20 lines
563 B
GDScript
20 lines
563 B
GDScript
extends CharacterBody2D
|
|
|
|
@onready var animationPlayer = $AnimatedSprite2D
|
|
const SPEED = 175
|
|
|
|
func _process(_delta):
|
|
velocity = Input.get_vector("moveLeft", "moveRight", "moveUp", "moveDown") * SPEED
|
|
move_and_slide()
|
|
|
|
if Input.is_action_pressed("moveUp"):
|
|
animationPlayer.play("walk_up")
|
|
elif Input.is_action_pressed("moveDown"):
|
|
animationPlayer.play("walk_down")
|
|
elif Input.is_action_pressed("moveLeft"):
|
|
animationPlayer.play("walk_left")
|
|
elif Input.is_action_pressed("moveRight"):
|
|
animationPlayer.play("walk_right")
|
|
else:
|
|
animationPlayer.stop()
|