smashball/scenes/player.gd
2025-11-13 00:37:12 -03:00

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)