108 lines
4.0 KiB
GDScript
108 lines
4.0 KiB
GDScript
extends Node2D
|
|
## Plancia Juggle Board in legno: binari a TUTTA larghezza con larghezza
|
|
## variabile (svasati alle estremità, stretti al centro), alloggiamenti
|
|
## circolari incassati e indicatori numerici 1-5, come nel mockup.
|
|
|
|
const VIEW := Vector2(1280, 720)
|
|
const LANE_TOP := 210.0
|
|
const LANE_GAP := 98.0
|
|
const LANE_LEFT := 70.0 # centro alloggiamento sinistro
|
|
const LANE_RIGHT := 1210.0 # centro alloggiamento destro
|
|
const SOCKET_R := 46.0 # raggio alloggiamento (ampio alle estremità)
|
|
const H_NARROW := 24.0 # semi-altezza canale al centro (stretto)
|
|
const CENTER_X := (LANE_LEFT + LANE_RIGHT) / 2.0
|
|
const HALF_SPAN := (LANE_RIGHT - LANE_LEFT) / 2.0
|
|
|
|
const LANE_FILL := Color("#c9ac7c")
|
|
const LANE_EDGE := Color(0.22, 0.15, 0.08, 0.9)
|
|
|
|
var wood_tex: Texture2D
|
|
var circus_tex: Texture2D
|
|
|
|
|
|
func _ready() -> void:
|
|
z_index = -10
|
|
wood_tex = load("res://assets/wood_board.png")
|
|
circus_tex = load("res://assets/circus_arena_bg.png")
|
|
queue_redraw()
|
|
|
|
|
|
func _draw() -> void:
|
|
# Arena circense quieta ai margini; la plancia copre il centro più ricco.
|
|
if circus_tex:
|
|
draw_texture_rect(circus_tex, Rect2(Vector2.ZERO, VIEW), false)
|
|
# Ombra e corpo smussato del tabellone.
|
|
var shadow := StyleBoxFlat.new()
|
|
shadow.bg_color = Color(0.12, 0.055, 0.02, 0.5)
|
|
shadow.corner_radius_top_left = 28
|
|
shadow.corner_radius_top_right = 28
|
|
shadow.corner_radius_bottom_left = 28
|
|
shadow.corner_radius_bottom_right = 28
|
|
draw_style_box(shadow, Rect2(32, 151, 1216, 560))
|
|
if wood_tex:
|
|
draw_texture_rect(wood_tex, Rect2(36, 142, 1208, 558), false)
|
|
var frame := StyleBoxFlat.new()
|
|
frame.bg_color = Color(0, 0, 0, 0)
|
|
frame.border_color = Color("#81542f")
|
|
frame.set_border_width_all(8)
|
|
frame.corner_radius_top_left = 27
|
|
frame.corner_radius_top_right = 27
|
|
frame.corner_radius_bottom_left = 27
|
|
frame.corner_radius_bottom_right = 27
|
|
draw_style_box(frame, Rect2(32, 138, 1216, 566))
|
|
for i in range(5):
|
|
_draw_lane(LANE_TOP + i * LANE_GAP)
|
|
_draw_number(i + 1, LANE_TOP + i * LANE_GAP)
|
|
|
|
|
|
func _lane_half_width(x: float) -> float:
|
|
# larghezza corsia: ampia alle estremità (d=1), stretta al centro (d=0)
|
|
var d := absf(x - CENTER_X) / HALF_SPAN
|
|
d = clampf(d, 0.0, 1.0)
|
|
return H_NARROW + (SOCKET_R - H_NARROW) * d * d
|
|
|
|
|
|
func _draw_lane(y: float) -> void:
|
|
var pts := PackedVector2Array()
|
|
var steps := 48
|
|
for k in range(steps + 1):
|
|
var x := lerpf(LANE_LEFT, LANE_RIGHT, float(k) / steps)
|
|
var hw := _lane_half_width(x)
|
|
pts.append(Vector2(x, y - hw))
|
|
for k in range(steps, -1, -1):
|
|
var x := lerpf(LANE_LEFT, LANE_RIGHT, float(k) / steps)
|
|
var hw := _lane_half_width(x)
|
|
pts.append(Vector2(x, y + hw))
|
|
draw_polygon(pts, [LANE_FILL])
|
|
var closed := pts.duplicate()
|
|
closed.append(pts[0])
|
|
draw_polyline(closed, LANE_EDGE, 3.0, true)
|
|
# Alloggiamenti a calotta: anelli concentrici e luce/ombra danno profondità.
|
|
for cx in [LANE_LEFT, LANE_RIGHT]:
|
|
var c := Vector2(cx, y)
|
|
draw_circle(c + Vector2(0, 4), SOCKET_R + 3.0, Color(0.12, 0.06, 0.02, 0.38))
|
|
draw_circle(c, SOCKET_R, Color("#8b6841"))
|
|
draw_circle(c + Vector2(0, 3), SOCKET_R - 6.0, Color("#6d4b2d"))
|
|
draw_circle(c + Vector2(-2, -4), SOCKET_R - 9.0, Color("#c5a476"))
|
|
draw_circle(c + Vector2(3, 5), SOCKET_R - 13.0, Color(0.2, 0.1, 0.04, 0.16))
|
|
draw_arc(c, SOCKET_R, 0.0, TAU, 48, Color("#4a301d"), 3.0)
|
|
draw_arc(c - Vector2(1, 2), SOCKET_R - 8.0, PI, TAU, 24, Color(1, 0.92, 0.72, 0.28), 2.0)
|
|
# ombra del canale in alto (profondità)
|
|
draw_rect(Rect2(LANE_LEFT + 10, y - _lane_half_width((LANE_LEFT + CENTER_X) / 2.0) + 3.0, HALF_SPAN * 2 - 20, 3.0),
|
|
Color(0.2, 0.12, 0.05, 0.18))
|
|
|
|
|
|
func _draw_number(n: int, y: float) -> void:
|
|
var c := Vector2(38, y)
|
|
var col: Color
|
|
match n:
|
|
1: col = Color("#de6b7e")
|
|
2: col = Color("#1852de")
|
|
3: col = Color("#88ce96")
|
|
4: col = Color("#e8b84b")
|
|
_: col = Color("#9b7ede")
|
|
draw_circle(c, 22.0, col)
|
|
draw_circle(c + Vector2(0, 2), 22.0, Color(0, 0, 0, 0.18))
|
|
draw_arc(c, 22.0, 0.0, TAU, 32, Color(0.1, 0.1, 0.1, 0.85), 2.0)
|
|
draw_string(ThemeDB.fallback_font, c + Vector2(-14, -10), str(n), HORIZONTAL_ALIGNMENT_CENTER, 28, 26, Color(1, 1, 1))
|