Main.gd 659 B

1234567891011121314151617181920212223
  1. extends Node2D
  2. func _process(_delta: float) -> void:
  3. # Keep redrawing on every frame.
  4. queue_redraw()
  5. func _draw() -> void:
  6. # Get the touch helper singleton.
  7. var touch_helper: Node = $"/root/TouchHelper"
  8. # Draw every pointer as a circle.
  9. for ptr_index: int in touch_helper.state.keys():
  10. var pos: Vector2 = touch_helper.state[ptr_index]
  11. var color := _get_color_for_ptr_index(ptr_index)
  12. color.a = 0.75
  13. draw_circle(pos, 40.0, color)
  14. ## Returns a unique-looking color for the specified index.
  15. func _get_color_for_ptr_index(index: int) -> Color:
  16. var x := (index % 7) + 1
  17. return Color(float(bool(x & 1)), float(bool(x & 2)), float(bool(x & 4)))