18 lines
464 B
GDScript
18 lines
464 B
GDScript
extends CharacterBody2D
|
|
class_name Player
|
|
|
|
@export var speed = 100
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
velocity = Vector2.ZERO
|
|
if Input.is_action_pressed("ui_down"):
|
|
velocity += Vector2.DOWN
|
|
if Input.is_action_pressed("ui_up"):
|
|
velocity += Vector2.UP
|
|
if Input.is_action_pressed("ui_left"):
|
|
velocity += Vector2.LEFT
|
|
if Input.is_action_pressed("ui_right"):
|
|
velocity += Vector2.RIGHT
|
|
velocity = velocity.normalized() * speed
|
|
move_and_slide()
|