#38: touch action buttons
TouchButtons (phones only, Main adds it beside TouchSticks): Pause, Fear, Bomb, Patch, Use (word from the new read-only Interactions.focus_info()) and Build, round Sketch buttons that press the existing actions for at least one physics tick, shown only when they can do something and hidden whenever the tree is paused or a menu, panel or sign is up. Columns follow TouchSticks.move_on_right (now a variable); both join "touch_controls" with apply_settings (Swap sticks), which Main calls at startup; Prompts.move_side() reads the live sticks. Stick fingers keep their drags over buttons. New Sketch icons: fear, patch, use, build, pause. Test: game/tests/mobile/buttons_test.gd. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5392ae09af
commit
e435b76aa2
9 changed files with 1115 additions and 48 deletions
|
|
@ -6,7 +6,8 @@ extends RefCounted
|
|||
## sketched outlines (each edge drawn twice, slightly off, overshooting its corners), painted
|
||||
## fills (a flat color, a lighter dab, a darker rim), and painted icons for the weapons, the
|
||||
## materials, the backpack, the sun and moon, the scarecrow's portrait, what thieves take (crops,
|
||||
## animals, supplies), the enemies, and the farmer and his wife (talking heads); and the morning
|
||||
## animals, supplies), the enemies, the farmer and his wife (talking heads), and the phone's touch
|
||||
## buttons (TouchButtons: fear, patch, use, build, pause; Bomb is the pumpkin bomb); and the morning
|
||||
## screen's wooden sign (planks, a nailed sheet of paper, leaves). Every wobble comes from a hash of a seed, so a shape is drawn the
|
||||
## same way each frame (no flicker).
|
||||
## Icons are designed in a 100 x 100 box and scaled to the rect they're drawn in.
|
||||
|
|
@ -39,7 +40,8 @@ const LEAF := Color(0.42, 0.64, 0.22)
|
|||
## EnemySystem.TYPE_NAMES, and these.
|
||||
const ICONS: Array[String] = ["pitchfork", "corn_shooter", "pumpkin_bomb", "potato_cannon", "shurikens",
|
||||
"propane_torch", "alien_ray", "wood", "scrap", "straw", "alien_goop", "backpack", "sun", "moon", "portrait",
|
||||
"crops", "animals", "supplies", "crow", "thief", "breaker", "ufo", "farmer", "farmers_wife"]
|
||||
"crops", "animals", "supplies", "crow", "thief", "breaker", "ufo", "farmer", "farmers_wife",
|
||||
"fear", "patch", "use", "build", "pause"]
|
||||
|
||||
static var _font: Font
|
||||
|
||||
|
|
@ -586,6 +588,54 @@ static func _icon(ci: CanvasItem, id: String) -> void:
|
|||
for j in 5:
|
||||
paint(ci, blob(flower + Vector2.from_angle(TAU * j / 5.0 - 0.3) * 5.5, 4.6, 4.6, 392.0 + j), Color(0.96, 0.42, 0.56), 397.0 + j, 1.2)
|
||||
ci.draw_circle(flower, 3.4, Color(1.0, 0.84, 0.3))
|
||||
"fear": # a fright: a jagged burst in the fear ring's blue, with a "boo" face
|
||||
var blue := Color(0.36, 0.74, 1.0)
|
||||
var burst := PackedVector2Array()
|
||||
for i in 18:
|
||||
var a := TAU * i / 18.0 - PI * 0.5
|
||||
burst.append(Vector2(50, 50) + Vector2(cos(a), sin(a)) * (46.0 if i % 2 == 0 else 29.0) + jitter(403.0 + i, 1.8))
|
||||
paint(ci, burst, blue, 422.0)
|
||||
for k: float in [-1.0, 1.0]:
|
||||
paint(ci, blob(Vector2(50.0 + 11.0 * k, 42.0), 5.5, 7.5, 423.0 + k), INK, 425.0 + k, 0.0)
|
||||
paint(ci, blob(Vector2(50, 63), 8.5, 10.5, 427.0, 0.06), INK, 428.0, 0.0)
|
||||
"patch": # a heart patched with a square of straw, stitched on
|
||||
var heart := PackedVector2Array()
|
||||
for i in 36:
|
||||
var a := TAU * i / 36.0
|
||||
var y := 13.0 * cos(a) - 5.0 * cos(2.0 * a) - 2.0 * cos(3.0 * a) - cos(4.0 * a)
|
||||
heart.append(Vector2(50.0 + 40.0 * sin(a) * sin(a) * sin(a), 47.0 - 2.5 * y) + jitter(431.0 + i, 0.6))
|
||||
paint(ci, heart, Color(0.88, 0.14, 0.12), 468.0)
|
||||
var square := PackedVector2Array([Vector2(40, 37), Vector2(68, 33), Vector2(72, 61), Vector2(44, 65)])
|
||||
paint(ci, square, Color(0.96, 0.82, 0.36), 469.0, 2.0)
|
||||
for i in 4:
|
||||
var a := square[i]
|
||||
var b := square[(i + 1) % 4]
|
||||
var across := (b - a).orthogonal().normalized() * 4.5
|
||||
for k in 3:
|
||||
var m := a.lerp(b, (k + 0.5) / 3.0)
|
||||
ci.draw_line(m - across, m + across, INK, 2.5, true)
|
||||
"use": # an open hand in a work glove, reaching out
|
||||
var glove := Color(0.93, 0.79, 0.5)
|
||||
for k in 4:
|
||||
var x := 35.0 + k * 10.0
|
||||
stroke(ci, Vector2(x, 58.0), Vector2(x + (k - 1.5) * 2.5, 20.0 + absf(k - 1.4) * 6.0), glove, 8.0, 471.0 + k)
|
||||
stroke(ci, Vector2(34.0, 72.0), Vector2(16.0, 52.0), glove, 8.0, 475.0)
|
||||
paint(ci, PackedVector2Array([Vector2(29, 50), Vector2(71, 49), Vector2(70, 82), Vector2(31, 83)]), glove, 476.0)
|
||||
paint(ci, PackedVector2Array([Vector2(29, 80), Vector2(71, 79), Vector2(72, 95), Vector2(28, 96)]), glove.darkened(0.3), 477.0, 2.0)
|
||||
"build": # a claw hammer
|
||||
var grip := Vector2(28, 90)
|
||||
var top := Vector2(60, 38)
|
||||
stroke(ci, grip, top, WOOD, 10.0, 481.0)
|
||||
var d := (top - grip).normalized() # along the handle
|
||||
var p := d.orthogonal() # across it: the head, its striking face up and to the left
|
||||
var c := top + d * 4.0
|
||||
paint(ci, PackedVector2Array([c - p * 14.0 + d * 6.0, c - p * 30.0 + d * 1.0, c - p * 38.0 - d * 12.0, c - p * 28.0 - d * 6.0,
|
||||
c - p * 14.0 - d * 6.0]), Color(0.56, 0.58, 0.62), 482.0, 2.0) # the claw, curling back
|
||||
paint(ci, PackedVector2Array([c + p * 24.0 - d * 9.0, c + p * 24.0 + d * 9.0, c - p * 14.0 + d * 9.0, c - p * 14.0 - d * 9.0]),
|
||||
Color(0.66, 0.68, 0.72), 483.0)
|
||||
"pause": # two upright bars
|
||||
for x: float in [25.0, 57.0]:
|
||||
paint(ci, PackedVector2Array([Vector2(x, 17), Vector2(x + 18.0, 16), Vector2(x + 19.0, 84), Vector2(x + 1.0, 85)]), TEXT, 491.0 + x, 3.0)
|
||||
|
||||
|
||||
## An open outline (pts) closed with straight edges through corners, in steps about 5 long, so
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue