create code regions
This commit is contained in:
parent
a446efbac0
commit
12093b4234
1 changed files with 4 additions and 0 deletions
|
|
@ -7,15 +7,19 @@ func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void:
|
||||||
|
|
||||||
|
|
||||||
func _state_physics_update(_delta: float) -> void:
|
func _state_physics_update(_delta: float) -> void:
|
||||||
|
#region player physics
|
||||||
var direction: Vector2 = player.get_movement_vector()
|
var direction: Vector2 = player.get_movement_vector()
|
||||||
direction = direction.normalized()
|
direction = direction.normalized()
|
||||||
player.velocity = direction * player.max_speed
|
player.velocity = direction * player.max_speed
|
||||||
|
|
||||||
player.move_and_slide()
|
player.move_and_slide()
|
||||||
|
#endregion
|
||||||
|
|
||||||
if watch_state([WALKING]): return
|
if watch_state([WALKING]): return
|
||||||
|
|
||||||
|
#region player animation
|
||||||
if direction.y > 0: player.sprite.play("walk_down")
|
if direction.y > 0: player.sprite.play("walk_down")
|
||||||
elif direction.y < 0: player.sprite.play("walk_up")
|
elif direction.y < 0: player.sprite.play("walk_up")
|
||||||
elif direction.x > 0: player.sprite.play("walk_right")
|
elif direction.x > 0: player.sprite.play("walk_right")
|
||||||
elif direction.x < 0: player.sprite.play("walk_left")
|
elif direction.x < 0: player.sprite.play("walk_left")
|
||||||
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue