cleaned up player movement code
This commit is contained in:
@@ -11,17 +11,10 @@ var color := Color.WHITE
|
||||
var lives: int = 1
|
||||
|
||||
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
|
||||
var input_direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||
velocity = input_direction * speed
|
||||
move_and_slide()
|
||||
|
||||
for i in range(get_slide_collision_count()):
|
||||
var collision := get_slide_collision(i)
|
||||
if collision.get_collider() is Chest:
|
||||
|
||||
Reference in New Issue
Block a user