player_controls.gd 562 B

123456789101112131415161718192021222324
  1. extends Node
  2. @export
  3. var motion = Vector2():
  4. set(value):
  5. # This will be sent by players, make sure values are within limits.
  6. motion = clamp(value, Vector2(-1, -1), Vector2(1, 1))
  7. @export
  8. var bombing = false
  9. func update():
  10. var m = Vector2()
  11. if Input.is_action_pressed("move_left"):
  12. m += Vector2(-1, 0)
  13. if Input.is_action_pressed("move_right"):
  14. m += Vector2(1, 0)
  15. if Input.is_action_pressed("move_up"):
  16. m += Vector2(0, -1)
  17. if Input.is_action_pressed("move_down"):
  18. m += Vector2(0, 1)
  19. motion = m
  20. bombing = Input.is_action_pressed("set_bomb")