player_controls.gd 578 B

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