TableTower/ui/die_icon.gd
RobinFiredrake 60c2d03147 Build the pipe-board app in Godot
Tables are cards on a felt board, joined by copper pipes that carry a
roll from one table to the next. Play mode rolls with a flicker and a
bead down each pipe; Build mode edits names, results, ranges and pipes.

- core/: data model (RollTable, TableEntry, TowerBoard), sample board
  with a d100 table of 100 trinkets and a weighted d100 range table,
  and a Roller with a depth limit
- ui/: board with pan and zoom, pipe and port layers, collapsible table
  cards, result tray with earlier rolls, undo toasts, and a Collapse all
  / Expand all button
- assets/fonts/: Rokkitt and Atkinson Hyperlegible (SIL OFL)
- tests/test_roller.gd: headless checks for the model and roller

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 12:05:41 -06:00

46 lines
1.1 KiB
GDScript

class_name DieIcon
extends Control
## A three-pip die face. Tumbles while `spinning` is on.
var color: Color = Style.BRASS
var spinning: bool = false:
set(value):
spinning = value
if not value:
_angle = 0.0
set_process(value)
queue_redraw()
var _angle: float = 0.0
var _frame: StyleBoxFlat
func _init() -> void:
custom_minimum_size = Vector2(20, 20)
size = custom_minimum_size
mouse_filter = MOUSE_FILTER_IGNORE
_frame = StyleBoxFlat.new()
_frame.draw_center = false
_frame.set_border_width_all(2)
_frame.set_corner_radius_all(3)
_frame.anti_aliasing = true
set_process(false)
func _ready() -> void:
# Godot turns processing on for nodes with _process when they become ready.
set_process(spinning)
func _process(delta: float) -> void:
_angle = fmod(_angle + delta * TAU * 2.0, TAU)
queue_redraw()
func _draw() -> void:
draw_set_transform(size / 2.0, _angle)
_frame.border_color = color
draw_style_box(_frame, Rect2(-7.5, -7.5, 15, 15))
for p in [Vector2(-3, -3), Vector2(0, 0), Vector2(3, 3)]:
draw_circle(p, 1.45, color)
draw_set_transform(Vector2.ZERO)