18 lines
553 B
GDScript
18 lines
553 B
GDScript
extends CharacterBody2D
|
|
|
|
const MAX_SPEED: float = 200
|
|
|
|
func _ready() -> void:
|
|
pass
|
|
|
|
func _process(delta: float) -> void:
|
|
var movement_vector: Vector2 = get_movement_vector()
|
|
var direction: Vector2 = movement_vector.normalized()
|
|
velocity = direction * MAX_SPEED
|
|
|
|
move_and_slide()
|
|
|
|
func get_movement_vector() -> Vector2:
|
|
var x_mov: float = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
|
|
var y_mov: float = Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
|
|
return Vector2(x_mov, y_mov)
|