Added player and a basic test level
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
extends NodeState
|
||||
|
||||
@export var player: Player
|
||||
@export var animatedSprite2D: AnimatedSprite2D
|
||||
|
||||
@onready var friction = player.friction
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func on_process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
@warning_ignore("unused_parameter")
|
||||
func on_phyisics_process(delta: float) -> void:
|
||||
player.velocity.x = move_toward(player.velocity.x, 0, friction * delta)
|
||||
|
||||
|
||||
transition_states()
|
||||
|
||||
func enter() -> void:
|
||||
animatedSprite2D.play("Idle")
|
||||
|
||||
func exit() -> void:
|
||||
animatedSprite2D.stop()
|
||||
|
||||
func transition_states() -> void:
|
||||
#transitioning state
|
||||
|
||||
#fall state
|
||||
if !player.is_on_floor():
|
||||
transition.emit("fall")
|
||||
|
||||
#run state
|
||||
var direction: float = GameInputEvents.movement_input()
|
||||
|
||||
if direction and player.is_on_floor():
|
||||
transition.emit("Run")
|
||||
|
||||
#jump state
|
||||
if GameInputEvents.jump_input():
|
||||
transition.emit("jump")
|
||||
|
||||
#shoot crouch state
|
||||
if Input.is_action_pressed("crouch"):
|
||||
transition.emit("CrouchIdle")
|
||||
Reference in New Issue
Block a user