Files
autgame/scripts/hud_cartouche.gd
T

56 lines
2.2 KiB
GDScript

extends Node2D
## Cartiglio circense in legno, puramente decorativo: la UI interattiva
## rimane costruita da main.gd sopra questo nodo.
const INK := Color("#5b2f19")
const WOOD_LIGHT := Color("#efd6aa")
const WOOD_MID := Color("#d8ad72")
const WOOD_DARK := Color("#8a552d")
func _draw() -> void:
# Ombra morbida e sagoma con angoli tagliati a 45 gradi.
var shadow := PackedVector2Array([
Vector2(56, 27), Vector2(75, 10), Vector2(1205, 10), Vector2(1224, 27),
Vector2(1224, 128), Vector2(1205, 145), Vector2(75, 145), Vector2(56, 128)
])
for i in range(shadow.size()):
shadow[i] += Vector2(0, 7)
draw_colored_polygon(shadow, Color(0.12, 0.055, 0.02, 0.42))
var body := PackedVector2Array([
Vector2(56, 27), Vector2(75, 10), Vector2(1205, 10), Vector2(1224, 27),
Vector2(1224, 128), Vector2(1205, 145), Vector2(75, 145), Vector2(56, 128)
])
draw_colored_polygon(body, WOOD_LIGHT)
var rim := body.duplicate()
rim.append(body[0])
draw_polyline(rim, WOOD_DARK, 5.0, true)
# Incisioni e venatura tenue.
draw_line(Vector2(79, 25), Vector2(1201, 25), Color(1, 0.93, 0.78, 0.7), 2.0)
draw_line(Vector2(78, 130), Vector2(1202, 130), Color(0.38, 0.18, 0.07, 0.25), 2.0)
for y in [42.0, 104.0, 119.0]:
draw_arc(Vector2(640, y), 420.0, 0.08, PI - 0.08, 40, Color(0.45, 0.24, 0.1, 0.09), 1.0)
# Tasca incassata della biglia bersaglio.
_draw_socket(Vector2(430, 78), 43.0)
# Borchie dorate del cartiglio e della targhetta Opzioni.
for p in [Vector2(78, 34), Vector2(1202, 34), Vector2(78, 120), Vector2(1202, 120),
Vector2(567, 76), Vector2(713, 76)]:
_draw_stud(p)
func _draw_stud(p: Vector2) -> void:
draw_circle(p + Vector2(1, 3), 8.0, Color(0.25, 0.12, 0.03, 0.32))
draw_circle(p, 7.0, Color("#b77a24"))
draw_circle(p - Vector2(1.5, 2), 4.2, Color("#edc668"))
draw_circle(p - Vector2(2.5, 3), 1.5, Color(1, 0.94, 0.7, 0.9))
draw_arc(p, 7.0, 0.0, TAU, 20, Color("#714318"), 1.5)
func _draw_socket(p: Vector2, r: float) -> void:
draw_circle(p + Vector2(0, 3), r + 4.0, Color(0.28, 0.14, 0.06, 0.55))
draw_circle(p, r, WOOD_DARK)
draw_circle(p + Vector2(0, 3), r - 7.0, Color("#5b351f"))
draw_circle(p + Vector2(-2, -3), r - 10.0, Color(0.93, 0.76, 0.51, 0.28))
draw_arc(p, r, 0.0, TAU, 36, INK, 2.5)