Files
study-life/entities/player/player.gd

19 lines
393 B
GDScript

extends CharacterBody2D
@export var speed = 400
func _physics_process(_delta):
velocity.x = 0
velocity.y = 0
if Input.is_action_pressed("move_down"):
velocity.y = speed
elif Input.is_action_pressed("move_up"):
velocity.y = -speed
elif Input.is_action_pressed("move_right"):
velocity.x = speed
elif Input.is_action_pressed("move_left"):
velocity.x = -speed
move_and_slide()