basic death functionality
This commit is contained in:
parent
60a6df808e
commit
d77ed8a49f
4 changed files with 30 additions and 5 deletions
|
@ -18,6 +18,9 @@ extends CharacterBody2D
|
|||
@export var run_animation: SpritesheetAnimation
|
||||
|
||||
|
||||
@onready var start_position: Vector2 = global_position
|
||||
|
||||
|
||||
var input_dir: Vector2 = Vector2.ZERO:
|
||||
set(value):
|
||||
input_dir = value.sign()
|
||||
|
@ -42,6 +45,10 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
state_chart.send_event(&"jump_pressed")
|
||||
|
||||
|
||||
func kill() -> void:
|
||||
state_chart.send_event(&"killed")
|
||||
|
||||
|
||||
#region Idle
|
||||
func _slow_to_stop(delta: float) -> void:
|
||||
velocity.x = move_toward(velocity.x, 0.0, stopping_force * delta)
|
||||
|
@ -82,3 +89,10 @@ func _face_towards_velocity(_delta: float) -> void:
|
|||
func _restore_graphics_rotation() -> void:
|
||||
graphics.rotation = 0.0
|
||||
#endregion
|
||||
|
||||
|
||||
#region Death
|
||||
func _reset_position() -> void:
|
||||
global_position = start_position
|
||||
velocity = Vector2.ZERO
|
||||
#endregion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue