This commit is contained in:
Tabby 2025-08-08 15:17:37 +10:00
parent f0f173ee06
commit 23b21cefbb
3 changed files with 14 additions and 4 deletions

View file

@ -24,8 +24,14 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
move_progress += delta * snake_speed
if Input.get_vector("left","right","up","down").length() > 0:
want_direction = Input.get_vector("left","right","up","down")
if Input.is_action_just_pressed("left"):
want_direction = Vector2.LEFT
elif Input.is_action_just_pressed("right"):
want_direction = Vector2.RIGHT
elif Input.is_action_just_pressed("up"):
want_direction = Vector2.UP
elif Input.is_action_just_pressed("down"):
want_direction = Vector2.DOWN
position = lerp(start_pos,target_pos,move_progress)
if move_progress >= 1:
get_new_target()