Added player and a basic test level
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
extends NodeState
|
||||
|
||||
@export_category("nodes")
|
||||
@export var player: Player
|
||||
@export var animatedSprite2D: AnimatedSprite2D
|
||||
@export var ledgeGrabBox: CollisionShape2D
|
||||
@export var wallCheck: ShapeCast2D
|
||||
@export var floorCheck: RayCast2D
|
||||
|
||||
const GRAVITY = player.GRAVITY
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func on_process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func on_phyisics_process(delta: float) -> void:
|
||||
|
||||
var collision = wallCheck.get_collision_normal(0)
|
||||
if collision.x == -1:
|
||||
animatedSprite2D.flip_h = false
|
||||
if collision.x == 1:
|
||||
animatedSprite2D.flip_h = true
|
||||
|
||||
transition_states()
|
||||
|
||||
func enter() -> void:
|
||||
player.velocity.x = 0
|
||||
ledgeGrabBox.disabled = false
|
||||
animatedSprite2D.play("Ledge Grab")
|
||||
|
||||
func exit() -> void:
|
||||
ledgeGrabBox.disabled = true
|
||||
animatedSprite2D.stop()
|
||||
|
||||
func transition_states() -> void:
|
||||
|
||||
if GameInputEvents.jump_input():
|
||||
transition.emit("jump")
|
||||
|
||||
if floorCheck.is_colliding():
|
||||
transition.emit("idle")
|
||||
|
||||
if GameInputEvents.crouch_input():
|
||||
ledgeGrabBox.disabled = true
|
||||
transition.emit("fall")
|
||||
Reference in New Issue
Block a user