Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fde68603cb | ||
|
|
686fee043e | ||
|
|
4b709ffd80 | ||
|
|
733680301c | ||
|
|
0ba8cfc800 | ||
|
|
84ad19a47e | ||
|
|
058acd6325 | ||
|
|
497209fc9a | ||
|
|
2289480812 | ||
|
|
de418c0da8 | ||
|
|
713e328138 | ||
|
|
6a5a80d7af | ||
|
|
88f0439f79 | ||
|
|
c244424af9 | ||
|
|
c26d888263 | ||
|
|
f8dbd01358 | ||
|
|
e3d5d8b0d3 | ||
|
|
1b7511f6ca | ||
|
|
9d2cc2fcb3 | ||
|
|
44480221db | ||
|
|
4d13a4ef25 | ||
|
|
22f408cc60 | ||
|
|
927459344b | ||
|
|
08ab9ba069 | ||
|
|
1918c8d9c7 | ||
|
|
381254ed4d |
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"image": "chiaru.png",
|
||||
"height": 120,
|
||||
"frames": {
|
||||
"explain": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 56,
|
||||
"h": 120,
|
||||
"ax": 31.5,
|
||||
"ay": 120
|
||||
},
|
||||
"talk": {
|
||||
"x": 58,
|
||||
"y": 0,
|
||||
"w": 64,
|
||||
"h": 119,
|
||||
"ax": 38.5,
|
||||
"ay": 119
|
||||
},
|
||||
"blink": {
|
||||
"x": 124,
|
||||
"y": 0,
|
||||
"w": 44,
|
||||
"h": 120,
|
||||
"ax": 24.2,
|
||||
"ay": 120
|
||||
},
|
||||
"stand": {
|
||||
"x": 170,
|
||||
"y": 0,
|
||||
"w": 44,
|
||||
"h": 120,
|
||||
"ax": 24.2,
|
||||
"ay": 120
|
||||
},
|
||||
"cheer": {
|
||||
"x": 216,
|
||||
"y": 0,
|
||||
"w": 66,
|
||||
"h": 118,
|
||||
"ax": 31.5,
|
||||
"ay": 118
|
||||
},
|
||||
"shrug": {
|
||||
"x": 284,
|
||||
"y": 0,
|
||||
"w": 79,
|
||||
"h": 119,
|
||||
"ax": 42.2,
|
||||
"ay": 119
|
||||
},
|
||||
"watch": {
|
||||
"x": 365,
|
||||
"y": 0,
|
||||
"w": 63,
|
||||
"h": 98,
|
||||
"ax": 30.3,
|
||||
"ay": 98
|
||||
},
|
||||
"laugh": {
|
||||
"x": 430,
|
||||
"y": 0,
|
||||
"w": 52,
|
||||
"h": 120,
|
||||
"ax": 30.3,
|
||||
"ay": 120
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 100 KiB |
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"image": "zio_mario.png",
|
||||
"height": 120,
|
||||
"frames": {
|
||||
"explain": {
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"w": 67,
|
||||
"h": 120,
|
||||
"ax": 33.8,
|
||||
"ay": 120
|
||||
},
|
||||
"talk": {
|
||||
"x": 69,
|
||||
"y": 0,
|
||||
"w": 79,
|
||||
"h": 120,
|
||||
"ax": 44.8,
|
||||
"ay": 120
|
||||
},
|
||||
"blink": {
|
||||
"x": 150,
|
||||
"y": 0,
|
||||
"w": 57,
|
||||
"h": 120,
|
||||
"ax": 28.1,
|
||||
"ay": 120
|
||||
},
|
||||
"stand": {
|
||||
"x": 209,
|
||||
"y": 0,
|
||||
"w": 57,
|
||||
"h": 120,
|
||||
"ax": 27.8,
|
||||
"ay": 120
|
||||
},
|
||||
"shrug": {
|
||||
"x": 268,
|
||||
"y": 0,
|
||||
"w": 94,
|
||||
"h": 120,
|
||||
"ax": 48.1,
|
||||
"ay": 120
|
||||
},
|
||||
"point": {
|
||||
"x": 364,
|
||||
"y": 0,
|
||||
"w": 87,
|
||||
"h": 120,
|
||||
"ax": 51.0,
|
||||
"ay": 120
|
||||
},
|
||||
"think": {
|
||||
"x": 453,
|
||||
"y": 0,
|
||||
"w": 58,
|
||||
"h": 121,
|
||||
"ax": 29.2,
|
||||
"ay": 121
|
||||
},
|
||||
"laugh": {
|
||||
"x": 513,
|
||||
"y": 0,
|
||||
"w": 59,
|
||||
"h": 121,
|
||||
"ax": 30.1,
|
||||
"ay": 121
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 115 KiB |
|
After Width: | Height: | Size: 388 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 1006 B |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 316 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 228 KiB |
@@ -95,6 +95,10 @@
|
||||
"file": "andrea-a9df2e6bbb.mp3",
|
||||
"sec": 4.98
|
||||
},
|
||||
"andrea|La bottega di Pierin di Frilli, sotto la tenda rossa. Da ragazzi ci si comprava lo stucco per la cerbottana.": {
|
||||
"file": "andrea-cb15f8f919.mp3",
|
||||
"sec": 7.29
|
||||
},
|
||||
"andrea|Il Circolo 4 Maggio. Dentro, dietro il bar, la sala dei biliardi: tre tavoli e il silenzio delle grandi occasioni.": {
|
||||
"file": "andrea-f0aef83c80.mp3",
|
||||
"sec": 9.43
|
||||
@@ -935,9 +939,9 @@
|
||||
"file": "andrea-127a90af53.mp3",
|
||||
"sec": 9.37
|
||||
},
|
||||
"andrea|Bertovo, al tavolo di mezzo. Le biglie le mette dove nessuno ci arriva, e poi ci arriva lui.": {
|
||||
"file": "andrea-0b28b74cdb.mp3",
|
||||
"sec": 6.78
|
||||
"andrea|Trappizzio Berti, al tavolo di mezzo. Le biglie le mette dove nessuno ci arriva, e poi ci arriva lui.": {
|
||||
"file": "andrea-089ce1d608.mp3",
|
||||
"sec": 7.92
|
||||
},
|
||||
"andrea|Le stecche del circolo, in fila. Ognuna ha il suo proprietario, e guai a sbagliare.": {
|
||||
"file": "andrea-1eae1a8577.mp3",
|
||||
@@ -1187,14 +1191,6 @@
|
||||
"file": "andrea-00f2e70a4d.mp3",
|
||||
"sec": 2.95
|
||||
},
|
||||
"andrea|La Ghiacciomobile nera. Hai visto cose che noi poveri umani non potremmo neppur lontanamente immaginare.": {
|
||||
"file": "andrea-7be29434e0.mp3",
|
||||
"sec": 7.25
|
||||
},
|
||||
"andrea|Con questo sole, di ghiaccio c'è rimasto giusto il nome. Vo a piedi.": {
|
||||
"file": "andrea-def44809bc.mp3",
|
||||
"sec": 5.08
|
||||
},
|
||||
"andrea|Il circolino: il Circolo SMS di Campomigliaio. Un'istituzione, qui i volontari hanno sempre fatto miracoli.": {
|
||||
"file": "andrea-90bbad0de0.mp3",
|
||||
"sec": 9.59
|
||||
@@ -1627,6 +1623,14 @@
|
||||
"file": "andrea-7c17aa384c.mp3",
|
||||
"sec": 3.2
|
||||
},
|
||||
"andrea|La Ghiacciomobile nera, mezza dentro il muro. Hai visto cose che noi poveri umani non potremmo neppur lontanamente immaginare.": {
|
||||
"file": "andrea-decbc1c807.mp3",
|
||||
"sec": 9.49
|
||||
},
|
||||
"andrea|Per tirarla fuori di lì ci vuole altro che le mie braccia.": {
|
||||
"file": "andrea-a193a43f3e.mp3",
|
||||
"sec": 3.78
|
||||
},
|
||||
"andrea|Nessuno ha mai capito davvero il tuo immenso valore.": {
|
||||
"file": "andrea-3e85200509.mp3",
|
||||
"sec": 2.93
|
||||
@@ -1639,14 +1643,26 @@
|
||||
"file": "andrea-3d15dd47bb.mp3",
|
||||
"sec": 4.82
|
||||
},
|
||||
"andrea|Lo zio Mario. Guarda il muro, guarda la macchina, e si gratta la testa sotto il berretto.": {
|
||||
"file": "andrea-9da3d936d3.mp3",
|
||||
"sec": 6.14
|
||||
},
|
||||
"andrea|Zio, hai problemi?": {
|
||||
"file": "andrea-c36f0dd2c5.mp3",
|
||||
"sec": 1.52
|
||||
},
|
||||
"zio_mario|I problemi io gli avevo quando andavo a scuola!": {
|
||||
"file": "zio_mario-b3e99c241a.mp3",
|
||||
"sec": 2.68
|
||||
},
|
||||
"andrea|Il parcheggio sotto casa. Col gesso ci si disegnava la pista delle macchinine, e si giocava finché non chiamavano per cena.": {
|
||||
"file": "andrea-8670e6ce99.mp3",
|
||||
"sec": 7.6
|
||||
},
|
||||
"andrea|Casa mia. Secondo piano: quella con la tapparella a metà è la camera di mia sorella, e a destra quella dei miei.": {
|
||||
"file": "andrea-6c9e7f684e.mp3",
|
||||
"sec": 8.72
|
||||
},
|
||||
"andrea|Se salgo, mi mettono ad apparecchiare. Prima il palio.": {
|
||||
"file": "andrea-8945f1786d.mp3",
|
||||
"sec": 3.89
|
||||
},
|
||||
"andrea|Il prato sotto casa. Qui le porte le facevamo con le maglie per terra: due maglie, un palo ciascuna.": {
|
||||
"file": "andrea-4708fda5ef.mp3",
|
||||
"sec": 6.92
|
||||
@@ -1667,6 +1683,54 @@
|
||||
"file": "andrea-f6c10fd559.mp3",
|
||||
"sec": 6.28
|
||||
},
|
||||
"andrea|Il Chiaru, con le ginocchia bianche di gesso e una Formula 1 blu in mano.": {
|
||||
"file": "andrea-8d5911c8e7.mp3",
|
||||
"sec": 4.53
|
||||
},
|
||||
"andrea|La vista di casa. Da qui si vede mezzo paese, e lassù la Fortezza.": {
|
||||
"file": "andrea-8a63e250ae.mp3",
|
||||
"sec": 5.64
|
||||
},
|
||||
"andrea|Lassù in cima, fra gli alberi, la Fortezza. Da qui pare piccina.": {
|
||||
"file": "andrea-6544c0d778.mp3",
|
||||
"sec": 6.17
|
||||
},
|
||||
"andrea|Il paese che sale verso la collina, coi tetti uno sull'altro e il campanile in mezzo.": {
|
||||
"file": "andrea-b082638d5a.mp3",
|
||||
"sec": 5.93
|
||||
},
|
||||
"andrea|Il palazzo accanto, di mattoni come il nostro.": {
|
||||
"file": "andrea-8d0507f514.mp3",
|
||||
"sec": 2.45
|
||||
},
|
||||
"andrea|I gerani. Guai a chi li tocca.": {
|
||||
"file": "andrea-54d8dfd381.mp3",
|
||||
"sec": 2.86
|
||||
},
|
||||
"andrea|Se ne strappo uno, il palio lo guardo dal letto.": {
|
||||
"file": "andrea-02fe387f5d.mp3",
|
||||
"sec": 3.45
|
||||
},
|
||||
"andrea|L'edera nel vaso: cresce da sola, e si arrampica dove le pare.": {
|
||||
"file": "andrea-ab2bb4cae8.mp3",
|
||||
"sec": 4.68
|
||||
},
|
||||
"andrea|Una sedia di plastica, piegata.": {
|
||||
"file": "andrea-8b314f556d.mp3",
|
||||
"sec": 2.05
|
||||
},
|
||||
"andrea|Sedermi qui a guardare il paese? Prima il palio.": {
|
||||
"file": "andrea-7593ef5d63.mp3",
|
||||
"sec": 3.41
|
||||
},
|
||||
"andrea|La porta-finestra di casa, con la tapparella a metà.": {
|
||||
"file": "andrea-be7c2b9a45.mp3",
|
||||
"sec": 3.16
|
||||
},
|
||||
"andrea|Se rientro, mi mettono ad apparecchiare. Prima il palio.": {
|
||||
"file": "andrea-2e64b2d5c2.mp3",
|
||||
"sec": 4.8
|
||||
},
|
||||
"andrea|Un pino a ombrello enorme. Alla ricreazione, tutti all'ombra lì sotto. Sembra ieri.": {
|
||||
"file": "andrea-0a073729fd.mp3",
|
||||
"sec": 7.3
|
||||
@@ -2212,8 +2276,8 @@
|
||||
"sec": 4.42
|
||||
},
|
||||
"arcu|Fammi vedere... Verde. Come la Panda di mi' zio.": {
|
||||
"file": "arcu-62e981592d.mp3",
|
||||
"sec": 6.29
|
||||
"file": "arcu-82526ee9fb.mp3",
|
||||
"sec": 4.52
|
||||
},
|
||||
"arcu|Verde! Allora il Regolo tifa Cardetole. Tradimento.": {
|
||||
"file": "arcu-9e5b7c6e95.mp3",
|
||||
@@ -2427,9 +2491,97 @@
|
||||
"file": "mariano-d65fb6e871.mp3",
|
||||
"sec": 3.42
|
||||
},
|
||||
"andrea|Bertovo! Che fai, giochi da solo?": {
|
||||
"file": "andrea-2eaaaffa37.mp3",
|
||||
"sec": 3
|
||||
"andrea|Una cerbottana e un po' di stucco, Pierino!": {
|
||||
"file": "andrea-eaaf19eef0.mp3",
|
||||
"sec": 2.77
|
||||
},
|
||||
"andrea|Niente, grazie: guardavo.": {
|
||||
"file": "andrea-12cbe6f9a8.mp3",
|
||||
"sec": 2.26
|
||||
},
|
||||
"andrea|Lo stucco verde di Pierino: quell'odore non te lo levi più dalle dita.": {
|
||||
"file": "andrea-2ede7e7324.mp3",
|
||||
"sec": 3.82
|
||||
},
|
||||
"andrea|Ora un muro. Quello della piazza va benissimo.": {
|
||||
"file": "andrea-9cc0991d39.mp3",
|
||||
"sec": 3.32
|
||||
},
|
||||
"andrea|No, dopo.": {
|
||||
"file": "andrea-78ad61a67a.mp3",
|
||||
"sec": 1.22
|
||||
},
|
||||
"andrea|Si fa una gara alle macchinine?!?!": {
|
||||
"file": "andrea-17216997e2.mp3",
|
||||
"sec": 2.74
|
||||
},
|
||||
"andrea|Che pista hai disegnato?": {
|
||||
"file": "andrea-3dd737ed1b.mp3",
|
||||
"sec": 1.46
|
||||
},
|
||||
"andrea|Le regole sono quelle solite?": {
|
||||
"file": "andrea-ee03433b9c.mp3",
|
||||
"sec": 1.6
|
||||
},
|
||||
"andrea|Vado a fare un girino alle case rosse.": {
|
||||
"file": "andrea-cb2fa74266.mp3",
|
||||
"sec": 1.97
|
||||
},
|
||||
"chiaru|Un giro, una spinta a testa, prima te. Tutta fuori dal gesso, si torna indietro. Come la vuoi?": {
|
||||
"file": "chiaru-df4b1e3a0e.mp3",
|
||||
"sec": 7.32
|
||||
},
|
||||
"chiaru|Rettilineo, curvone, rettilineo, e in fondo la esse. Nella esse chi ha fretta esce.": {
|
||||
"file": "chiaru-a7d83e9454.mp3",
|
||||
"sec": 7.35
|
||||
},
|
||||
"chiaru|Il tombino l'ho lasciato in pista: porta fortuna.": {
|
||||
"file": "chiaru-3810b7d228.mp3",
|
||||
"sec": 3.56
|
||||
},
|
||||
"chiaru|Le solite. Chi accompagna la macchinina col dito: accompagnè.": {
|
||||
"file": "chiaru-bb17a500b5.mp3",
|
||||
"sec": 4.39
|
||||
},
|
||||
"chiaru|Chi taglia la strada: tagliè. Chi si ribalta: cappottè. E chi esce tutto dal gesso, fuori.": {
|
||||
"file": "chiaru-1db3c53c04.mp3",
|
||||
"sec": 7.9
|
||||
},
|
||||
"chiaru|In tutti i casi, si torna dov'eri prima.": {
|
||||
"file": "chiaru-a7ab8d241f.mp3",
|
||||
"sec": 2.01
|
||||
},
|
||||
"chiaru|Vorrai dire un giochino!": {
|
||||
"file": "chiaru-c106f9e9c4.mp3",
|
||||
"sec": 1.14
|
||||
},
|
||||
"andrea|Ciao Mattè.": {
|
||||
"file": "andrea-fc5a08bbd6.mp3",
|
||||
"sec": 0.73
|
||||
},
|
||||
"andrea|No, aspetta.": {
|
||||
"file": "andrea-04890c1d8e.mp3",
|
||||
"sec": 1.39
|
||||
},
|
||||
"chiaru|Alla bona: ti faccio vedere dove si ferma. E io vado piano.": {
|
||||
"file": "chiaru-d31cc223f6.mp3",
|
||||
"sec": 5.08
|
||||
},
|
||||
"chiaru|Seria. Così mi piace.": {
|
||||
"file": "chiaru-89bf2bb9f9.mp3",
|
||||
"sec": 2.31
|
||||
},
|
||||
"chiaru|A fassi male. Poi non piangere.": {
|
||||
"file": "chiaru-f551f6a268.mp3",
|
||||
"sec": 2.5
|
||||
},
|
||||
"chiaru|Io intanto ripasso il gesso.": {
|
||||
"file": "chiaru-a0d7dbb4c1.mp3",
|
||||
"sec": 2.15
|
||||
},
|
||||
"andrea|Fabri! Che fai, giochi da solo?": {
|
||||
"file": "andrea-44037129d8.mp3",
|
||||
"sec": 2.71
|
||||
},
|
||||
"andrea|Come fai a prendere le biglie dove nessuno ci arriva?": {
|
||||
"file": "andrea-c6670ffb48.mp3",
|
||||
@@ -2443,9 +2595,9 @@
|
||||
"file": "andrea-fe39c8f30c.mp3",
|
||||
"sec": 1.49
|
||||
},
|
||||
"andrea|Ci si vede, Bertovo.": {
|
||||
"file": "andrea-a3364fd72b.mp3",
|
||||
"sec": 1.78
|
||||
"andrea|Ci si vede, Fabri.": {
|
||||
"file": "andrea-d48ea04521.mp3",
|
||||
"sec": 1.37
|
||||
},
|
||||
"bertovo|Da solo? Io gioco contro le sponde. E vinco quasi sempre.": {
|
||||
"file": "bertovo-5e771069ff.mp3",
|
||||
@@ -2775,6 +2927,34 @@
|
||||
"file": "bertovo-ca941bee91.mp3",
|
||||
"sec": 5.41
|
||||
},
|
||||
"andrea|Tutti sul muro, verdi in fila. Lo stucco di Pierino un tradisce mai.": {
|
||||
"file": "andrea-585cd65f93.mp3",
|
||||
"sec": 5.2
|
||||
},
|
||||
"andrea|Finito lo stucco. Domani si ripassa da Pierino.": {
|
||||
"file": "andrea-62c5d74b82.mp3",
|
||||
"sec": 3.29
|
||||
},
|
||||
"andrea|Il muro resta lì. E l'odore dello stucco, sulle dita, pure.": {
|
||||
"file": "andrea-c7dcb11e66.mp3",
|
||||
"sec": 5.52
|
||||
},
|
||||
"chiaru|Hai vinto te. Ma la mia aveva le ruote piene di gesso, sia chiaro.": {
|
||||
"file": "chiaru-91a4b23b22.mp3",
|
||||
"sec": 4.44
|
||||
},
|
||||
"chiaru|Visto? La blu non perde mai. Mai.": {
|
||||
"file": "chiaru-f8afa97da1.mp3",
|
||||
"sec": 4.95
|
||||
},
|
||||
"chiaru|Ti ritiri? Allora la vinco a tavolino.": {
|
||||
"file": "chiaru-3e949c1519.mp3",
|
||||
"sec": 4.06
|
||||
},
|
||||
"chiaru|Pari. Si rifà, ma la pista la ridisegno io.": {
|
||||
"file": "chiaru-91c549bb83.mp3",
|
||||
"sec": 3.39
|
||||
},
|
||||
"andrea|Laggiù, appoggiato al muro, c'è un angolo di tela dipinta: una strada bianca, e un omino con la maglia rossa e le braccia alzate.": {
|
||||
"file": "andrea-6484641c58.mp3",
|
||||
"sec": 8.67
|
||||
|
||||
@@ -166,3 +166,12 @@ spinte a turno e la macchinina doveva restare in pista: tutta fuori, si torna da
|
||||
Tozzino. Le macchinine: Micro Machines, le Formula 1 degli anni 80/90 con gli alettoni e i loro colori (senza marchi
|
||||
né nomi veri). Proposta: vista dall'alto sull'asfalto, mira e spinta come al biliardo (riusarne la fisica), a turno,
|
||||
vince chi taglia per primo il traguardo. Il quadro della pista e le macchinine da Codex (crediti finiti il 28: domani).
|
||||
|
||||
## Il libro di Fabrizio Berti: le cartoline dei vecchi posti (idea di Fabrizio Berti, 29 ottobre)
|
||||
|
||||
Fabrizio Berti (Bertovo nel gioco) ha scritto «Memorie di sport e di paese». Nel gioco il libro diventa un oggetto
|
||||
dell'inventario: aprendolo, a seconda della scena in cui si è, compare la cartolina d'epoca di quel posto (San Piero
|
||||
com'era). Si può riusare il primo piano del libro che c'è già (`libro-chiuso.png` / `libro-aperto.png`, effetto
|
||||
`closeup`). Servono le cartoline **[DA ANDREA]** (dal libro, con il permesso dell'autore) e la scelta di quali scene ne
|
||||
hanno una; dove non c'è, una battuta («Questo posto nel libro non c'è»). Come lo si ottiene: proposta, lo regala
|
||||
Bertovo dopo una sfida ai rinquarti. Fabrizio Berti e il libro sono già nei Ringraziamenti.
|
||||
|
||||
@@ -29,6 +29,12 @@ ne è un'opera derivata. Le foto scattate da Andrea non hanno problemi; quelle p
|
||||
| `polisportiva-*.png`, `ponte-sieve.png`, `area-feste.png`, `via-provinciale.png`, `comune-asilo.png`, `giardini-poste.png`, `stazione.png` | Codex | foto omonime in `assets/raw/foto/` | Andrea (EXIF, 23 ottobre 2026) | sì |
|
||||
| `via-del-pignone.png` | Codex | `via-del-pignone.png` (murale: `riferimenti/cistola.png`, `murale-maradona.png`) | Andrea | sì (Cistola consenziente) |
|
||||
| `provinciale-pignone.png`, `piazzetta-cambray-digny.png`, `via-cipriani.png`, `via-massorondinaio.png`, `mozzete.png`, `ponticino-mozzete.png`, `coldaia.png`, `falegnameria-coldaia.png`, `gabbiano.png` | Codex | screenshot di Google Street View | Google | **no**: da rifare con foto di Andrea |
|
||||
| `closeups/micro-parcheggio.png`, `closeups/micro/*.png` (macchinine) | Codex, solo testo | nessuna | — | sì |
|
||||
| `characters/chiaru.png` | Codex | `foto/chiaru.jpg` | Andrea (29 ottobre) | sì (il Chiaru consenziente) |
|
||||
| `via-liguri-magelli-muro.png` | Codex, ritocco di `via-liguri-magelli.png` con la Ghiacciomobile nel muro | come `via-liguri-magelli.png` | Street View | **no**: come lo sfondo da cui viene |
|
||||
| `characters/zio_mario.png` | Codex | `foto/zio-mario.png` | Andrea (29 ottobre) | sì (famiglia di Andrea) |
|
||||
| `terrazza-cardetole.png` | Codex (dalla foto, poi il terrazzo davanti) | `cardetole-finestra.jpg` | Andrea (29 ottobre) | **da decidere**: come `cardetole.png`, dice dove abita Andrea |
|
||||
| `closeups/muro-cerbottana.png` | Codex, solo testo (stile dalla piazza) | nessuna | — | sì |
|
||||
| `cardetole.png` | Codex | `cardetole.jpg` | Andrea (EXIF) | **da decidere**: è la casa vera di Andrea, pubblicarla dice dove abita |
|
||||
| `pieve-interno.png` | Codex | `pieve-interno.png` | Mariano Mirannalti (mandata ad Andrea su WhatsApp) | sì, se Mariano è d'accordo; citarlo nei crediti |
|
||||
| `panorama-intro.png` | Codex | `altre/panorama-intro.png` | da internet (screenshot con l'icona di Google Lens) | **no**, finché non si sostituisce |
|
||||
|
||||
@@ -18,6 +18,43 @@ Online su 50037.manzolo.it tutto fino agli effetti ambientali di Codex. Aperto,
|
||||
|
||||
## Dove siamo arrivati
|
||||
|
||||
- **La cerbottana (29 ottobre)**: in piazza, la bottega di Pierin di Frilli sotto la tenda rossa; si compra lo stucco
|
||||
verde e si tira al muro della piazza (`muro-cerbottana.png`, Codex). Motore `cerbottana.js`, disegno
|
||||
`cerbottana-render.js`: si mira, si tiene premuto per il fiato (giusto al 70%: poco cade sotto, troppo va sopra), il
|
||||
mirino ondeggia col respiro, troppo a fiato pieno si tossisce. Bersaglio di gesso (10/5/2), lattine sul muretto
|
||||
(3), barattolo appeso (8, seria e a fassi male); 12 pallini, servono 30/40/50 punti; i pallini restano sul muro.
|
||||
Test in `cerbottana.test.mjs` e `npm run browser:cerbottana`. [DA ANDREA] le battute, com'era la bottega, se far
|
||||
comparire Pierino (è scomparso da anni: decide Andrea).
|
||||
- **Il terrazzo di casa a Cardetole (29 ottobre)**: dalla foto di Andrea dalla finestra (il paese che sale e lassù
|
||||
la Fortezza), Codex l'ha dipinta e ci ha messo davanti il terrazzo (`terrazza-cardetole.png`). Ci si sale da
|
||||
«casa di Andrea» a Cardetole; la battuta dell'apparecchiare ora è sulla porta-finestra. Battute provvisorie
|
||||
[DA ANDREA]. Come Cardetole, dice dove abita Andrea: da decidere prima di Pages.
|
||||
- **La Ghiacciomobile nel muro (29 ottobre)**: non è più al circolino di Campomigliaio. In Via Liguri Magelli, prima
|
||||
del tramonto (`!indizio_regolo`), è schiantata dentro il muro giallo coi mattoni rotti e senza targa
|
||||
(`via-liguri-magelli-muro.png`, ritocco di Codex); dal tramonto il muro è rifatto e c'è la targa. Il motore ha le
|
||||
varianti di sfondo per scena (`backdrops`, con `when`; `game.backdrop()`). Lo zio Mario (sprite di Codex dalla
|
||||
foto di Andrea) davanti alla macchina che si gratta la testa; scala della scena rifatta (le persone erano troppo
|
||||
piccole). [DA ANDREA] le battute dello zio (scherzava su tutto, anche sulla morte) e quella dello schianto.
|
||||
- **GP di Fortezza, guida semplice (29 ottobre)**: alla bona e Seria si tiene premuto per il gas e lasciando si
|
||||
frena; lo sterzo segue la strada da solo (scansa le buche, sorpassa, prende la miscela), ma oltre la velocità che la
|
||||
curva regge il motorino scivola fuori verso la paglia (`SIMPLE` in `gara.js`). Ginocchio in terra resta con lo
|
||||
sterzo vero. Il pannello nasconde Sterza, Frena, swipe e sensibilità. Test in `gara.test.mjs` e
|
||||
`npm run browser:gara`. Seria più difficile (parere di Codex, simulato): sopra il 110% del limite in curva si esce
|
||||
di sicuro (stun 1,2 s), la curva pulita dà una spinta, rivali a 0,81; CURVA! (preavviso) e LASCIA! sul motorino.
|
||||
In simulazione: chi frena giusto 1° in 46 s, tutto gas 4°-5° in 55-59 s.
|
||||
- **La pista col gesso (29 ottobre, modifiche locali)**: le Micro Machines sul parcheggio di Cardetole contro il
|
||||
Chiaru (Matteo Chiarusi, sprite di Codex dalla foto di Andrea, accanto alla pista). Motore in `micro.js`, disegno in
|
||||
`micro-render.js`: pista disegnata a gesso dal codice sopra l'asfalto di Codex (`micro-parcheggio.png`), un giro,
|
||||
una spinta a testa (mira e carica come al biliardo), le macchinine di Codex (`assets/closeups/micro/`). Penalità
|
||||
alla francese, per tutte si torna dov'eri: fuori, tagliè (curva presa dalla parte di dentro o erba saltata),
|
||||
cappottè (urto forte), accompagnè (dito tenuto oltre la carica piena). Tre livelli: alla bona la guida mostra dove
|
||||
ci si ferma. Test in `tests/micro.test.mjs` e nel browser (`npm run browser:micro`). Battute del Chiaru provvisorie
|
||||
[DA ANDREA]; il Chiaru ha dato il consenso (29 ottobre).
|
||||
Poi: si sceglie la macchinina (sei, il Chiaru tiene la blu), la forza parte da zero appena si preme e la spinta
|
||||
parte quando si lascia; saluto «Vado a fare un girino alle case rosse» / «Vorrai dire un giochino!» / «Ciao Mattè»;
|
||||
Andrea chiama Bertovo «Fabri». Musica sua: `assets/audio/macchinine.mp3` (Andrea con Suno).
|
||||
- **Bertovo ora si chiama «Trappizzio Berti»** in tutte le scritte (Andrea, 29 ottobre); l'id resta `bertovo`.
|
||||
Fabrizio Berti e il suo libro «Memorie di sport e di paese» nei Ringraziamenti; l'idea delle cartoline in `IDEE.md`.
|
||||
- **I rinquarti di Bertovo (28 ottobre, modifiche locali)**: variante del biliardo in `rinquarto.js` e
|
||||
`rinquarto-render.js`, con fisica, mira, carica e suoni del biliardo. Sei posizioni riproducibili dal seme,
|
||||
diretto coperto da una biglia e almeno una soluzione di sponda verificata con `simulate` per ciascuna.
|
||||
@@ -306,6 +343,7 @@ I prompt fissi (stile, scene, foglio sprite) sono in `prompts/STILE.md`, escluso
|
||||
6. Il nonno: confermare il nome (Settimo Villani) e decidere come usare la sua leggenda nel finale.
|
||||
7. Il Lele: come e quanto farlo comparire (con calma).
|
||||
8. Battute e modi di dire del paese.
|
||||
9. ~~Consenso del Chiaru~~ Dato il 29 ottobre. Le sue battute vanno bene?
|
||||
|
||||
### Grafica
|
||||
- Sfondi puliti 16:9 di Pieve, Cardetole, Campomigliaio, interno della Fortezza (sotterranei).
|
||||
|
||||
@@ -225,7 +225,13 @@
|
||||
guida mostra la parabola fino al primo urto, Seria solo l’inizio, A fassi male niente.</p>
|
||||
</details>
|
||||
<details id="gara-help" hidden><summary>Come si gioca</summary>
|
||||
<p>Il GP di Fortezza: tre giri attorno alle mura coi cinquantini. Con un solo dito: tieni premuto sulla scena per
|
||||
<p>Il GP di Fortezza: tre giri attorno alle mura coi cinquantini. <b>Alla bona e Seria</b> la guida è semplice:
|
||||
tieni premuto sulla scena (o Spazio, o il pulsante Gas) per accelerare e lascia per frenare; lo sterzo segue la
|
||||
strada da solo, scansa le buche e sorpassa. Ma se entri in curva troppo forte scivoli fuori, e nella paglia ti
|
||||
fermi: molla prima delle curve. Sopra il motorino «CURVA!» avvisa che ne arriva una, «LASCIA!» dice quando
|
||||
mollare. A Seria chi entra in curva troppo forte va fuori di sicuro, e chi la prende giusta fa la «curva pulita»
|
||||
ed esce con una spinta in più.</p>
|
||||
<p><b>Ginocchio in terra</b> si guida davvero. Con un solo dito: tieni premuto sulla scena per
|
||||
il gas e trascina verso la direzione in cui vuoi andare sullo schermo. A destra vai verso destra, anche quando
|
||||
il motorino scende. I piccoli movimenti non sterzano; il cerchietto segue gli swipe lunghi. Alza il dito per
|
||||
mollare il gas e raddrizzare lo sterzo. Funziona anche col mouse premuto.</p>
|
||||
@@ -249,14 +255,35 @@
|
||||
il pulsante alterna Recupera e Molla. Sei lanci. La gloria: 2 pesci alla bona, 3 seria, 4 a fassi male (lo stivale
|
||||
non conta, e non pesa). Frecce ← →: distanza del lancio; Esc esce.</p>
|
||||
</details>
|
||||
<details id="cerbottana-help" hidden><summary>Come si gioca</summary>
|
||||
<p>La cerbottana, con lo stucco verde di Pierin di Frilli: dodici pallini contro il muro della piazza. Il bersaglio
|
||||
di gesso vale 10, 5 o 2 punti secondo il cerchio, ogni lattina sul muretto 3, il barattolo appeso che dondola (Seria
|
||||
e A fassi male) 8. Servono 30 punti alla bona, 40 Seria, 50 A fassi male. I pallini restano attaccati al muro.</p>
|
||||
<p>Muovi il mouse o tocca il muro per mirare: il mirino ondeggia col respiro (di più salendo di livello). Tieni
|
||||
premuto per prendere fiato e lascia per sparare: col fiato giusto il pallino va dove punti, con poco cade sotto,
|
||||
con troppo va sopra. Alla bona la barra del fiato segna il punto giusto. Se resti troppo a fiato pieno tossisci, e
|
||||
il pallino è perso. Si può anche regolare il fiato col cursore e premere Spara. Frecce per spostare il mirino.</p>
|
||||
</details>
|
||||
<details id="micro-help" hidden><summary>Come si gioca</summary>
|
||||
<p>La pista col gesso sul parcheggio di Cardetole: un giro contro il Chiaru, una spinta a testa (prima tu, poi
|
||||
lui). La tua macchinina è la rossa. Vince chi taglia per primo il traguardo a scacchi; se ci arrivate tutti e due
|
||||
nello stesso giro di spinte, vince chi è andato più in là.</p>
|
||||
<p>Se durante la corsa la macchinina esce <b>tutta</b> dal gesso, torna dov'era prima della spinta: vale anche se
|
||||
ce la manda l'altra urtandola, e vale per i tornanti, dove non si salta dall'altra parte. Alla bona vedi dove si
|
||||
ferma la spinta (verde dentro, rossa fuori), Seria solo la direzione, A fassi male una freccina. Il Chiaru è più
|
||||
preciso a ogni livello.</p>
|
||||
<p>Muovi il mouse o tocca il parcheggio per mirare: un tocco fissa solo la mira. Per spingere tieni premuto (o
|
||||
Spazio) finché il dito si carica e lascia, oppure regola la forza e premi Spingi. Frecce ← → o i pulsanti Mira
|
||||
girano la mira (Maiusc per i passi fini); Esc esce.</p>
|
||||
</details>
|
||||
<details id="rinquarto-help" hidden><summary>Come si gioca</summary>
|
||||
<p>I rinquarti di Bertovo: sei posizioni. Su ognuna tiri prima tu, poi il tavolo torna com'era e tira Bertovo; un
|
||||
<p>I rinquarti di Trappizzio Berti: sei posizioni. Su ognuna tiri prima tu, poi il tavolo torna com'era e tira Trappizzio Berti; un
|
||||
punto per ogni rinquarto riuscito, vince chi ne fa di più (si può anche pareggiare). La tua biglia è la bianca, il
|
||||
bersaglio la gialla con l'anello. Le biglie viola con la croce e i birilli sono disturbi: toccarne uno prima del
|
||||
bersaglio annulla il tiro. La diretta è sempre coperta, ma c'è sempre un rinquarto possibile.</p>
|
||||
<p>Punto se la bianca tocca la gialla dopo almeno le sponde richieste: conta il primo contatto. Alla bona una
|
||||
sponda e la guida fino al secondo rimbalzo, Seria due sponde e la guida corta, A fassi male tre sponde e niente
|
||||
guida. Le posizioni si fanno più strette man mano, e Bertovo è più preciso a ogni livello. La forza è sempre piena:
|
||||
guida. Le posizioni si fanno più strette man mano, e Trappizzio Berti è più preciso a ogni livello. La forza è sempre piena:
|
||||
è un rompicapo di angoli. Nell'allenamento («Fammi vedere un rinquarto») tira prima lui, poi lo rifai tu.</p>
|
||||
<p>Muovi il mouse o tocca il tavolo per mirare: un tocco fissa solo la mira. Per tirare premi Tira, oppure tieni
|
||||
premuto sul tavolo (o Spazio) finché la stecca si carica e lascia. Frecce ← → o i pulsanti Mira (tenuti
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"name": "leggenda-del-regolo",
|
||||
"version": "0.1.36",
|
||||
"version": "0.1.47",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "node --test tests/*.test.mjs",
|
||||
"browser": "node tests/browser.mjs",
|
||||
"browser:biliardo": "node tests/biliardo.browser.mjs",
|
||||
"browser:micro": "node tests/micro.browser.mjs",
|
||||
"browser:gara": "node tests/gara.browser.mjs",
|
||||
"browser:cerbottana": "node tests/cerbottana.browser.mjs",
|
||||
"browser:tressette": "node tests/tressette.browser.mjs",
|
||||
"browser:scopa": "node tests/scopa.browser.mjs",
|
||||
"browser:briscola": "node tests/briscola.browser.mjs",
|
||||
|
||||
@@ -30,7 +30,10 @@ export function castle() {
|
||||
}
|
||||
|
||||
export const powerAt = time => clamp(time / SWING, 0, 1);
|
||||
export const speedFor = power => MIN_SPEED + (MAX_SPEED - MIN_SPEED) * power;
|
||||
// Il tiro più forte: al biliardo dell'Ing. Tozzi si arriva a STRONG (Andrea, 29 ottobre: «più potenza»); i rinquarti
|
||||
// restano a MAX_SPEED, perché le loro posizioni sono misurate a quella forza.
|
||||
export const STRONG = 720;
|
||||
export const speedFor = (power, max = MAX_SPEED) => MIN_SPEED + (max - MIN_SPEED) * power;
|
||||
// Quanta strada fa una biglia lanciata a velocità v, senza urti (attrito costante più un po' di resistenza).
|
||||
export function reach(v) {
|
||||
const k = FRICTION / DRAG, t = Math.log((v + k) / k) / DRAG;
|
||||
@@ -48,7 +51,7 @@ export const LEVELS = {
|
||||
};
|
||||
export function newBiliardo(seed = Date.now() >>> 0, def = {}) {
|
||||
const level = LEVELS[def.level] ? def.level : 'seria';
|
||||
const c = { step: 'aim', t: 0, seed, level, skill: LEVELS[level], current: 'player', target: def.target ?? TARGET, power: 0.45, angle: 0,
|
||||
const c = { step: 'aim', t: 0, seed, level, skill: LEVELS[level], current: 'player', target: def.target ?? TARGET, maxSpeed: def.maxSpeed ?? STRONG, power: 0.45, angle: 0,
|
||||
holding: false, holdTime: 0, accumulator: 0, events: [], points: { player: 0, cpu: 0 }, last: null, shot: null, plan: null };
|
||||
c.balls = { player: ball('player', LEN * 0.18, WID * 0.5), cpu: ball('cpu', LEN * 0.81, WID * 0.25), pallino: ball('pallino', LEN * 0.88, WID * 0.7) };
|
||||
c.pins = castle();
|
||||
@@ -171,7 +174,7 @@ function step(w, dt) {
|
||||
|
||||
export function strike(c, who, angle, power) {
|
||||
c.turn = null;
|
||||
const b = c.balls[who], v = speedFor(power);
|
||||
const b = c.balls[who], v = speedFor(power, c.maxSpeed);
|
||||
c.visual.shot = { at: c.visual.time, angle, power, x: b.x, y: b.y };
|
||||
c.pending = { ball: b, vx: Math.cos(angle) * v, vy: Math.sin(angle) * v, power };
|
||||
c.windup = WINDUP;
|
||||
@@ -183,7 +186,7 @@ export function strike(c, who, angle, power) {
|
||||
export function simulate(c, who, angle, power, { onContact, stop } = {}) {
|
||||
const balls = list(c).map(b => ({ ...b })), pins = c.pins.map(p => ({ ...p }));
|
||||
const w = { balls, pins, onContact, shot: { shooter: who, first: null, pallino: false, pins: [] } };
|
||||
const b = balls.find(x => x.role === who), v = speedFor(power);
|
||||
const b = balls.find(x => x.role === who), v = speedFor(power, c.maxSpeed);
|
||||
b.vx = Math.cos(angle) * v; b.vy = Math.sin(angle) * v;
|
||||
for (let i = 0; i < 15 / FIXED_STEP && !stop?.() && balls.some(x => x.vx || x.vy); i++) step(w, FIXED_STEP);
|
||||
return judge(w.shot);
|
||||
@@ -343,7 +346,7 @@ export function predict(c) {
|
||||
const cached = predictions.get(c);
|
||||
if (cached?.key === key) return cached.result;
|
||||
const balls = list(c).map(b => ({ ...b })), me = balls.find(b => b.role === c.current);
|
||||
const v = speedFor(c.power);
|
||||
const v = speedFor(c.power, c.maxSpeed);
|
||||
me.vx = Math.cos(c.angle) * v; me.vy = Math.sin(c.angle) * v;
|
||||
const result = { points: [[me.x, me.y]], ghost: null, hit: null, dir: null, outgoing: [] };
|
||||
const tracks = [];
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { TARGET, CAN, SWINGER, LEDGE, PELLETS, FLIGHT, BEST, rings, reticle, swinger, canThrow, overHeld } from './cerbottana.js';
|
||||
import { text, panel } from './bocce-render.js';
|
||||
|
||||
// Il gesso sul muro: tre cerchi un po' storti (sempre gli stessi) e i numeri dei punti, in alto, ognuno nel suo anello.
|
||||
function chalkTarget(ctx, c) {
|
||||
let inner = 0;
|
||||
for (const [r, p] of rings(c)) {
|
||||
ctx.strokeStyle = 'rgba(250,248,236,0.85)'; ctx.lineWidth = 1.5; ctx.beginPath();
|
||||
for (let k = 0; k <= 48; k++) {
|
||||
const a = k / 48 * Math.PI * 2, j = 0.6 * Math.sin(k * 2.3 + r);
|
||||
const x = TARGET.x + Math.cos(a) * (r + j), y = TARGET.y + Math.sin(a) * (r + j);
|
||||
if (k) ctx.lineTo(x, y); else ctx.moveTo(x, y);
|
||||
}
|
||||
ctx.stroke();
|
||||
if (inner) text(ctx, String(p), TARGET.x, TARGET.y - (inner + r) / 2, 6, 'rgba(250,248,236,0.8)', 'center');
|
||||
inner = r;
|
||||
}
|
||||
ctx.fillStyle = 'rgba(250,248,236,0.9)'; ctx.fillRect(TARGET.x - 1, TARGET.y - 1, 2, 2);
|
||||
}
|
||||
// Una lattina: rossa con la fascia chiara, i bordi d'alluminio.
|
||||
function can(ctx, x, y, angle = 0, color = '#c8321e') {
|
||||
ctx.save(); ctx.translate(Math.round(x), Math.round(y)); ctx.rotate(angle);
|
||||
ctx.fillStyle = 'rgba(20,16,10,0.35)'; ctx.fillRect(-CAN.w / 2 + 2, -1, CAN.w, 2);
|
||||
ctx.fillStyle = color; ctx.fillRect(-CAN.w / 2, -CAN.h, CAN.w, CAN.h);
|
||||
ctx.fillStyle = '#f2e6c8'; ctx.fillRect(-CAN.w / 2, -CAN.h + 6, CAN.w, 4);
|
||||
ctx.fillStyle = '#c9cdd2'; ctx.fillRect(-CAN.w / 2, -CAN.h, CAN.w, 2); ctx.fillRect(-CAN.w / 2, -2, CAN.w, 2);
|
||||
ctx.fillStyle = 'rgba(255,255,255,0.35)'; ctx.fillRect(-CAN.w / 2 + 2, -CAN.h + 2, 1, CAN.h - 4);
|
||||
ctx.restore();
|
||||
}
|
||||
// Un pallino di stucco: verdastro, un po' schiacciato sul muro.
|
||||
function pellet(ctx, x, y, r = 2.5) {
|
||||
ctx.fillStyle = '#2b3a1c'; ctx.beginPath(); ctx.arc(x, y, r + 0.8, 0, Math.PI * 2); ctx.fill();
|
||||
ctx.fillStyle = '#8fa05a'; ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2); ctx.fill();
|
||||
ctx.fillStyle = '#c3cf8e'; ctx.fillRect(Math.round(x - r / 2), Math.round(y - r / 2), 1, 1);
|
||||
}
|
||||
// La cerbottana in basso, in prospettiva: grossa vicino alla bocca, più fine in punta, girata verso il mirino, col
|
||||
// pallino di stucco in punta.
|
||||
function blowpipe(ctx, c, to) {
|
||||
const from = { x: 320, y: 376 }, a = Math.atan2(to.y - from.y, to.x - from.x), len = 64;
|
||||
const tip = { x: from.x + Math.cos(a) * len, y: from.y + Math.sin(a) * len }, nx = -Math.sin(a), ny = Math.cos(a);
|
||||
const tube = (w0, w1, color) => {
|
||||
ctx.fillStyle = color; ctx.beginPath();
|
||||
ctx.moveTo(from.x + nx * w0, from.y + ny * w0); ctx.lineTo(tip.x + nx * w1, tip.y + ny * w1);
|
||||
ctx.lineTo(tip.x - nx * w1, tip.y - ny * w1); ctx.lineTo(from.x - nx * w0, from.y - ny * w0); ctx.fill();
|
||||
};
|
||||
tube(9, 4, '#2a2018'); tube(7, 3, '#6b5236');
|
||||
ctx.fillStyle = '#8a6a44'; ctx.fillRect(Math.round(tip.x - 1), Math.round(tip.y - 1), 2, 2);
|
||||
if (canThrow(c)) pellet(ctx, tip.x, tip.y - 1, 3.5);
|
||||
}
|
||||
|
||||
export function drawCerbottana(ctx, c, def, bg) {
|
||||
ctx.save(); ctx.imageSmoothingEnabled = false;
|
||||
if (bg) ctx.drawImage(bg, 0, 0, 640, 360); else { ctx.fillStyle = '#d9a640'; ctx.fillRect(0, 0, 640, 360); }
|
||||
chalkTarget(ctx, c);
|
||||
for (const p of c.stuck) pellet(ctx, p.x, p.y);
|
||||
// Le lattine sul muretto; colpite, cadono all'indietro.
|
||||
for (const k of c.cans) { if (k.fall < 1) can(ctx, k.x, LEDGE + k.fall * 6, -k.fall * 1.4); }
|
||||
if (c.skill.swinger) {
|
||||
const s = swinger(c);
|
||||
ctx.strokeStyle = '#3a3024'; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(SWINGER.x, SWINGER.y); ctx.lineTo(s.x, s.y); ctx.stroke();
|
||||
can(ctx, s.x, s.y + SWINGER.h, s.a + c.swing.spin * Math.sin(c.visual.time * 30) * 0.6, '#2f6fb0');
|
||||
}
|
||||
// Il pallino in volo: parte grande dalla cerbottana e rimpicciolisce andando verso il muro.
|
||||
if (c.shot) {
|
||||
const k = Math.min(1, c.shot.t / FLIGHT), { from, to } = c.shot;
|
||||
pellet(ctx, from.x + (to.x - from.x) * k, from.y + (to.y - from.y) * k - Math.sin(k * Math.PI) * 18, 6 - 3.5 * k);
|
||||
}
|
||||
const r = reticle(c);
|
||||
if (canThrow(c)) {
|
||||
const over = overHeld(c);
|
||||
ctx.strokeStyle = over ? '#ff6a4a' : '#fff8dc'; ctx.lineWidth = 1;
|
||||
ctx.beginPath(); ctx.arc(r.x, r.y, 7, 0, Math.PI * 2); ctx.stroke();
|
||||
ctx.beginPath(); ctx.moveTo(r.x - 11, r.y); ctx.lineTo(r.x - 3, r.y); ctx.moveTo(r.x + 3, r.y); ctx.lineTo(r.x + 11, r.y);
|
||||
ctx.moveTo(r.x, r.y - 11); ctx.lineTo(r.x, r.y - 3); ctx.moveTo(r.x, r.y + 3); ctx.lineTo(r.x, r.y + 11); ctx.stroke();
|
||||
}
|
||||
blowpipe(ctx, c, r);
|
||||
// Il fiato: una barra in basso a sinistra (alla bona col punto giusto segnato).
|
||||
if (canThrow(c)) {
|
||||
const x = 16, y = 300, h = 50;
|
||||
ctx.fillStyle = '#17160fd0'; ctx.fillRect(x - 3, y - 3, 18, h + 6);
|
||||
ctx.fillStyle = overHeld(c) ? '#ff6a4a' : c.power > BEST + 0.08 ? '#ffd23c' : '#9be07c';
|
||||
const f = Math.round(h * c.power); ctx.fillRect(x, y + h - f, 12, f);
|
||||
if (c.skill.sweet) { ctx.fillStyle = '#fff8dc'; ctx.fillRect(x - 3, Math.round(y + h - h * BEST) - 1, 18, 2); }
|
||||
text(ctx, 'FIATO', x + 6, y - 9, 6, '#efd49e', 'center');
|
||||
}
|
||||
// In alto: punti, pallini rimasti e cosa è successo.
|
||||
ctx.fillStyle = '#17160fe8'; ctx.fillRect(0, 0, 640, 22);
|
||||
text(ctx, 'LA CERBOTTANA', 8, 7, 8, '#efd49e');
|
||||
text(ctx, { bona: 'alla bona', seria: 'seria', male: 'a fassi male' }[c.level], 8, 16, 7, '#d9ccba');
|
||||
text(ctx, `Punti ${c.points} / ${c.skill.goal}`, 260, 11, 9, c.points >= c.skill.goal ? '#b9e5b3' : '#fff0c8', 'center');
|
||||
for (let i = 0; i < PELLETS; i++) pellet(ctx, 430 + i * 15, 11, i < c.left ? 3 : 1.2);
|
||||
const line = overHeld(c) ? 'Lascia, sennò tossisci!' : c.line;
|
||||
if (line) { ctx.fillStyle = '#17160fd0'; ctx.fillRect(170, 24, 300, 14); text(ctx, line, 320, 31, 8, overHeld(c) || /corto|alto|Coff/.test(line) ? '#ffbf9f' : '#9fd0ff', 'center'); }
|
||||
if (c.step === 'result') {
|
||||
const won = c.result.winner === 'player';
|
||||
panel(ctx, 170, 140, 300, 76);
|
||||
text(ctx, won ? 'CENTRATO!' : 'LO STUCCO È FINITO', 320, 160, 12, won ? '#b9e5b3' : '#efd49e', 'center');
|
||||
text(ctx, `${c.result.points} punti, ne servivano ${c.result.goal}`, 320, 182, 8, '#efd49e', 'center');
|
||||
text(ctx, 'Torna in piazza per uscire.', 320, 200, 8, '#d9ccba', 'center');
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
// La cerbottana (idea di Andrea, 29 ottobre): da ragazzi in piazza si comprava da Pierin di Frilli lo stucco verde,
|
||||
// dall'odore inconfondibile, lo si metteva intorno alla cerbottana, si facevano i pallini e si «sparava» al muro.
|
||||
// Qui: un muro della piazza visto di fronte, un bersaglio fatto col gesso, le lattine sul muretto e (a seria e a fassi
|
||||
// male) un barattolo appeso che dondola. Si mira, si tiene premuto per prendere fiato e si lascia: con poco fiato il
|
||||
// pallino cade sotto, con troppo va sopra; il mirino ondeggia col respiro, e chi resta troppo a fiato pieno tossisce.
|
||||
// I pallini di stucco restano attaccati al muro. Unità: i pixel del primo piano 640×360.
|
||||
|
||||
export const WALL_BOTTOM = 244; // sotto comincia il muretto: lì il pallino non attacca
|
||||
export const LEDGE = 244; // dove poggiano le lattine
|
||||
export const PELLETS = 12, SWING = 1, TAP = 0.14, COUGH = 0.6, FLIGHT = 0.3, REST = 0.5, BEST = 0.7, DROP = 300;
|
||||
export const TARGET = { x: 320, y: 118, rings: [[8, 10], [18, 5], [30, 2]] };
|
||||
export const CAN = { w: 10, h: 16, points: 3 }, SWINGER = { x: 470, y: 8, length: 92, w: 12, h: 16, points: 8 };
|
||||
// I livelli: quanto ondeggia il mirino (px), quanti punti servono, se c'è il barattolo appeso, se la barra del fiato
|
||||
// mostra il punto giusto, e quanto sono grandi i cerchi del bersaglio.
|
||||
export const LEVELS = {
|
||||
bona: { sway: 3, goal: 30, swinger: false, sweet: true, rings: 1.3 },
|
||||
seria: { sway: 6, goal: 40, swinger: true, sweet: false, rings: 1 },
|
||||
male: { sway: 10, goal: 50, swinger: true, sweet: false, rings: 0.85 },
|
||||
};
|
||||
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
||||
function random(c) { c.seed = (Math.imul(c.seed, 1664525) + 1013904223) >>> 0; return c.seed / 4294967296; }
|
||||
|
||||
export function newCerbottana(seed = Date.now() >>> 0, def = {}) {
|
||||
const level = LEVELS[def.level] ? def.level : 'seria';
|
||||
return { step: 'aim', t: 0, seed, level, skill: LEVELS[level], aim: { x: TARGET.x, y: TARGET.y }, power: BEST,
|
||||
holding: false, holdTime: 0, charging: false, left: PELLETS, points: 0, events: [], shot: null, stuck: [], line: null,
|
||||
cans: [200, 250, 390, 440].map(x => ({ x, down: false, fall: 0 })), swing: { hits: 0, spin: 0 }, visual: { time: 0 } };
|
||||
}
|
||||
export const canThrow = c => c.step === 'aim' && c.left > 0;
|
||||
export const canAdjust = canThrow;
|
||||
export const powerAt = time => clamp(time / SWING, 0, 1);
|
||||
export const rings = c => TARGET.rings.map(([r, p]) => [r * c.skill.rings, p]);
|
||||
|
||||
// Il respiro: il mirino gira piano intorno al punto voluto (due onde, non si ripete subito); trattenendo il fiato pieno
|
||||
// trema di più.
|
||||
export function sway(c) {
|
||||
const t = c.visual.time, a = c.skill.sway * (1 + (c.overHold ?? 0) * 2);
|
||||
return { x: a * (Math.sin(t * 1.7) + 0.5 * Math.sin(t * 3.1 + 1)), y: a * 0.8 * (Math.sin(t * 1.3 + 2) + 0.5 * Math.sin(t * 2.9)) };
|
||||
}
|
||||
export function reticle(c) { const s = sway(c); return { x: c.aim.x + s.x, y: c.aim.y + s.y }; }
|
||||
// Dove arriva il pallino: dove punta il mirino, più su o più giù secondo il fiato (BEST è il fiato giusto).
|
||||
export const landing = (c, power = c.power) => { const r = reticle(c); return { x: r.x, y: r.y + (BEST - power) * DROP }; };
|
||||
// Il barattolo appeso: un pendolo che dondola sotto la gronda (e gira su sé stesso se colpito).
|
||||
export function swinger(c) {
|
||||
const a = 0.5 * Math.sin(c.visual.time * 1.6);
|
||||
return { x: SWINGER.x + Math.sin(a) * SWINGER.length, y: SWINGER.y + Math.cos(a) * SWINGER.length, a };
|
||||
}
|
||||
|
||||
export function shoot(c) {
|
||||
if (!canThrow(c) || c.holding) return false;
|
||||
return fire(c, c.power);
|
||||
}
|
||||
function fire(c, power, cough = false) {
|
||||
const from = { x: 320, y: 380 }, to = cough ? { x: 300 + random(c) * 40, y: 330 } : landing(c, power);
|
||||
c.left--; c.power = power;
|
||||
c.shot = { from, to, t: 0, cough };
|
||||
c.step = 'flying'; c.line = null;
|
||||
c.events.push({ kind: cough ? 'cerbottana-tosse' : 'cerbottana-pff', power });
|
||||
return true;
|
||||
}
|
||||
// Arrivato: prima il barattolo appeso, poi le lattine, poi il bersaglio; sul muro il pallino resta attaccato.
|
||||
function land(c) {
|
||||
const { x, y } = c.shot.to;
|
||||
let got = 0, what = null;
|
||||
if (c.shot.cough) what = 'Coff! Il pallino è finito per terra.';
|
||||
if (!what && c.skill.swinger) {
|
||||
const s = swinger(c);
|
||||
if (Math.abs(x - s.x) <= SWINGER.w / 2 + 1 && Math.abs(y - s.y - SWINGER.h / 2) <= SWINGER.h / 2 + 1) {
|
||||
got = SWINGER.points; c.swing.hits++; c.swing.spin = 1; what = `Il barattolo appeso! ${got} punti.`;
|
||||
c.events.push({ kind: 'cerbottana-latta', power: 1 });
|
||||
}
|
||||
}
|
||||
if (!what) {
|
||||
const can = c.cans.find(k => !k.down && Math.abs(x - k.x) <= CAN.w / 2 + 1 && y >= LEDGE - CAN.h - 1 && y <= LEDGE);
|
||||
if (can) { can.down = true; got = CAN.points; what = `Lattina giù! ${got} punti.`; c.events.push({ kind: 'cerbottana-latta', power: 0.8 }); }
|
||||
}
|
||||
if (!what) {
|
||||
if (y < WALL_BOTTOM && y > 4 && x > 4 && x < 636) {
|
||||
c.stuck.push({ x, y });
|
||||
const d = Math.hypot(x - TARGET.x, y - TARGET.y), ring = rings(c).find(([r]) => d <= r);
|
||||
got = ring ? ring[1] : 0;
|
||||
what = got ? `Nel bersaglio: ${got} ${got === 1 ? 'punto' : 'punti'}.` : y < TARGET.y - 40 ? 'Troppo fiato: alto.' : 'Sul muro, fuori dal bersaglio.';
|
||||
c.events.push({ kind: 'cerbottana-muro', power: 0.6 });
|
||||
} else what = 'Poco fiato: il pallino è caduto corto.';
|
||||
}
|
||||
c.points += got; c.line = what;
|
||||
c.shot = null; c.step = 'rest'; c.t = 0;
|
||||
}
|
||||
|
||||
export function update(c, dt) {
|
||||
if (!Number.isFinite(dt) || dt <= 0) return;
|
||||
dt = Math.min(dt, 0.25); c.t += dt; c.visual.time += dt;
|
||||
for (const k of c.cans) if (k.down) k.fall = Math.min(1, k.fall + dt * 3);
|
||||
if (c.swing.spin) c.swing.spin = Math.max(0, c.swing.spin - dt);
|
||||
if (c.holding) {
|
||||
c.holdTime += dt; c.charging = c.holdTime >= TAP;
|
||||
c.power = powerAt(c.holdTime);
|
||||
c.overHold = c.power >= 1 ? (c.overHold ?? 0) + dt : 0;
|
||||
// Troppo a fiato pieno: tosse, e il pallino è perso.
|
||||
if (c.overHold > COUGH) { c.holding = c.charging = false; c.overHold = 0; fire(c, 1, true); }
|
||||
}
|
||||
if (c.step === 'flying') { c.shot.t += dt; if (c.shot.t >= FLIGHT) land(c); }
|
||||
else if (c.step === 'rest' && c.t >= REST) {
|
||||
if (c.left > 0) c.step = 'aim';
|
||||
else { c.step = 'result'; c.result = { winner: c.points >= c.skill.goal ? 'player' : 'cpu', points: c.points, goal: c.skill.goal }; }
|
||||
}
|
||||
}
|
||||
|
||||
// --- Comandi: il mirino segue il mouse o il dito; tenere premuto prende fiato, lasciare spara.
|
||||
export function aimScreen(c, [x, y]) {
|
||||
if (!canThrow(c) || c.holding || !Number.isFinite(x) || !Number.isFinite(y)) return false;
|
||||
c.aim = { x: clamp(x, 10, 630), y: clamp(y, 24, 300) }; return true;
|
||||
}
|
||||
export function nudge(c, dir) { if (!canThrow(c) || c.holding) return false; c.aim.x = clamp(c.aim.x + dir * 4, 10, 630); return true; }
|
||||
export function setPower(c, value) { if (!canThrow(c) || c.holding || !Number.isFinite(value)) return false; c.power = clamp(value, 0, 1); return true; }
|
||||
export function key(c, key, down) {
|
||||
const move = { ArrowLeft: [-4, 0], ArrowRight: [4, 0], ArrowUp: [0, -4], ArrowDown: [0, 4] }[key];
|
||||
if (!move) return false;
|
||||
if (down && canThrow(c) && !c.holding) c.aim = { x: clamp(c.aim.x + move[0], 10, 630), y: clamp(c.aim.y + move[1], 24, 300) };
|
||||
return true;
|
||||
}
|
||||
export function press(c, pointerId) {
|
||||
if (!canThrow(c) || c.holding) return false;
|
||||
c.pointerId = pointerId; c.holding = true; c.charging = false; c.holdTime = 0; c.previousPower = c.power; c.power = 0; c.overHold = 0;
|
||||
return true;
|
||||
}
|
||||
export function cancel(c, pointerId) {
|
||||
if (pointerId !== undefined && c.pointerId !== pointerId) return false;
|
||||
if (!c.holding) return false;
|
||||
c.holding = c.charging = false; c.power = c.previousPower; c.holdTime = 0; c.overHold = 0; return true;
|
||||
}
|
||||
export function release(c, pointerId) {
|
||||
if (c.pointerId !== pointerId || !c.holding) return false;
|
||||
if (c.holdTime < TAP) return cancel(c, pointerId); // il tocco secco mira soltanto
|
||||
c.holding = c.charging = false; c.overHold = 0;
|
||||
return fire(c, c.power);
|
||||
}
|
||||
// Trattenendo il fiato pieno: il disegno avvisa prima della tosse.
|
||||
export const overHeld = c => c.holding && (c.overHold ?? 0) > 0;
|
||||
|
||||
export function button(c) { return c.step === 'result' ? 'Finita' : c.step === 'aim' ? 'Spara' : 'In volo…'; }
|
||||
export function status(c) {
|
||||
const score = `Punti ${c.points} su ${c.skill.goal}, pallini ${c.left} di ${PELLETS}.`;
|
||||
if (c.step === 'result') return `${c.result.winner === 'player' ? 'Fatto! ' : 'Lo stucco è finito. '}${score}`;
|
||||
return `${score} ${c.line ?? 'Mira, tieni premuto per prendere fiato e lascia.'}`;
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import * as briscola from './briscola.js';
|
||||
import * as tressette from './tressette.js';
|
||||
import * as scopa from './scopa.js';
|
||||
import * as gara from './gara.js';
|
||||
import * as micro from './micro.js';
|
||||
import * as cerbottana from './cerbottana.js';
|
||||
|
||||
// I minigiochi in primo piano: comandi opzionali per il tiro o per la scelta di una carta.
|
||||
export const MINIGAMES = {
|
||||
@@ -21,6 +23,8 @@ export const MINIGAMES = {
|
||||
rinquarto: { create: (seed, level) => rinquarto.newRinquarto(seed, { level }), update: rinquarto.update, press: rinquarto.press, release: rinquarto.release, cancel: rinquarto.cancel, aim: rinquarto.aimScreen },
|
||||
basket: { create: (seed, level) => basket.newBasket(seed, { level }), update: basket.update, press: basket.press, release: basket.release, cancel: basket.cancel, aim: basket.aimScreen },
|
||||
pesca: { create: (seed, level) => pesca.newPesca(seed, { level }), update: pesca.update, press: pesca.press, release: pesca.release, cancel: pesca.cancel, aim: pesca.aimScreen },
|
||||
cerbottana: { create: (seed, level) => cerbottana.newCerbottana(seed, { level }), update: cerbottana.update, press: cerbottana.press, release: cerbottana.release, cancel: cerbottana.cancel, aim: cerbottana.aimScreen },
|
||||
micro: { create: (seed, level) => micro.newMicro(seed, { level }), update: micro.update, press: micro.press, release: micro.release, cancel: micro.cancel, aim: micro.aimScreen },
|
||||
gara: { create: (seed, level, deck, def) => gara.newGara(seed, { level, riders: def.riders }), update: gara.update, press: gara.press, release: gara.release, cancel: gara.cancel, aim: gara.aimScreen },
|
||||
};
|
||||
|
||||
@@ -160,6 +164,9 @@ export class Game {
|
||||
}
|
||||
|
||||
get scene() { return this.story.scenes[this.state.scene]; }
|
||||
// Lo sfondo di adesso: la prima variante della scena (`backdrops`, ognuna con la sua condizione `when`) che vale,
|
||||
// sennò il suo `background`. Così un posto cambia con la storia (la Ghiacciomobile nel muro, poi la targa).
|
||||
backdrop(scene = this.scene) { return scene.backdrops?.find(b => check(b.when, this.state))?.src ?? scene.background; }
|
||||
// Occupato: c'è qualcosa in corso che il giocatore non può interrompere. La camminata verso un punto
|
||||
// o verso un oggetto si può sempre cambiare con un altro clic: la coda che la seguiva viene scartata.
|
||||
get busy() { return !!this.speech || !!this.closeup || this.reach > 0 || (this.task ? !this.task.interruptible : this.queue.length > 0); }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { TRACK, CURVES, PICKUPS, BRAKE, LAPS, COUNTDOWN, ROAD, VERGE, CAN, SWIPE, pointAt, standings, player, lapOf, presenting, placeOf, INTRO } from './gara.js';
|
||||
import { TRACK, CURVES, PICKUPS, BRAKE, LAPS, COUNTDOWN, ROAD, VERGE, CAN, SWIPE, pointAt, standings, player, lapOf, presenting, placeOf, INTRO, mustLift, PREAVVISO } from './gara.js';
|
||||
import { text, panel } from './bocce-render.js';
|
||||
import { ambientHash as hash } from './ambient.js';
|
||||
|
||||
@@ -216,6 +216,12 @@ function result(ctx, c) {
|
||||
});
|
||||
}
|
||||
|
||||
// Una scritta sopra il motorino di Andrea, su un fondo scuro perché si legga anche sullo sterrato e sul telefono.
|
||||
function tag(ctx, line, r, color) {
|
||||
const x = Math.round(r.x), y = Math.round(r.y) - 20, w = line.length * 9 + 10;
|
||||
ctx.fillStyle = 'rgba(23,22,15,0.85)'; ctx.fillRect(x - w / 2, y - 7, w, 14);
|
||||
text(ctx, line, x, y, 10, color, 'center');
|
||||
}
|
||||
export function drawGara(ctx, c, def, bg, look = () => null, sheet = () => null) {
|
||||
ctx.save();
|
||||
if (bg) ctx.drawImage(bg, 0, 0, 640, 360);
|
||||
@@ -232,6 +238,10 @@ export function drawGara(ctx, c, def, bg, look = () => null, sheet = () => null)
|
||||
const me = player(c);
|
||||
if (c.step === 'race' && me.out > 0) text(ctx, me.lastHole !== undefined ? 'NELLA BUCA!' : 'NELLA PAGLIA!', 320, 180, 10, '#ffe28a', 'center');
|
||||
if (c.step === 'race' && me.boost > 0 && me.out <= 0) text(ctx, 'MISCELA!', 320, 180, 8, '#ffb030', 'center');
|
||||
// La guida semplice: LASCIA! sopra il motorino quando serve frenare, e la curva pulita.
|
||||
if (c.step === 'race' && c.holding && mustLift(c)) { if (Math.floor(c.age * 8) % 2) tag(ctx, 'LASCIA!', me, '#ff6a4a'); }
|
||||
else if (c.step === 'race' && c.holding && mustLift(c, PREAVVISO)) tag(ctx, 'CURVA!', me, '#ffe28a');
|
||||
if (c.step === 'race' && c.clean !== undefined && c.t - c.clean < 1.2) text(ctx, 'CURVA PULITA!', 320, 180, 9, '#b9e5b3', 'center');
|
||||
if (c.step === 'result') result(ctx, c);
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
@@ -50,12 +50,20 @@ export const RIDERS = [
|
||||
{ id: 'andrea', name: 'Andrea', bike: 'il Fifty', motore: 3, testa: 3, color: '#d8402f', trim: '#1c1c1c' },
|
||||
{ id: 'arcu', name: 'L\'Arcu', bike: 'il Betino', motore: 1, testa: 5, color: '#2f7a3a', trim: '#e8d9a0' },
|
||||
];
|
||||
// I livelli: quanto vanno gli altri, quanto si resta fermi nella paglia, e la guida disegnata in pista.
|
||||
// I livelli: quanto vanno gli altri, quanto si resta fermi nella paglia, e la guida disegnata in pista. `simple`: la
|
||||
// guida semplice (Andrea, 29 ottobre: dal telefono lo sterzo era ingiocabile): si tiene premuto per il gas e lasciando
|
||||
// si frena, lo sterzo segue la strada da solo, e chi entra in curva troppo forte scivola fuori. Ginocchio in terra
|
||||
// tiene lo sterzo vero.
|
||||
export const LEVELS = {
|
||||
bona: { rivals: 0.74, stun: 0.4, guide: 'zone' },
|
||||
seria: { rivals: 0.84, stun: 0.9, guide: 'coni' },
|
||||
bona: { rivals: 0.74, stun: 0.4, guide: 'zone', simple: true },
|
||||
// Seria (Andrea, 29 ottobre: «chi non rallenta in curva deve andare fuori»; valori proposti da Codex e simulati):
|
||||
// si scivola di più, sopra il limite in curva si esce per forza, e la curva pulita dà una spinta.
|
||||
seria: { rivals: 0.81, stun: 1.2, guide: 'coni', simple: true,
|
||||
tune: { slide: 12, clean: { min: 0.85, slack: 2, time: 0.6, accel: 1.2 }, force: { over: 1.1, hold: 0.18, apex: 1.15, time: 0.3, guard: 0.6 } } },
|
||||
male: { rivals: 0.93, stun: 1.4, guide: null },
|
||||
};
|
||||
// `def.simple` la forza (i test della guida vera la spengono anche alla bona).
|
||||
export const simple = c => !!c.simple;
|
||||
|
||||
function catmull(p0, p1, p2, p3, t) {
|
||||
const t2 = t * t, t3 = t2 * t;
|
||||
@@ -154,7 +162,7 @@ export function newGara(seed = Date.now() >>> 0, def = {}) {
|
||||
});
|
||||
if (!riders.some(r => r.id === 'andrea')) throw new Error('Nella gara manca Andrea');
|
||||
for (const r of riders) { r.grid = r.s; r.shown = false; }
|
||||
return { step: 'intro', t: 0, age: 0, seed, level, skill, riders, holding: false, braking: false, keys: { left: false, right: false, gas: new Set(), brake: false },
|
||||
return { step: 'intro', t: 0, age: 0, seed, level, skill, simple: def.simple ?? !!skill.simple, tune: { ...SIMPLE, ...skill.tune }, riders, holding: false, braking: false, keys: { left: false, right: false, gas: new Set(), brake: false },
|
||||
pointer: null, toggle: false, brakeButton: false, drag: 0, buttons: 0, anchor: null, finger: null, sens: SWIPE.sens,
|
||||
power: SWIPE.sens, accumulator: 0, events: [], result: null, order: riders.map(r => r.id), taken: {} };
|
||||
}
|
||||
@@ -258,12 +266,75 @@ export function steering(c) {
|
||||
// La distanza davanti, sul giro, da s a un punto della pista (sempre fra 0 e la lunghezza del giro).
|
||||
export const ahead = (from, to) => ((((to - from) % TRACK.length) + TRACK.length) % TRACK.length);
|
||||
|
||||
// Lo sterzo che segue la strada: si guarda un punto più avanti sulla propria corsia e ci si gira (gli avversari, e
|
||||
// Andrea nella guida semplice). Andando troppo forte in curva lo sterzo non basta e si scivola fuori.
|
||||
const follow = r => { const aim = pointAt(r.s + 14 + r.v * 0.18, r.lane * 0.6); return clamp(wrapAngle(Math.atan2(aim.y - r.y, aim.x - r.x) - r.a) * 2.6, -1, 1); };
|
||||
// La guida semplice di Andrea: lo sterzo scansa le buche, sorpassa e va sulle lattine di miscela; ma oltre la velocità
|
||||
// che la curva regge (la più stretta nei SIMPLE.window pixel davanti) il motorino scivola verso l'esterno, tanto più
|
||||
// quanto si esagera (SIMPLE.slide): a tutto gas, nelle curve vere si finisce nella paglia.
|
||||
// Ogni livello può stringere (LEVELS.*.tune). `clean`: il premio della curva pulita, presa senza mai passare il
|
||||
// limite (`slack` px/s di tolleranza) e senza frenare troppo (almeno `min` del limite): per `time` secondi in uscita
|
||||
// si accelera di più (`accel`), senza superare la velocità massima. `force`: l'uscita sicura, sopra `over` volte il
|
||||
// limite per `hold` secondi (o `apex` volte nel punto più stretto) si va nella paglia in `time` secondi, una volta per
|
||||
// curva; rientrati, `guard` secondi di tregua.
|
||||
export const SIMPLE = { grip: 1, slide: 8, window: 50, clean: null, force: null };
|
||||
export function simpleLimit(r, s = r.s, tune = SIMPLE) {
|
||||
let low = Infinity;
|
||||
for (let d = -10; d <= tune.window; d += STEP) low = Math.min(low, limitAt(s + d));
|
||||
return low * r.grip * tune.grip;
|
||||
}
|
||||
// La curva in corso: dentro si tiene il peggio dell'eccesso e la velocità più bassa (per il premio), e si guarda se
|
||||
// si è andati troppo forte abbastanza a lungo (per l'uscita sicura).
|
||||
function judgeCurve(c, r, dt) {
|
||||
const tune = c.tune, s = ((r.s % TRACK.length) + TRACK.length) % TRACK.length;
|
||||
const k = CURVES.find(k => s >= k.start - 20 && s <= k.end + 10);
|
||||
if (k) {
|
||||
const w = r.curve?.k === k ? r.curve : (r.curve = { k, excess: 0, slow: Infinity, over: 0, fault: false });
|
||||
w.excess = Math.max(w.excess, r.excess); w.slow = Math.min(w.slow, r.v);
|
||||
const f = tune.force, limit = limitAt(k.apex) * r.grip * tune.grip;
|
||||
if (f && !w.fault && !(r.guard > 0) && r.out === 0) {
|
||||
w.over = r.v > limit * f.over ? w.over + dt : 0;
|
||||
if (w.over >= f.hold || (Math.abs(s - k.apex) < STEP * 2 && r.v > limit * f.apex)) { w.fault = true; r.forced = f.time; }
|
||||
}
|
||||
return;
|
||||
}
|
||||
const w = r.curve; r.curve = null;
|
||||
if (!w || !tune.clean || w.fault) return;
|
||||
const limit = limitAt(w.k.apex) * r.grip * tune.grip;
|
||||
if (w.excess <= tune.clean.slack && w.slow >= limit * tune.clean.min && r.out === 0) {
|
||||
r.push = tune.clean.time; r.cleans = (r.cleans ?? 0) + 1;
|
||||
c.events.push({ kind: 'gara-giro', who: r.id, power: 1 }); c.clean = c.t;
|
||||
}
|
||||
}
|
||||
// Andrea, nella guida semplice, deve lasciare entro `lead` secondi per arrivare alle curve davanti sotto il limite.
|
||||
// Sopra il motorino: CURVA! in giallo con PREAVVISO secondi d'anticipo, poi LASCIA! in rosso quando è il momento (sul
|
||||
// telefono non serve l'istante preciso, e lasciare troppo presto, che qui vuol dire frenare, non conviene).
|
||||
export const PREAVVISO = 0.7, LIFT = 0;
|
||||
export function mustLift(c, lead = LIFT) {
|
||||
const r = player(c);
|
||||
if (!simple(c) || c.step !== 'race' || r.out > 0) return false;
|
||||
const horizon = r.v * r.v / (2 * BRAKE) + r.v * lead + 10;
|
||||
for (let d = 0; d <= horizon; d += 4) {
|
||||
const a = simpleLimit(r, r.s + d, c.tune), room = Math.max(0, d - r.v * lead);
|
||||
if (r.v > a && r.v * r.v > a * a + 2 * BRAKE * room) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function autopilot(c, r) {
|
||||
const next = PICKUPS.find(p => p.kind !== 'boost' && ahead(r.s, p.s) < 30 + r.v * 0.6);
|
||||
// Chi sta davanti più lento si passa dall'altra parte; le buche si scansano, la miscela si prende.
|
||||
const slow = c.riders.find(o => o !== r && o.s - r.s > 0 && o.s - r.s < 26 && Math.abs(o.lat - r.lat) < 7 && o.v < r.v + 8);
|
||||
if (next?.kind === 'buca') r.lane = next.lane > 0 ? -5 : 5;
|
||||
else if (slow) r.lane = slow.lat > 0 ? -6 : 6;
|
||||
else if (next?.kind === 'miscela') r.lane = next.lane;
|
||||
r.excess = Math.max(0, r.v - simpleLimit(r, r.s, c.tune));
|
||||
return follow(r);
|
||||
}
|
||||
// Gli avversari: guardano un punto più avanti sulla loro corsia e ci sterzano; danno gas finché, frenando da qui,
|
||||
// arriverebbero a ogni curva davanti sotto il limite (un po' meno, quanto si fidano). Chi ha poca testa ogni tanto
|
||||
// si fida troppo.
|
||||
function drive(c, r) {
|
||||
const aim = pointAt(r.s + 14 + r.v * 0.18, r.lane * 0.6);
|
||||
r.steer = clamp(wrapAngle(Math.atan2(aim.y - r.y, aim.x - r.x) - r.a) * 2.6, -1, 1);
|
||||
r.steer = follow(r);
|
||||
const curve = CURVES.find(k => { const s = ((r.s % TRACK.length) + TRACK.length) % TRACK.length; return s >= k.start - 60 && s < k.start - 57; });
|
||||
if (curve && r.lastCurve !== curve) { r.lastCurve = curve; r.risk = random(c) < r.slip ? 1.15 : 1; }
|
||||
const horizon = (r.v * r.v) / (2 * BRAKE) + 20;
|
||||
@@ -283,22 +354,28 @@ function drive(c, r) {
|
||||
}
|
||||
function stepRider(c, r, dt) {
|
||||
if (r.finished !== null) { r.gas = false; r.brake = false; drive(c, r); r.gas = false; }
|
||||
else if (r.out > 0) { r.out = Math.max(0, r.out - dt); r.v = 0; r.u = 0; return; }
|
||||
else if (r.out > 0) { r.out = Math.max(0, r.out - dt); r.v = 0; r.u = 0; if (!r.out && c.tune.force) r.guard = c.tune.force.guard; return; }
|
||||
else if (r.id === 'andrea' && simple(c)) { r.gas = c.holding; r.brake = !c.holding; r.steer = autopilot(c, r); judgeCurve(c, r, dt); }
|
||||
else if (r.id === 'andrea') { r.gas = c.holding; r.brake = c.braking; r.steer = steering(c); }
|
||||
else drive(c, r);
|
||||
if (r.finished !== null) r.gas = false;
|
||||
const grass = Math.abs(r.lat) > ROAD, top = r.vmax * (r.boost > 0 ? BOOST.speed : 1) * (grass ? 0.5 : 1);
|
||||
// Il freno vince sul gas: chi li tiene tutti e due frena.
|
||||
if (r.brake) r.v -= BRAKE * dt;
|
||||
else if (r.gas) r.v += r.accel * dt * (1 - 0.4 * r.v / top) * (r.boost > 0 ? 1.6 : 1);
|
||||
if (r.brake) { r.v -= BRAKE * dt; r.push = 0; }
|
||||
else if (r.gas) r.v += r.accel * dt * (1 - 0.4 * r.v / top) * (r.boost > 0 ? 1.6 : 1) * (r.push > 0 ? c.tune.clean.accel : 1);
|
||||
else r.v -= COAST * dt;
|
||||
if (r.v > top) r.v = Math.max(top, r.v - 120 * dt);
|
||||
r.v = Math.max(0, r.v);
|
||||
r.boost = Math.max(0, r.boost - dt);
|
||||
if (r.push) r.push = Math.max(0, r.push - dt);
|
||||
if (r.guard) r.guard = Math.max(0, r.guard - dt);
|
||||
// Lo sterzo: da fermi non si gira; in curva una parte della velocità resta per traverso e si scivola fuori.
|
||||
const turn = r.steer * TURN * Math.min(1, r.v / 22) * dt;
|
||||
r.a = wrapAngle(r.a + turn);
|
||||
r.u -= r.v * Math.sin(turn) * SLIDE * (r.v / r.vmax) / r.grip;
|
||||
if (r.excess) r.u -= TRACK.side[r.idx] * r.excess * c.tune.slide * dt; // la guida semplice: troppo forte, si allarga
|
||||
// L'uscita sicura: verso l'esterno della curva, e lo sterzo non la salva.
|
||||
if (r.forced > 0) { r.forced = Math.max(0, r.forced - dt); r.u = -(r.curve?.k.side ?? TRACK.side[r.idx]) * 90; r.v = Math.max(r.v, 30); }
|
||||
r.u *= Math.exp(-GRIP * r.grip * dt);
|
||||
r.x += (Math.cos(r.a) * r.v - Math.sin(r.a) * r.u) * dt;
|
||||
r.y += (Math.sin(r.a) * r.v + Math.cos(r.a) * r.u) * dt;
|
||||
@@ -307,7 +384,8 @@ function stepRider(c, r, dt) {
|
||||
if (Math.abs(r.lat) > VERGE) {
|
||||
const h = TRACK.heading[r.idx], p = TRACK.pts[r.idx], side = Math.sign(r.lat), back = side * (VERGE - 1);
|
||||
r.x = p[0] - Math.sin(h) * back; r.y = p[1] + Math.cos(h) * back; r.lat = back; r.u = 0;
|
||||
if (r.v > 40 && r.finished === null) {
|
||||
if ((r.v > 40 || r.forced > 0) && r.finished === null) {
|
||||
r.forced = 0;
|
||||
r.out = c.skill.stun * (r.id === 'andrea' ? 1 : 0.7); r.offs++; r.risk = 1;
|
||||
c.events.push({ kind: 'gara-fuori', who: r.id, power: r.id === 'andrea' ? 1 : 0.4 });
|
||||
}
|
||||
@@ -406,7 +484,7 @@ export function status(c) {
|
||||
const r = presenting(c);
|
||||
return r ? `${r.name} con ${r.bike}. (Un tocco: il prossimo.)` : 'Tutti in griglia!';
|
||||
}
|
||||
if (c.step === 'start') return c.t < COUNTDOWN - 0.01 ? `GP di Fortezza: si parte fra ${Math.ceil(COUNTDOWN - c.t)}… Tieni premuto per il gas, sterza con ← →.` : 'Via!';
|
||||
if (c.step === 'start') return c.t < COUNTDOWN - 0.01 ? `GP di Fortezza: si parte fra ${Math.ceil(COUNTDOWN - c.t)}… Tieni premuto per il gas, ${simple(c) ? 'lascia per frenare' : 'sterza con ← →'}.` : 'Via!';
|
||||
if (c.step === 'result') {
|
||||
const who = c.riders.find(r => r.id === c.result.order[0]).name;
|
||||
return c.result.place === 1 ? `Primo al GP di Fortezza! ${LAPS} giri in ${c.result.times.andrea.toFixed(1)} secondi.` : `${c.result.place}° posto. Ha vinto ${who}.`;
|
||||
@@ -414,6 +492,9 @@ export function status(c) {
|
||||
const me = player(c), place = placeOf(c);
|
||||
if (me.out > 0) return me.lastHole !== undefined ? 'Nella buca! Ci si rialza…' : 'Nella paglia! Si riparte…';
|
||||
if (me.boost > 0) return `Giro ${lapOf(me)} di ${LAPS}, ${place}° posto. Miscela!`;
|
||||
if (simple(c)) return `Giro ${lapOf(me)} di ${LAPS}, ${place}° posto. ${c.clean !== undefined && c.t - c.clean < 1.5 ? 'Curva pulita!' : mustLift(c) && c.holding ? 'Lascia!' : mustLift(c, PREAVVISO) && c.holding ? 'Curva!' : c.holding ? 'Gas!' : 'Freno.'}`;
|
||||
return `Giro ${lapOf(me)} di ${LAPS}, ${place}° posto. ${c.braking ? 'Freno!' : c.holding ? 'Gas!' : 'Senza gas.'}`;
|
||||
}
|
||||
export const button = c => c.step === 'intro' ? 'Avanti' : c.step === 'result' ? 'Finita' : c.holding ? 'Molla' : 'Gas';
|
||||
// Nella guida semplice il pulsante si tiene premuto: la scritta resta Gas (su iPhone un pulsante che cambia sotto il dito
|
||||
// perde il tocco).
|
||||
export const button = c => c.step === 'intro' ? 'Avanti' : c.step === 'result' ? 'Finita' : simple(c) ? 'Gas' : c.holding ? 'Molla' : 'Gas';
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
import { HALF, CAR, CARS, canThrow, guide, done, overHeld, carImage, choiceAt, why, rank } from './micro.js';
|
||||
import { text, panel } from './bocce-render.js';
|
||||
|
||||
const NAME = { player: 'Andrea', cpu: 'Chiaru' };
|
||||
// Il gesso: i due bordi della pista e il traguardo, calcolati una volta per pista. Il tratto ha dei buchi, come il
|
||||
// gesso vero sull'asfalto ruvido (sempre gli stessi, da un piccolo hash: non tremano da un fotogramma all'altro).
|
||||
const chalks = new WeakMap();
|
||||
const hash = i => { let h = Math.imul(i ^ 0x9e3779b9, 0x85ebca6b); h ^= h >>> 13; return ((Math.imul(h, 0xc2b2ae35) ^ (h >>> 16)) >>> 0) / 4294967296; };
|
||||
function chalk(track) {
|
||||
if (chalks.has(track)) return chalks.get(track);
|
||||
const edges = [-1, 1].map(side => track.pts.map(([x, y], i) => [x - track.tan[i][1] * HALF * side, y + track.tan[i][0] * HALF * side]));
|
||||
const [tx, ty] = track.tan[0], [x0, y0] = track.pts[0];
|
||||
const out = { edges, finish: { x: x0, y: y0, nx: -ty, ny: tx, tx, ty } };
|
||||
chalks.set(track, out);
|
||||
return out;
|
||||
}
|
||||
function drawChalk(ctx, track) {
|
||||
const { edges, finish } = chalk(track);
|
||||
for (const edge of edges) for (const [width, color, jitter] of [[3, 'rgba(236,236,226,0.28)', 0.8], [1.5, 'rgba(246,246,238,0.85)', 0]]) {
|
||||
ctx.strokeStyle = color; ctx.lineWidth = width; ctx.beginPath();
|
||||
let open = false;
|
||||
edge.forEach(([x, y], i) => {
|
||||
if (hash(i + width * 1000) < 0.06) { open = false; return; } // un buco nel gesso
|
||||
const j = jitter * (hash(i * 7 + 3) - 0.5);
|
||||
if (!open) { ctx.moveTo(x + j, y - j); open = true; } else ctx.lineTo(x + j, y - j);
|
||||
});
|
||||
ctx.closePath(); ctx.stroke();
|
||||
}
|
||||
// Il traguardo: la scacchiera di gesso di traverso alla pista, due file.
|
||||
const { x, y, nx, ny, tx, ty } = finish, cell = 4;
|
||||
for (let k = -HALF; k < HALF; k += cell) for (let row = 0; row < 2; row++) {
|
||||
if ((Math.round(k / cell) + row) % 2) continue;
|
||||
const cx = x + nx * (k + cell / 2) + tx * (row - 0.5) * cell, cy = y + ny * (k + cell / 2) + ty * (row - 0.5) * cell;
|
||||
ctx.fillStyle = 'rgba(246,246,238,0.85)'; ctx.fillRect(Math.round(cx - cell / 2), Math.round(cy - cell / 2), cell, cell);
|
||||
}
|
||||
}
|
||||
function car(ctx, img, x, y, heading, alpha = 1, flipped = false) {
|
||||
ctx.save(); ctx.globalAlpha = alpha; ctx.translate(x, y); ctx.rotate(heading);
|
||||
if (flipped) ctx.scale(1, -1);
|
||||
ctx.fillStyle = 'rgba(10,12,16,0.35)'; ctx.fillRect(-CAR.len / 2 + 1, -CAR.wid / 2 + 2, CAR.len, CAR.wid); // l'ombra
|
||||
if (img) ctx.drawImage(img, -CAR.len / 2, -CAR.wid / 2, CAR.len, CAR.wid);
|
||||
else { ctx.fillStyle = '#d8402f'; ctx.fillRect(-CAR.len / 2, -CAR.wid / 2, CAR.len, CAR.wid); }
|
||||
ctx.restore();
|
||||
}
|
||||
function dashed(ctx, x0, y0, x1, y1, color) {
|
||||
ctx.strokeStyle = color; ctx.lineWidth = 1; ctx.setLineDash([3, 3]);
|
||||
ctx.beginPath(); ctx.moveTo(x0, y0); ctx.lineTo(x1, y1); ctx.stroke(); ctx.setLineDash([]);
|
||||
}
|
||||
// La mira: alla bona tutto il tiro, con la macchinina fantasma dove si ferma (rossa se esce); seria solo la linea; a
|
||||
// fassi male una freccina. Quando si carica, il dito si tira indietro; se resta troppo alla carica piena diventa rosso
|
||||
// (sta per essere un accompagnè).
|
||||
function aim(ctx, c, img) {
|
||||
const me = c.cars.player, ux = Math.cos(c.angle), uy = Math.sin(c.angle), kind = c.skill.guide;
|
||||
if (kind === 'full') {
|
||||
const g = guide(c), color = g.out ? '#ff7a5c' : '#b9f0a8';
|
||||
dashed(ctx, me.x, me.y, g.x, g.y, color);
|
||||
car(ctx, img, g.x, g.y, c.angle, 0.35);
|
||||
ctx.strokeStyle = color; ctx.lineWidth = 1; ctx.beginPath(); ctx.arc(g.x, g.y, CAR.r + 3, 0, Math.PI * 2); ctx.stroke();
|
||||
} else {
|
||||
const length = kind === 'line' ? 70 : 24;
|
||||
dashed(ctx, me.x, me.y, me.x + ux * length, me.y + uy * length, '#fff8dc');
|
||||
const hx = me.x + ux * length, hy = me.y + uy * length;
|
||||
ctx.fillStyle = '#fff8dc'; ctx.beginPath();
|
||||
ctx.moveTo(hx + ux * 4, hy + uy * 4); ctx.lineTo(hx - uy * 3, hy + ux * 3); ctx.lineTo(hx + uy * 3, hy - ux * 3); ctx.fill();
|
||||
}
|
||||
const back = CAR.len / 2 + 4 + (c.charging ? c.power * 14 : 0), fx = me.x - ux * back, fy = me.y - uy * back;
|
||||
const over = overHeld(c);
|
||||
ctx.fillStyle = over ? '#ff6a4a' : '#e8b48f'; ctx.strokeStyle = '#6b3d26'; ctx.lineWidth = 1;
|
||||
ctx.beginPath(); ctx.arc(fx, fy, 4, 0, Math.PI * 2); ctx.fill(); ctx.stroke();
|
||||
ctx.fillStyle = '#f7d9c4'; ctx.fillRect(Math.round(fx + ux * 1.5) - 1, Math.round(fy + uy * 1.5) - 1, 2, 2); // l'unghia
|
||||
// La forza che sale mentre si tiene premuto: una barretta sopra la macchinina.
|
||||
if (c.holding) {
|
||||
const x = Math.round(me.x - 15), y = Math.round(me.y - 19);
|
||||
ctx.fillStyle = '#17160fd0'; ctx.fillRect(x - 1, y - 1, 32, 6);
|
||||
ctx.fillStyle = over ? '#ff6a4a' : c.power > 0.75 ? '#ffd23c' : '#9be07c'; ctx.fillRect(x, y, Math.round(30 * c.power), 4);
|
||||
}
|
||||
}
|
||||
// Dove una macchinina ha fatto il fallo: una croce di gesso rosso che sfuma, e la macchinina (ribaltata, se ha cappottato)
|
||||
// che sparisce per tornare al suo posto.
|
||||
function returns(ctx, c, images) {
|
||||
for (const r of c.returns) {
|
||||
const age = c.visual.time - r.at;
|
||||
if (age > 3) continue;
|
||||
const a = 1 - age / 3;
|
||||
ctx.strokeStyle = `rgba(255,110,80,${a})`; ctx.lineWidth = 2; ctx.beginPath();
|
||||
ctx.moveTo(r.x - 5, r.y - 5); ctx.lineTo(r.x + 5, r.y + 5); ctx.moveTo(r.x + 5, r.y - 5); ctx.lineTo(r.x - 5, r.y + 5); ctx.stroke();
|
||||
const fade = r.fault === 'cappotte' ? 1.2 : 0.6;
|
||||
if (age < fade) car(ctx, images[r.role], r.x, r.y, r.heading + (r.fault === 'cappotte' ? 0.5 : 0), 0.7 * (1 - age / fade), r.fault === 'cappotte');
|
||||
}
|
||||
}
|
||||
|
||||
// La scelta della macchinina: le sei in grande sul parcheggio, quella scelta cerchiata di gesso e un po' sollevata.
|
||||
function choice(ctx, c, image) {
|
||||
ctx.fillStyle = '#17160fc8'; ctx.fillRect(60, 56, 520, 250);
|
||||
text(ctx, 'SCEGLI LA TUA MACCHININA', 320, 76, 12, '#efd49e', 'center');
|
||||
CARS.forEach((car, i) => {
|
||||
const [x, y] = choiceAt(i), on = i === c.choice, lift = on ? Math.sin(c.visual.time * 5) * 1.5 - 2 : 0, img = image?.(carImage(car.id, true));
|
||||
if (on) { ctx.strokeStyle = 'rgba(246,246,238,0.9)'; ctx.lineWidth = 2; ctx.beginPath(); ctx.ellipse(x, y, 50, 28, 0, 0, Math.PI * 2); ctx.stroke(); }
|
||||
ctx.fillStyle = 'rgba(10,12,16,0.35)'; ctx.fillRect(x - 37, y - 16, 78, 38); // l'ombra
|
||||
if (img) ctx.drawImage(img, Math.round(x - img.width / 2), Math.round(y - img.height / 2 + lift));
|
||||
text(ctx, car.name, x, y + 34, 8, on ? '#fff0c8' : '#a99d86', 'center');
|
||||
});
|
||||
const cpu = CARS[c.choice].id === 'blu' ? 'la rossa' : 'la blu e gialla';
|
||||
text(ctx, `Il Chiaru prende ${cpu}. Tocca la tua, o frecce e Scegli.`, 320, 292, 8, '#d9ccba', 'center');
|
||||
}
|
||||
|
||||
export function drawMicro(ctx, c, def, bg, image) {
|
||||
ctx.save(); ctx.imageSmoothingEnabled = false;
|
||||
if (bg) ctx.drawImage(bg, 0, 0, 640, 360); else { ctx.fillStyle = '#4b4d50'; ctx.fillRect(0, 0, 640, 360); }
|
||||
drawChalk(ctx, c.track);
|
||||
if (c.step === 'choose') { choice(ctx, c, image); ctx.restore(); return; }
|
||||
const images = { player: image?.(carImage(c.colors.player)), cpu: image?.(carImage(c.colors.cpu)) };
|
||||
if (c.step === 'rolling' && c.trail.length > 1) {
|
||||
ctx.strokeStyle = 'rgba(255,248,220,0.35)'; ctx.lineWidth = 1; ctx.beginPath(); ctx.moveTo(...c.trail[0]);
|
||||
for (const p of c.trail.slice(1)) ctx.lineTo(...p);
|
||||
ctx.stroke();
|
||||
}
|
||||
returns(ctx, c, images);
|
||||
if (canThrow(c)) aim(ctx, c, images.player);
|
||||
for (const who of ['cpu', 'player']) { const x = c.cars[who]; car(ctx, images[who], x.x, x.y, x.heading); }
|
||||
// In alto: quanta pista ha fatto ciascuno (una barra col colore della macchinina) e cosa succede.
|
||||
ctx.fillStyle = '#17160fe8'; ctx.fillRect(0, 0, 640, 22);
|
||||
text(ctx, 'LA PISTA COL GESSO', 8, 7, 8, '#efd49e');
|
||||
const level = { bona: 'alla bona', seria: 'seria', male: 'a fassi male' }[c.level];
|
||||
text(ctx, `${level} · spinte ${c.flicks.player}`, 8, 16, 7, '#d9ccba');
|
||||
const tint = id => CARS.find(x => x.id === id).color;
|
||||
for (const [who, x0, color] of [['player', 200, tint(c.colors.player)], ['cpu', 430, tint(c.colors.cpu)]]) {
|
||||
// Primo o secondo, mentre si va (Andrea, 29 ottobre).
|
||||
const place = rank(c, who);
|
||||
text(ctx, `${place}°`, x0 - 4, 11, 9, place === 1 ? '#ffe28a' : '#a99d86', 'right');
|
||||
text(ctx, NAME[who], x0, 11, 8, '#fff0c8');
|
||||
ctx.fillStyle = '#3a372e'; ctx.fillRect(x0 + 52, 7, 140, 8);
|
||||
ctx.fillStyle = color; ctx.fillRect(x0 + 52, 7, Math.round(140 * done(c, who)), 8);
|
||||
ctx.strokeStyle = '#897b57'; ctx.lineWidth = 1; ctx.strokeRect(x0 + 52.5, 7.5, 139, 7);
|
||||
}
|
||||
const turn = c.step === 'result' ? null : c.current === 'cpu' ? 'Spinge il Chiaru…' : c.step === 'aim' ? 'Tocca a te: mira e spingi' : null;
|
||||
const line = overHeld(c) ? 'Lascia! Sennò è accompagnè' : c.line ?? turn;
|
||||
if (line) { ctx.fillStyle = '#17160fd0'; ctx.fillRect(170, 24, 300, 14); text(ctx, line, 320, 31, 8, /^(Fuori|Tagliè|Cappottè|Accompagnè)!/.test(c.line ?? '') ? '#ffbf9f' : '#9fd0ff', 'center'); }
|
||||
if (c.step === 'result') {
|
||||
const w = c.result.winner, title = w === 'player' ? 'HAI BATTUTO IL CHIARU!' : w === 'cpu' ? 'HA VINTO IL CHIARU' : 'ARRIVATI PARI';
|
||||
// Il perché, in due righe: chi è arrivato a quale spinta, e di quanto è andato più in là.
|
||||
const [first, second] = why(c);
|
||||
panel(ctx, 130, 132, 380, 92);
|
||||
text(ctx, title, 320, 150, 12, w === 'player' ? '#b9e5b3' : '#efd49e', 'center');
|
||||
text(ctx, first, 320, 172, 8, '#efd49e', 'center');
|
||||
text(ctx, second, 320, 186, 8, '#efd49e', 'center');
|
||||
text(ctx, 'Torna dal Chiaru per uscire.', 320, 208, 8, '#d9ccba', 'center');
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
// Le macchinine sulla pista col gesso (Andrea, 28 ottobre): sul parcheggio sotto casa, a Cardetole, si disegnava col
|
||||
// gesso la pista e si davano spinte a turno alle Micro Machines; la macchinina doveva restare in pista: tutta fuori, si
|
||||
// torna da dove si era partiti. Si gioca contro il Chiaru, un giro; vince chi taglia per primo il traguardo.
|
||||
//
|
||||
// Regole: una spinta a testa, prima Andrea e poi il Chiaru, così a fine giro hanno spinto lo stesso numero di volte.
|
||||
// Se tagliano il traguardo tutti e due nello stesso giro di spinte vince chi è andato più in là. Le penalità, coi nomi
|
||||
// alla francese che si usavano (Andrea, 29 ottobre), e per tutte si torna dove si era prima della spinta:
|
||||
// - fuori: la macchinina esce tutta dal gesso (anche se ce la manda l'altra, urtandola);
|
||||
// - tagliè: esce dalla parte di dentro di una curva, o salta l'erba di mezzo per tagliare la strada;
|
||||
// - cappottè: un urto forte la ribalta;
|
||||
// - accompagnè: il dito l'ha accompagnata invece di darle il colpetto (tenuto premuto oltre la carica piena).
|
||||
// Unità: i pixel del primo piano 640×360; la pista si disegna sopra al parcheggio di Codex.
|
||||
|
||||
// La linea di mezzo, in senso orario a partire dal traguardo; la pista è larga 2·HALF, col gesso sui due bordi.
|
||||
export const CONTROL = [
|
||||
[150, 68], [300, 62], [450, 66], [540, 80], [586, 122], [580, 172], [536, 196], [470, 196], [414, 178],
|
||||
[356, 168], [318, 196], [326, 240], [388, 262], [480, 260], [556, 262], [598, 290], [588, 324], [530, 334],
|
||||
[400, 334], [250, 332], [130, 326], [74, 296], [58, 230], [62, 150], [88, 96],
|
||||
];
|
||||
export const HALF = 22, CAR = { len: 26, wid: 13, r: 6 }, LAPS = 1;
|
||||
// La spinta: velocità di partenza da MIN_SPEED a MAX_SPEED, e l'asfalto che frena di DECEL px/s².
|
||||
export const MIN_SPEED = 60, MAX_SPEED = 400, DECEL = 420, SWING = 1.2, TAP = 0.14, FIXED_STEP = 1 / 120;
|
||||
const REST = 0.7, THINK = 1, RESTITUTION = 0.6, OUT = HALF + CAR.r, WINDOW = 30;
|
||||
// FLIP: la velocità d'urto (px/s) che ribalta la macchinina colpita; ACCOMPAGNA: quanti secondi si può restare alla
|
||||
// carica piena prima che diventi un accompagnè.
|
||||
export const FLIP = 260, ACCOMPAGNA = 0.45;
|
||||
export const FAULTS = { fuori: 'Fuori', taglie: 'Tagliè', cappotte: 'Cappottè', accompagne: 'Accompagnè' };
|
||||
export const OTHER = { player: 'cpu', cpu: 'player' };
|
||||
|
||||
// Quanto è bravo il Chiaru: quanto gli trema il dito (radianti e forza) e fin dove osa spingere (px). `guide`: cosa
|
||||
// vede Andrea mentre mira (tutto il tiro col punto d'arrivo, solo la linea, solo la freccia).
|
||||
export const LEVELS = {
|
||||
bona: { wobble: 0.1, powerNoise: 0.16, ahead: 120, guide: 'full' },
|
||||
seria: { wobble: 0.05, powerNoise: 0.08, ahead: 170, guide: 'line' },
|
||||
male: { wobble: 0.022, powerNoise: 0.035, ahead: 200, guide: 'arrow' },
|
||||
};
|
||||
|
||||
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
|
||||
function random(c) { c.seed = (Math.imul(c.seed, 1664525) + 1013904223) >>> 0; return c.seed / 4294967296; }
|
||||
const deviation = c => random(c) + random(c) + random(c) - 1.5;
|
||||
|
||||
export const powerAt = time => clamp(time / SWING, 0, 1);
|
||||
export const speedFor = power => MIN_SPEED + (MAX_SPEED - MIN_SPEED) * clamp(power, 0, 1);
|
||||
// Quanta strada fa una macchinina spinta a velocità v (l'asfalto frena sempre uguale).
|
||||
export const reach = v => v * v / (2 * DECEL);
|
||||
export const powerFor = distance => clamp((Math.sqrt(2 * DECEL * Math.max(0, distance)) - MIN_SPEED) / (MAX_SPEED - MIN_SPEED), 0, 1);
|
||||
|
||||
// --- La pista: una curva chiusa (Catmull-Rom sui punti di controllo), ricampionata a passo costante.
|
||||
export function buildTrack(control = CONTROL, step = 2) {
|
||||
const n = control.length, dense = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const [p0, p1, p2, p3] = [control[(i - 1 + n) % n], control[i], control[(i + 1) % n], control[(i + 2) % n]];
|
||||
for (let k = 0; k < 24; k++) {
|
||||
const t = k / 24, t2 = t * t, t3 = t2 * t;
|
||||
const f = j => 0.5 * (2 * p1[j] + (p2[j] - p0[j]) * t + (2 * p0[j] - 5 * p1[j] + 4 * p2[j] - p3[j]) * t2 + (3 * p1[j] - p0[j] - 3 * p2[j] + p3[j]) * t3);
|
||||
dense.push([f(0), f(1)]);
|
||||
}
|
||||
}
|
||||
const cum = [0];
|
||||
for (let i = 1; i <= dense.length; i++) cum.push(cum[i - 1] + Math.hypot(dense[i % dense.length][0] - dense[i - 1][0], dense[i % dense.length][1] - dense[i - 1][1]));
|
||||
const total = cum.at(-1), count = Math.round(total / step), pts = [];
|
||||
for (let j = 0, i = 0; j < count; j++) {
|
||||
const at = j * total / count;
|
||||
while (cum[i + 1] < at) i++;
|
||||
const a = dense[i], b = dense[(i + 1) % dense.length], t = (at - cum[i]) / (cum[i + 1] - cum[i] || 1);
|
||||
pts.push([a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]);
|
||||
}
|
||||
const tan = pts.map((p, i) => {
|
||||
const a = pts[(i - 1 + count) % count], b = pts[(i + 1) % count], d = Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;
|
||||
return [(b[0] - a[0]) / d, (b[1] - a[1]) / d];
|
||||
});
|
||||
return { pts, tan, n: count, step: total / count, length: total };
|
||||
}
|
||||
export const TRACK = buildTrack();
|
||||
|
||||
// Il punto della linea di mezzo più vicino: vicino all'ultimo noto (`hint`), così nei tornanti non si salta dall'altra
|
||||
// parte; senza `hint`, su tutta la pista. `s` è la distanza lungo la pista dal traguardo, `d` quella dalla linea.
|
||||
export function project(track, x, y, hint) {
|
||||
const { pts, n } = track;
|
||||
const from = hint === undefined ? 0 : hint - WINDOW, to = hint === undefined ? n : hint + WINDOW;
|
||||
let best = null;
|
||||
for (let k = from; k < to; k++) {
|
||||
const i = ((k % n) + n) % n, a = pts[i], b = pts[(i + 1) % n];
|
||||
const dx = b[0] - a[0], dy = b[1] - a[1], len2 = dx * dx + dy * dy || 1;
|
||||
const t = clamp(((x - a[0]) * dx + (y - a[1]) * dy) / len2, 0, 1);
|
||||
const d = Math.hypot(x - a[0] - dx * t, y - a[1] - dy * t);
|
||||
if (!best || d < best.d) best = { i, t, d };
|
||||
}
|
||||
return { i: best.i, d: best.d, s: (best.i + best.t) * track.step };
|
||||
}
|
||||
// Tutta fuori: nessun pezzo della macchinina tocca più la pista.
|
||||
export const isOut = d => d > OUT;
|
||||
// Uscita dalla parte di dentro di una curva (verso dove gira la pista): è un tagliè.
|
||||
function inside(track, i, x, y) {
|
||||
const a = track.tan[(i - 6 + track.n) % track.n], b = track.tan[(i + 6) % track.n], turn = a[0] * b[1] - a[1] * b[0];
|
||||
const [px, py] = track.pts[i], [tx, ty] = track.tan[i], side = tx * (y - py) - ty * (x - px);
|
||||
return Math.abs(turn) > 0.05 && Math.sign(turn) === Math.sign(side);
|
||||
}
|
||||
|
||||
// La macchinina tiene il conto della strada fatta (`progress`, anche oltre il giro) seguendo la pista da vicino.
|
||||
function follow(track, car) {
|
||||
const p = project(track, car.x, car.y, car.idx);
|
||||
let delta = p.s - car.s;
|
||||
if (delta > track.length / 2) delta -= track.length; else if (delta < -track.length / 2) delta += track.length;
|
||||
car.progress += delta; car.s = p.s; car.idx = p.i;
|
||||
if (isOut(p.d) && !car.fault) car.fault = inside(track, p.i, car.x, car.y) ? 'taglie' : 'fuori';
|
||||
}
|
||||
|
||||
function newCar(track, role, back, side) {
|
||||
const i = (track.n - Math.round(back / track.step)) % track.n, [x, y] = track.pts[i], [tx, ty] = track.tan[i];
|
||||
const car = { role, x: x - ty * side, y: y + tx * side, vx: 0, vy: 0, heading: Math.atan2(ty, tx), idx: i, s: 0, progress: 0, fault: null };
|
||||
const p = project(track, car.x, car.y);
|
||||
car.idx = p.i; car.s = p.s; car.progress = p.s > track.length / 2 ? p.s - track.length : p.s;
|
||||
return car;
|
||||
}
|
||||
const cars = c => [c.cars.player, c.cars.cpu];
|
||||
export const moving = c => cars(c).some(car => car.vx || car.vy);
|
||||
|
||||
// L'urto fra le due macchinine: due dischi uguali, un po' di rimbalzo. Se l'urto è forte, quella colpita (la più
|
||||
// lenta delle due) si ribalta.
|
||||
function collide(a, b, events) {
|
||||
const dx = b.x - a.x, dy = b.y - a.y, d = Math.hypot(dx, dy), min = CAR.r * 2;
|
||||
if (d >= min || d < 1e-6) return;
|
||||
const nx = dx / d, ny = dy / d, push = (min - d) / 2;
|
||||
a.x -= nx * push; a.y -= ny * push; b.x += nx * push; b.y += ny * push;
|
||||
const rel = (a.vx - b.vx) * nx + (a.vy - b.vy) * ny;
|
||||
if (rel <= 0) return;
|
||||
const j = rel * (1 + RESTITUTION) / 2;
|
||||
const hit = Math.hypot(a.vx, a.vy) < Math.hypot(b.vx, b.vy) ? a : b;
|
||||
a.vx -= j * nx; a.vy -= j * ny; b.vx += j * nx; b.vy += j * ny;
|
||||
if (rel > FLIP) hit.fault = 'cappotte';
|
||||
events?.push({ kind: 'micro-urto', power: Math.min(1, rel / 300) });
|
||||
}
|
||||
function step(track, list, dt, events) {
|
||||
for (const car of list) {
|
||||
const v = Math.hypot(car.vx, car.vy);
|
||||
if (!v) continue;
|
||||
const nv = Math.max(0, v - DECEL * dt);
|
||||
if (nv < 2) { car.vx = car.vy = 0; continue; }
|
||||
car.vx *= nv / v; car.vy *= nv / v;
|
||||
car.x += car.vx * dt; car.y += car.vy * dt;
|
||||
}
|
||||
collide(list[0], list[1], events);
|
||||
for (const car of list) if (car.vx || car.vy) follow(track, car);
|
||||
}
|
||||
|
||||
// Le macchinine fra cui scegliere (Andrea, 29 ottobre: «quando si parte fammi scegliere la macchinina»): il disegno di
|
||||
// Codex in `assets/closeups/micro/<id>.png` (e `<id>-grande.png` per la scelta) e il colore della barra in alto.
|
||||
// Il Chiaru tiene la sua blu e gialla; se la prende Andrea, lui prende la rossa.
|
||||
export const CARS = [
|
||||
{ id: 'rossa', name: 'Rossa e bianca', color: '#e0543c' },
|
||||
{ id: 'blu', name: 'Blu e gialla', color: '#3c66d8' },
|
||||
{ id: 'nera', name: 'Nera e oro', color: '#c9a23a' },
|
||||
{ id: 'azzurra', name: 'Bianca e azzurra', color: '#6fb7ff' },
|
||||
{ id: 'arancio', name: 'Arancione', color: '#f08a2c' },
|
||||
{ id: 'viola', name: 'Viola e argento', color: '#9a5ad8' },
|
||||
];
|
||||
export const carImage = (id, big = false) => `assets/closeups/micro/${id}${big ? '-grande' : ''}.png`;
|
||||
// Dove stanno le macchinine nella scelta: due file da tre, al centro del parcheggio.
|
||||
export const choiceAt = i => [160 + (i % 3) * 160, 132 + Math.floor(i / 3) * 88];
|
||||
export function pick(c, i = c.choice) {
|
||||
if (c.step !== 'choose' || !CARS[i]) return false;
|
||||
const mine = CARS[i].id;
|
||||
c.colors = { player: mine, cpu: mine === 'blu' ? 'rossa' : 'blu' };
|
||||
c.step = 'aim'; c.t = 0; c.aimLocked = false; // il clic che sceglie non deve fissare anche la mira
|
||||
return true;
|
||||
}
|
||||
export function choose(c, i) {
|
||||
if (c.step !== 'choose' || !Number.isFinite(i)) return false;
|
||||
c.choice = (i + CARS.length) % CARS.length; return true;
|
||||
}
|
||||
const carUnder = (x, y) => CARS.findIndex((_, i) => { const [cx, cy] = choiceAt(i); return Math.abs(x - cx) < 44 && Math.abs(y - cy) < 30; });
|
||||
|
||||
export function newMicro(seed = Date.now() >>> 0, def = {}) {
|
||||
const level = LEVELS[def.level] ? def.level : 'seria', track = TRACK;
|
||||
const c = { step: 'choose', choice: 0, colors: null, t: 0, seed, level, skill: LEVELS[level], current: 'player', power: 0.5, angle: 0,
|
||||
holding: false, holdTime: 0, accumulator: 0, events: [], track, laps: LAPS, flicks: { player: 0, cpu: 0 },
|
||||
line: null, trail: [], returns: [], before: null, plan: null, visual: { time: 0 } };
|
||||
// In griglia: Andrea all'esterno, il Chiaru all'interno, poco prima del traguardo.
|
||||
c.cars = { player: newCar(track, 'player', 18, -11), cpu: newCar(track, 'cpu', 18, 11) };
|
||||
c.angle = c.cars.player.heading;
|
||||
// Si parte scegliendo la macchinina, se non è già data (`def.car`).
|
||||
if (def.car) pick(c, CARS.findIndex(x => x.id === def.car));
|
||||
return c;
|
||||
}
|
||||
|
||||
export const canThrow = c => c.step === 'aim' && c.current === 'player';
|
||||
export const finished = (c, car) => car.progress >= c.laps * c.track.length;
|
||||
const snapshot = car => ({ x: car.x, y: car.y, heading: car.heading, idx: car.idx, s: car.s, progress: car.progress });
|
||||
|
||||
export function strike(c, who, angle, power) {
|
||||
c.turn = null;
|
||||
const car = c.cars[who], v = speedFor(power);
|
||||
c.before = { player: snapshot(c.cars.player), cpu: snapshot(c.cars.cpu) };
|
||||
for (const x of cars(c)) x.fault = null;
|
||||
car.vx = Math.cos(angle) * v; car.vy = Math.sin(angle) * v; car.heading = angle;
|
||||
c.returns = c.returns.filter(r => c.visual.time - r.at < 4);
|
||||
if (who === 'player') c.line = null;
|
||||
c.shooter = who; c.angle = angle; c.power = power; c.plan = null; c.trail = [[car.x, car.y]];
|
||||
c.step = 'rolling'; c.t = c.accumulator = 0; c.flicks[who]++;
|
||||
c.events.push({ kind: 'micro-spinta', power }, { kind: 'micro-strisciata', power });
|
||||
return true;
|
||||
}
|
||||
|
||||
// La spinta provata a vuoto su una copia: dove arriva ciascuna macchinina e se qualcuna esce.
|
||||
export function simulate(c, who, angle, power) {
|
||||
const list = cars(c).map(x => ({ ...x, fault: null })), car = list.find(x => x.role === who), v = speedFor(power);
|
||||
car.vx = Math.cos(angle) * v; car.vy = Math.sin(angle) * v;
|
||||
for (let i = 0; i < 6 / FIXED_STEP && list.some(x => x.vx || x.vy); i++) step(c.track, list, FIXED_STEP);
|
||||
return Object.fromEntries(list.map(x => [x.role, x]));
|
||||
}
|
||||
|
||||
// Il Chiaru guarda la pista davanti a sé: prova dei punti più o meno lontani, al centro e verso i bordi, e per ognuno
|
||||
// anche le spinte storte che gli possono scappare; sceglie quello che in media lo porta più avanti senza uscire.
|
||||
// Le prove si fanno a pezzi (BUDGET per fotogramma): tutte insieme fermerebbero il gioco per un decimo di secondo.
|
||||
const BUDGET = 20;
|
||||
function cpuCandidates(c) {
|
||||
const me = c.cars.cpu, k = c.skill, list = [];
|
||||
for (let ahead = 30; ahead <= k.ahead; ahead += 10) for (const side of [-10, 0, 10]) {
|
||||
const i = (me.idx + Math.round(ahead / c.track.step)) % c.track.n, [px, py] = c.track.pts[i], [tx, ty] = c.track.tan[i];
|
||||
const x = px - ty * side, y = py + tx * side, angle = Math.atan2(y - me.y, x - me.x), power = powerFor(Math.hypot(x - me.x, y - me.y));
|
||||
for (const [da, dp] of [[0, 0], [k.wobble, 0], [-k.wobble, 0], [0, k.powerNoise], [0, -k.powerNoise]])
|
||||
list.push({ angle, power, try: [angle + da, clamp(power + dp, 0, 1)] });
|
||||
}
|
||||
return list;
|
||||
}
|
||||
export function cpuThink(c, budget = BUDGET) {
|
||||
const t = c.thinking ??= { todo: cpuCandidates(c), scores: new Map() }, me = c.cars.cpu;
|
||||
for (let i = 0; i < budget && t.todo.length; i++) {
|
||||
const x = t.todo.pop(), r = simulate(c, 'cpu', ...x.try).cpu, key = x.angle + '|' + x.power;
|
||||
t.scores.set(key, { angle: x.angle, power: x.power, score: (t.scores.get(key)?.score ?? 0) + (r.fault ? -80 : r.progress - me.progress) });
|
||||
}
|
||||
if (t.todo.length) return false;
|
||||
const best = [...t.scores.values()].reduce((a, b) => b.score > a.score ? b : a, { score: -Infinity, angle: me.heading, power: 0.3 });
|
||||
const k = c.skill;
|
||||
c.plan = { angle: best.angle + deviation(c) * k.wobble, power: clamp(best.power + deviation(c) * k.powerNoise, 0.02, 1) };
|
||||
c.angle = c.plan.angle; c.power = c.plan.power; c.thinking = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Finita la spinta: chi ha fatto un fallo torna al suo posto, e alla fine di ogni giro di spinte si guarda il traguardo.
|
||||
function settle(c) {
|
||||
const names = { player: 'Andrea', cpu: 'il Chiaru' }, outs = cars(c).filter(car => car.fault);
|
||||
// Uscita e ripresa la pista più in là: ha saltato l'erba di mezzo, è un tagliè.
|
||||
for (const car of outs) if (car.fault === 'fuori' && !isOut(project(c.track, car.x, car.y).d)) car.fault = 'taglie';
|
||||
// Le scritte di un giro di spinte restano insieme fino alla spinta dopo di Andrea: così vede anche le sue.
|
||||
const said = outs.map(car => `${FAULTS[car.fault]}! ${names[car.role][0].toUpperCase() + names[car.role].slice(1)} torna dov'era.`);
|
||||
// Dove è uscita resta una croce, e la macchinina si vede tornare indietro (solo disegno).
|
||||
for (const car of outs) {
|
||||
c.returns.push({ role: car.role, x: car.x, y: car.y, heading: car.heading, fault: car.fault, at: c.visual.time });
|
||||
Object.assign(car, c.before[car.role], { vx: 0, vy: 0, fault: null });
|
||||
c.events.push({ kind: 'micro-fuori', power: car.role === 'player' ? 1 : 0.5 });
|
||||
}
|
||||
// Rimessa al suo posto, non deve stare sopra all'altra.
|
||||
const [a, b] = cars(c), d = Math.hypot(b.x - a.x, b.y - a.y);
|
||||
if (outs.length === 1 && d < CAR.r * 2) {
|
||||
const back = outs[0], other = back === a ? b : a, nx = d ? (back.x - other.x) / d : 1, ny = d ? (back.y - other.y) / d : 0;
|
||||
back.x = other.x + nx * CAR.r * 2; back.y = other.y + ny * CAR.r * 2;
|
||||
}
|
||||
const mine = c.cars[c.shooter];
|
||||
if (!outs.length && finished(c, mine)) said.push(`${c.shooter === 'player' ? 'Andrea' : 'Il Chiaru'} taglia il traguardo!`);
|
||||
c.line = [c.line, ...said].filter(Boolean).join(' ') || null;
|
||||
if (!outs.includes(mine) && finished(c, mine)) c.events.push({ kind: 'micro-arrivo', power: c.shooter === 'player' ? 1 : 0.5 });
|
||||
// Il giro di spinte si chiude col Chiaru: solo allora si decide, così hanno spinto tutti e due lo stesso numero di volte.
|
||||
const end = c.laps * c.track.length, over = { player: c.cars.player.progress - end, cpu: c.cars.cpu.progress - end };
|
||||
if (c.shooter === 'cpu' && (over.player >= 0 || over.cpu >= 0)) {
|
||||
const winner = over.player >= 0 && over.cpu >= 0 ? (Math.abs(over.player - over.cpu) < 1 ? 'draw' : over.player > over.cpu ? 'player' : 'cpu') : over.player >= 0 ? 'player' : 'cpu';
|
||||
c.step = 'result'; c.result = { winner, flicks: { ...c.flicks }, over };
|
||||
return;
|
||||
}
|
||||
// Chi ha già tagliato il traguardo aspetta; spinge l'altro.
|
||||
c.current = OTHER[c.shooter];
|
||||
c.step = 'aim'; c.t = 0;
|
||||
if (c.current === 'player') c.angle = aimAhead(c);
|
||||
}
|
||||
// Quando tocca ad Andrea la mira parte già lungo la pista, un po' più avanti.
|
||||
function aimAhead(c) {
|
||||
const car = c.cars.player, i = (car.idx + Math.round(60 / c.track.step)) % c.track.n, [x, y] = c.track.pts[i];
|
||||
return Math.atan2(y - car.y, x - car.x);
|
||||
}
|
||||
|
||||
export function update(c, dt) {
|
||||
if (!Number.isFinite(dt) || dt <= 0) return;
|
||||
dt = Math.min(dt, 0.25); c.t += dt; c.visual.time += dt;
|
||||
if (c.turn && canThrow(c) && !c.holding) {
|
||||
c.turn.time += dt;
|
||||
c.angle += c.turn.dir * dt * (c.turn.fine ? 0.05 : 0.6 + 1.8 * Math.min(1, c.turn.time / 1.2));
|
||||
}
|
||||
if (c.holding) {
|
||||
c.holdTime += dt;
|
||||
c.charging = c.holdTime >= c.holdDelay;
|
||||
if (c.charging) c.power = c.holdDelay ? Math.min(1, c.previousPower + powerAt(c.holdTime - c.holdDelay)) : powerAt(c.holdTime);
|
||||
// Alla carica piena il dito non deve restare: si conta quanto ci sta, per l'accompagnè.
|
||||
c.overHold = c.charging && c.power >= 1 ? (c.overHold ?? 0) + dt : 0;
|
||||
}
|
||||
if (c.step === 'rolling') {
|
||||
c.accumulator += dt;
|
||||
const list = cars(c), car = c.cars[c.shooter];
|
||||
while (c.accumulator >= FIXED_STEP) { step(c.track, list, FIXED_STEP, c.events); c.accumulator -= FIXED_STEP; }
|
||||
const last = c.trail.at(-1);
|
||||
if (!last || Math.hypot(last[0] - car.x, last[1] - car.y) > 3) c.trail.push([car.x, car.y]);
|
||||
if (!moving(c)) { c.step = 'settle'; c.t = 0; }
|
||||
} else if (c.step === 'settle' && c.t >= REST) settle(c);
|
||||
else if (c.step === 'aim' && c.current === 'cpu') {
|
||||
if (!c.plan && c.t >= THINK * 0.3) cpuThink(c);
|
||||
if (c.plan && c.t >= THINK) strike(c, 'cpu', c.plan.angle, c.plan.power);
|
||||
}
|
||||
}
|
||||
|
||||
// --- Comandi del giocatore: gli stessi del biliardo (mira col mouse o col dito, si tiene premuto per la forza).
|
||||
export function aimAt(c, x, y) {
|
||||
if (!canThrow(c) || c.holding || !Number.isFinite(x) || !Number.isFinite(y)) return false;
|
||||
const car = c.cars.player;
|
||||
if (Math.hypot(x - car.x, y - car.y) < CAR.r) return false;
|
||||
c.angle = Math.atan2(y - car.y, x - car.x); return true;
|
||||
}
|
||||
export function aimScreen(c, [x, y]) {
|
||||
if (c.step === 'choose') { const i = carUnder(x, y); return i >= 0 && choose(c, i); }
|
||||
return x >= 0 && x <= 640 && y >= 24 && y <= 360 && aimAt(c, x, y);
|
||||
}
|
||||
export function nudge(c, dir, fine = false) {
|
||||
if (!canThrow(c) || c.holding || !Number.isFinite(dir)) return false;
|
||||
c.angle += dir * (fine ? 0.004 : 0.03); return true;
|
||||
}
|
||||
export function setPower(c, value) {
|
||||
if (!canThrow(c) || c.holding || !Number.isFinite(value)) return false;
|
||||
c.power = clamp(value, 0, 1); return true;
|
||||
}
|
||||
export function shoot(c) { return c.step === 'choose' ? pick(c) : canThrow(c) && !c.holding && strike(c, 'player', c.angle, c.power); }
|
||||
export function turn(c, dir, owner, fine = false) {
|
||||
if (c.step === 'choose') { choose(c, c.choice + dir); return false; } // nella scelta frecce e pulsanti cambiano macchinina
|
||||
if (!canThrow(c) || c.holding || c.turn) return false;
|
||||
c.turn = { dir, owner, fine, time: 0 }; c.angle += dir * (fine ? 0.004 : 0.03);
|
||||
c.aimLocked = true; return true;
|
||||
}
|
||||
export function stopTurn(c, owner) {
|
||||
if (c.turn?.owner !== owner) return false;
|
||||
c.turn = null; return true;
|
||||
}
|
||||
export function key(c, key, down, fine = false) {
|
||||
if (!['ArrowLeft', 'ArrowRight'].includes(key)) return false;
|
||||
if (down) { if (c.turn?.owner === key) c.turn.fine = fine; else turn(c, key === 'ArrowLeft' ? -1 : 1, key, fine); }
|
||||
else stopTurn(c, key);
|
||||
return true;
|
||||
}
|
||||
export function press(c, pointerId) {
|
||||
if (c.step === 'choose') return pick(c);
|
||||
if (!canThrow(c) || c.holding) return false;
|
||||
// Premuto, la forza parte da zero e sale finché non si lascia (Andrea, 29 ottobre): come il dito che si carica.
|
||||
c.turn = null; c.pointerId = pointerId; c.holdDelay = 0;
|
||||
c.previousPower = c.power; c.holding = true; c.charging = false; c.holdTime = 0; c.power = 0;
|
||||
return true;
|
||||
}
|
||||
export function cancel(c, pointerId) {
|
||||
if (pointerId !== undefined && c.pointerId !== pointerId) return false;
|
||||
c.turn = null; c.charging = false;
|
||||
if (!c.holding) return false;
|
||||
c.holding = false; c.power = c.previousPower; c.holdTime = 0; c.overHold = 0; return true;
|
||||
}
|
||||
export function release(c, pointerId) {
|
||||
if (c.pointerId !== pointerId || !c.holding) return false;
|
||||
if (c.holdTime < TAP) return cancel(c, pointerId); // il tocco secco mira soltanto
|
||||
const accompagne = (c.overHold ?? 0) > ACCOMPAGNA;
|
||||
c.holding = c.charging = false; c.overHold = 0;
|
||||
strike(c, 'player', c.angle, c.power);
|
||||
if (accompagne) c.cars.player.fault = 'accompagne';
|
||||
return true;
|
||||
}
|
||||
// Sta tenendo il dito oltre la carica piena: il disegno lo avvisa prima che diventi un accompagnè.
|
||||
export const overHeld = c => c.holding && (c.overHold ?? 0) > 0;
|
||||
|
||||
// La guida: dove si fermerebbe la macchinina, se nessuno la tocca, e se ci arriva restando in pista.
|
||||
export function guide(c) {
|
||||
const car = c.cars.player, length = reach(speedFor(c.power)), ux = Math.cos(c.angle), uy = Math.sin(c.angle);
|
||||
let idx = car.idx, out = false;
|
||||
for (let d = 0; d <= length; d += 2) {
|
||||
const p = project(c.track, car.x + ux * d, car.y + uy * d, idx);
|
||||
idx = p.i; if (isOut(p.d)) { out = true; break; }
|
||||
}
|
||||
return { x: car.x + ux * length, y: car.y + uy * length, length, out };
|
||||
}
|
||||
|
||||
// Il pulsante del pannello vale anche nella scelta della macchinina.
|
||||
export const canPress = c => canThrow(c) || c.step === 'choose';
|
||||
export const canAdjust = canPress;
|
||||
export function button(c) {
|
||||
if (c.step === 'choose') return 'Scegli';
|
||||
if (c.step === 'result') return 'Finita';
|
||||
if (c.step === 'rolling' || c.step === 'settle') return 'In movimento…';
|
||||
return c.current === 'cpu' ? 'Spinge il Chiaru…' : 'Spingi';
|
||||
}
|
||||
// Il perché del risultato, da scrivere (Andrea, 29 ottobre: «ho tagliato prima io, ma ha vinto il Chiaru»). Le
|
||||
// macchinine vere sono lunghe 4 centimetri e mezzo: un pixel è quasi due millimetri.
|
||||
export const CM = 4.5 / CAR.len;
|
||||
export function why(c) {
|
||||
const { winner, flicks, over } = c.result, n = flicks.player;
|
||||
if (over.player >= 0 && over.cpu >= 0) {
|
||||
const cm = Math.max(1, Math.round(Math.abs(over.player - over.cpu) * CM));
|
||||
if (winner === 'draw') return [`Tutti e due al traguardo alla spinta ${n},`, 'pari al millimetro.'];
|
||||
return [`Tutti e due al traguardo alla spinta ${n}:`, `vince chi va più in là, ${winner === 'player' ? 'Andrea' : 'il Chiaru'} di ${cm} ${cm === 1 ? 'centimetro' : 'centimetri'}.`];
|
||||
}
|
||||
return winner === 'player' ? [`Andrea al traguardo alla spinta ${n};`, 'al Chiaru non è bastata la sua.'] : [`Il Chiaru al traguardo alla spinta ${n};`, 'Andrea non c\'è arrivato.'];
|
||||
}
|
||||
// Chi è davanti adesso (1 o 2), per strada fatta.
|
||||
export const rank = (c, who) => c.cars[who].progress >= c.cars[OTHER[who]].progress ? 1 : 2;
|
||||
// Quanta pista manca al traguardo, in percentuale, per il tabellone.
|
||||
export const done = (c, who) => clamp(c.cars[who].progress / (c.laps * c.track.length), 0, 1);
|
||||
export function status(c) {
|
||||
if (c.step === 'choose') return `Scegli la macchinina: ${CARS[c.choice].name}. Tocca quella che vuoi, o frecce e Scegli.`;
|
||||
const where = `Andrea ${rank(c, 'player')}° (${Math.round(done(c, 'player') * 100)}%), Chiaru ${rank(c, 'cpu')}° (${Math.round(done(c, 'cpu') * 100)}%).`;
|
||||
if (c.step === 'result') return `${c.result.winner === 'player' ? 'Hai battuto il Chiaru!' : c.result.winner === 'cpu' ? 'Ha vinto il Chiaru.' : 'Arrivati pari.'} ${why(c).join(' ')}`;
|
||||
if (c.step === 'rolling' || c.step === 'settle') return `${where} ${c.line ?? ''}`.trim();
|
||||
if (c.current === 'cpu') return `${where} Spinge il Chiaru…`;
|
||||
return `${where} ${c.line ? c.line + ' ' : ''}Tocca a te: mira e spingi.`;
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import { drawRinquarto } from './rinquarto-render.js';
|
||||
import { drawBasket } from './basket-render.js';
|
||||
import { drawPesca } from './pesca-render.js';
|
||||
import { drawGara } from './gara-render.js';
|
||||
import { drawMicro } from './micro-render.js';
|
||||
import { drawCerbottana } from './cerbottana-render.js';
|
||||
import { drawBriscola } from './briscola-render.js';
|
||||
import { drawTressette } from './tressette-render.js';
|
||||
import { drawScopa } from './scopa-render.js';
|
||||
@@ -130,7 +132,7 @@ export function backgroundOrder(story, first) {
|
||||
for (const h of story.scenes[queue[i]]?.hotspots ?? [])
|
||||
if (h.exit && story.scenes[h.exit.scene] && !seen.has(h.exit.scene)) { seen.add(h.exit.scene); queue.push(h.exit.scene); }
|
||||
for (const id of Object.keys(story.scenes)) if (!seen.has(id)) queue.push(id);
|
||||
return [...new Set(queue.map(id => story.scenes[id].background).filter(Boolean))];
|
||||
return [...new Set(queue.flatMap(id => [story.scenes[id].background, ...(story.scenes[id].backdrops ?? []).map(b => b.src)]).filter(Boolean))];
|
||||
}
|
||||
|
||||
// Il personaggio alto PERSON pixel a grandezza 1 (per `size` 1), con i piedi in (x, y); rivolto a sinistra si specchia.
|
||||
@@ -152,8 +154,8 @@ function drawSprite(ctx, { atlas, img }, frame, x, y, scale, facing, size = 1) {
|
||||
}
|
||||
|
||||
export function render(ctx, game, { hover, spots, debug, time = performance.now() } = {}) {
|
||||
const scene = game.scene, s = game.state, bg = backgrounds.get(scene.background);
|
||||
if (!bg && scene.background) loadBackground(scene.background);
|
||||
const scene = game.scene, s = game.state, backdrop = game.backdrop(), bg = backgrounds.get(backdrop);
|
||||
if (!bg && backdrop) loadBackground(backdrop);
|
||||
ctx.imageSmoothingEnabled = false;
|
||||
ctx.clearRect(0, 0, WIDTH, HEIGHT);
|
||||
if (bg) ctx.drawImage(bg, 0, 0, WIDTH, HEIGHT);
|
||||
@@ -394,7 +396,7 @@ export const EFFECTS = {
|
||||
// Alberi al vento (i cipressi): il pezzo di sfondo si piega tutto insieme dalla base, di frazioni di pixel e con
|
||||
// due onde lente sovrapposte, così il movimento è morbido e non a scatti.
|
||||
sway(ctx, e, time, game) {
|
||||
const bg = backgrounds.get(game.scene.background);
|
||||
const bg = backgrounds.get(game.backdrop());
|
||||
if (!bg) return;
|
||||
const k = bg.width / WIDTH, amount = e.amount ?? 3.2;
|
||||
for (const [i, [x, y, w, h]] of e.rects.entries()) {
|
||||
@@ -411,7 +413,7 @@ export const EFFECTS = {
|
||||
// ognuna a una sua altezza e velocità, uscita da un lato rientra dall'altro. Si vedono solo dove lo sfondo è
|
||||
// cielo (skyMask): passano dietro alberi, torri e tetti. Le due grandi solo coi cieli larghi (`big`).
|
||||
clouds(ctx, e, time, game) {
|
||||
const bg = backgrounds.get(game.scene.background), mask = bg && skyMask(bg);
|
||||
const bg = backgrounds.get(game.backdrop()), mask = bg && skyMask(bg);
|
||||
if (!mask) return;
|
||||
const layer = scratch(), lc = layer.getContext('2d'), [ax, ay, aw, ah] = e.area;
|
||||
const pool = e.big ? CLOUDS : CLOUDS.slice(2);
|
||||
@@ -451,7 +453,7 @@ export const EFFECTS = {
|
||||
// Una bandiera dipinta nello sfondo che sventola: a strisce verticali che salgono e scendono, ferme dalla parte
|
||||
// dell'asta (`pole`: 'left' o 'right') e sempre più mosse verso il lembo libero.
|
||||
cloth(ctx, e, time, game) {
|
||||
const bg = backgrounds.get(game.scene.background);
|
||||
const bg = backgrounds.get(game.backdrop());
|
||||
if (!bg) return;
|
||||
const k = bg.width / WIDTH;
|
||||
for (const [i, [x, y, w, h]] of e.rects.entries()) {
|
||||
@@ -686,6 +688,16 @@ function drawCloseup(ctx, game, time) {
|
||||
drawBocce(ctx, c, def, backgrounds.get(def.picture), time);
|
||||
return;
|
||||
}
|
||||
if (def.type === 'cerbottana') {
|
||||
if (!backgrounds.has(def.picture)) loadBackground(def.picture);
|
||||
drawCerbottana(ctx, c, def, backgrounds.get(def.picture));
|
||||
return;
|
||||
}
|
||||
if (def.type === 'micro') {
|
||||
if (!backgrounds.has(def.picture)) loadBackground(def.picture);
|
||||
drawMicro(ctx, c, def, backgrounds.get(def.picture), src => { if (!backgrounds.has(src)) loadBackground(src); return backgrounds.get(src); });
|
||||
return;
|
||||
}
|
||||
if (def.type === 'gara') {
|
||||
if (def.picture && !backgrounds.has(def.picture)) loadBackground(def.picture);
|
||||
drawGara(ctx, c, def, def.picture ? backgrounds.get(def.picture) : null,
|
||||
|
||||
@@ -4,7 +4,7 @@ import { guide, canThrow, shooter } from './rinquarto.js';
|
||||
import { text, panel } from './bocce-render.js';
|
||||
|
||||
const sx = x => VIEW.x + x * VIEW.k, sy = y => VIEW.y + y * VIEW.k;
|
||||
const NAME = { andrea: 'Andrea', bertovo: 'Bertovo' };
|
||||
const NAME = { andrea: 'Andrea', bertovo: 'Trappizzio Berti' };
|
||||
// La traiettoria del tiro: resta sul tavolo finché non si va avanti, con le sponde numerate e il contatto che decide.
|
||||
function trail(ctx, c) {
|
||||
if (c.trail.length < 2) return;
|
||||
@@ -59,19 +59,19 @@ export function drawRinquarto(ctx, c, def, bg) {
|
||||
ctx.restore();
|
||||
// In alto: chi tira, il punteggio, le sponde; l'esito sta qui, così non copre il tavolo.
|
||||
ctx.fillStyle = '#17160ff0'; ctx.fillRect(54, 4, 532, 64);
|
||||
text(ctx, c.skill.training ? 'I RINQUARTI DI BERTOVO · ALLENAMENTO' : 'I RINQUARTI DI BERTOVO', 320, 13, 9, '#efd49e', 'center');
|
||||
const score = c.skill.training ? 'senza punti' : `Andrea ${c.score.andrea} Bertovo ${c.score.bertovo}`;
|
||||
text(ctx, c.skill.training ? 'I RINQUARTI DI TRAPPIZZIO BERTI · ALLENAMENTO' : 'I RINQUARTI DI TRAPPIZZIO BERTI', 320, 13, 9, '#efd49e', 'center');
|
||||
const score = c.skill.training ? 'senza punti' : `Andrea ${c.score.andrea} Trappizzio Berti ${c.score.bertovo}`;
|
||||
text(ctx, `Posizione ${c.position}/${c.skill.positions} ${score} Sponde ${c.attempt.cushions}/${c.skill.cushions}`, 320, 29, 9, '#fff0c8', 'center');
|
||||
const who = NAME[shooter(c)];
|
||||
const line = c.step === 'review' ? c.line : c.step === 'think' ? 'Tira Bertovo…' : c.step === 'rolling' ? `Tira ${who}…` : `Tocca ad ${who}: «Oh tirami questo rinquarto!?»`;
|
||||
const line = c.step === 'review' ? c.line : c.step === 'think' ? 'Tira Trappizzio Berti…' : c.step === 'rolling' ? `Tira ${who}…` : `Tocca ad ${who}: «Oh tirami questo rinquarto!?»`;
|
||||
text(ctx, line, 320, 45, 8, c.step === 'review' ? (c.attempt.point ? '#b9e5b3' : '#ffbf9f') : '#9fd0ff', 'center');
|
||||
if (c.step === 'review') text(ctx, c.last ? 'Tocca per il risultato' : 'Tocca o premi Prossima', 320, 59, 7, '#d9ccba', 'center');
|
||||
if (c.step === 'result') {
|
||||
const r = c.result, title = r.training ? 'ALLENAMENTO FINITO' : r.winner === 'player' ? 'HAI BATTUTO BERTOVO!' : r.winner === 'cpu' ? 'HA VINTO BERTOVO' : 'PARI';
|
||||
const r = c.result, title = r.training ? 'ALLENAMENTO FINITO' : r.winner === 'player' ? 'HAI BATTUTO TRAPPIZZIO BERTI!' : r.winner === 'cpu' ? 'HA VINTO TRAPPIZZIO BERTI' : 'PARI';
|
||||
panel(ctx, 155, 145, 330, 80);
|
||||
text(ctx, title, 320, 166, 12, r.winner === 'player' ? '#b9e5b3' : '#efd49e', 'center');
|
||||
if (!r.training) text(ctx, `Andrea ${r.points.andrea} · Bertovo ${r.points.bertovo}, su ${c.skill.positions} posizioni`, 320, 190, 8, '#efd49e', 'center');
|
||||
text(ctx, 'Torna da Bertovo per uscire.', 320, 210, 8, '#d9ccba', 'center');
|
||||
if (!r.training) text(ctx, `Andrea ${r.points.andrea} · Trappizzio Berti ${r.points.bertovo}, su ${c.skill.positions} posizioni`, 320, 190, 8, '#efd49e', 'center');
|
||||
text(ctx, 'Torna da Trappizzio Berti per uscire.', 320, 210, 8, '#d9ccba', 'center');
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// I rinquarti di Bertovo (Andrea, 28 ottobre; revisione di Codex): Bertovo mette le biglie in modo che la diretta sia
|
||||
// I rinquarti di Trappizzio Berti (Andrea, 28 ottobre; revisione di Codex): Trappizzio Berti mette le biglie in modo che la diretta sia
|
||||
// coperta, e si deve arrivare al bersaglio (la gialla) dopo almeno tante sponde senza toccare prima i disturbi.
|
||||
// Sulla stessa posizione tira prima Andrea, poi il tavolo torna com'era e tira Bertovo: un punto per ogni rinquarto
|
||||
// riuscito, sei posizioni, vince chi ne fa di più. Nell'allenamento tira prima Bertovo, per far vedere, e senza punti.
|
||||
// Sulla stessa posizione tira prima Andrea, poi il tavolo torna com'era e tira Trappizzio Berti: un punto per ogni rinquarto
|
||||
// riuscito, sei posizioni, vince chi ne fa di più. Nell'allenamento tira prima Trappizzio Berti, per far vedere, e senza punti.
|
||||
//
|
||||
// La forza è sempre piena: conta solo il primo contatto, quindi tirare piano non serve mai (revisione di Codex,
|
||||
// rilievo 5). Il gioco è un rompicapo di angoli.
|
||||
@@ -23,7 +23,7 @@ const SCAN = 720, STEP_ANGLE = Math.PI * 2 / SCAN, BUDGET = 15, THINK = 1.1;
|
||||
const ball = (role, x, y) => ({ role, x, y, vx: 0, vy: 0 });
|
||||
function random(c) { c.seed = (Math.imul(c.seed, 1664525) + 1013904223) >>> 0; return c.seed / 4294967296; }
|
||||
const gauss = c => Math.sqrt(-2 * Math.log(1 - random(c))) * Math.cos(2 * Math.PI * random(c));
|
||||
// z tale che una normale stia entro ±z con probabilità p: quanto deve essere stretto l'errore di Bertovo.
|
||||
// z tale che una normale stia entro ±z con probabilità p: quanto deve essere stretto l'errore di Trappizzio Berti.
|
||||
const zFor = p => p >= 1 ? Infinity : Math.sqrt(2) * erfinv(p);
|
||||
function erfinv(x) {
|
||||
const a = 0.147, l = Math.log(1 - x * x), t = 2 / (Math.PI * a) + l / 2;
|
||||
@@ -40,7 +40,7 @@ export const canPress = c => canThrow(c) || c.step === 'review';
|
||||
export const aimFree = c => !canThrow(c);
|
||||
export const setPower = () => false; // la forza è sempre piena
|
||||
export const button = c => c.step === 'review' ? (c.last ? 'Finita' : 'Prossima') : c.step === 'result' ? 'Finita'
|
||||
: c.step === 'think' ? 'Tira Bertovo…' : c.step === 'aim' ? 'Tira' : 'In movimento…';
|
||||
: c.step === 'think' ? 'Tira Trappizzio Berti…' : c.step === 'aim' ? 'Tira' : 'In movimento…';
|
||||
|
||||
// Conta solo le sponde della bianca prima del primo ostacolo; il primo contatto decide.
|
||||
function contact(result, required, { kind, a, b }) {
|
||||
@@ -141,7 +141,7 @@ function setTable(c) {
|
||||
c.shot = c.pending = c.visual.shot = null; c.windup = 0; c.trail = [];
|
||||
c.angle = Math.atan2(c.balls.cpu.y - c.balls.player.y, c.balls.cpu.x - c.balls.player.x);
|
||||
c.attempt = attempt();
|
||||
c.line = shooter(c) === 'andrea' ? 'Bertovo: «Oh tirami questo rinquarto!?»' : 'Tira Bertovo…';
|
||||
c.line = shooter(c) === 'andrea' ? 'Trappizzio Berti: «Oh tirami questo rinquarto!?»' : 'Tira Trappizzio Berti…';
|
||||
}
|
||||
function nextPosition(c) {
|
||||
while (!c.ready.length) { const p = generate(c, 4000); if (p) c.ready.push(p); }
|
||||
@@ -152,13 +152,13 @@ function nextPosition(c) {
|
||||
|
||||
export function newRinquarto(seed = Date.now() >>> 0, def = {}) {
|
||||
const level = LEVELS[def.level] ? def.level : 'seria';
|
||||
const c = { ...billiard.newBiliardo(seed), level, skill: LEVELS[level], position: 0, score: { andrea: 0, bertovo: 0 }, history: [],
|
||||
const c = { ...billiard.newBiliardo(seed, { maxSpeed: billiard.MAX_SPEED }), level, skill: LEVELS[level], position: 0, score: { andrea: 0, bertovo: 0 }, history: [],
|
||||
order: LEVELS[level].training ? ['bertovo', 'andrea'] : ['andrea', 'bertovo'], ready: [], gen: null, fixedPower: 1, trail: [], last: false };
|
||||
nextPosition(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
// Bertovo mira al centro della finestra buona, con un errore che dipende dal livello: dentro la finestra con la
|
||||
// Trappizzio Berti mira al centro della finestra buona, con un errore che dipende dal livello: dentro la finestra con la
|
||||
// probabilità `bertovo`. Il tiro poi si fa davvero: se sbaglia, sbaglia sul panno.
|
||||
export function bertovoPlan(c) {
|
||||
const half = c.solution.width / 2 * Math.PI / 180, z = zFor(c.skill.bertovo);
|
||||
@@ -206,7 +206,7 @@ export function update(c, dt) {
|
||||
const who = shooter(c);
|
||||
if (!c.skill.training) c.score[who] += Number(c.attempt.point);
|
||||
c.history.push({ position: c.position, who, ...c.attempt });
|
||||
c.line = `${who === 'andrea' ? 'Andrea' : 'Bertovo'}: ${c.attempt.point ? 'punto!' : `niente, ${c.attempt.reason}.`}`;
|
||||
c.line = `${who === 'andrea' ? 'Andrea' : 'Trappizzio Berti'}: ${c.attempt.point ? 'punto!' : `niente, ${c.attempt.reason}.`}`;
|
||||
c.step = 'review';
|
||||
c.last = c.round === c.order.length - 1 && c.position >= c.skill.positions;
|
||||
}
|
||||
@@ -226,14 +226,14 @@ export function guide(c) {
|
||||
|
||||
const need = c => c.skill.cushions === 1 ? 'Serve almeno 1 sponda.' : `Servono almeno ${c.skill.cushions} sponde.`;
|
||||
export function status(c) {
|
||||
const score = c.skill.training ? 'Allenamento, senza punti.' : `Andrea ${c.score.andrea}, Bertovo ${c.score.bertovo}.`;
|
||||
const score = c.skill.training ? 'Allenamento, senza punti.' : `Andrea ${c.score.andrea}, Trappizzio Berti ${c.score.bertovo}.`;
|
||||
const prefix = `Posizione ${c.position} di ${c.skill.positions}. ${score}`;
|
||||
if (c.step === 'result') {
|
||||
if (c.result.training) return 'Allenamento finito. Quando vuoi, la sfida vera.';
|
||||
return `${prefix} ${c.result.winner === 'player' ? 'Hai battuto Bertovo!' : c.result.winner === 'cpu' ? 'Ha vinto Bertovo.' : 'Pari.'}`;
|
||||
return `${prefix} ${c.result.winner === 'player' ? 'Hai battuto Trappizzio Berti!' : c.result.winner === 'cpu' ? 'Ha vinto Trappizzio Berti.' : 'Pari.'}`;
|
||||
}
|
||||
if (c.step === 'review') return `${prefix} ${c.line} ${c.last ? 'Tocca per il risultato.' : 'Tocca o premi Prossima.'}`;
|
||||
if (c.step === 'think') return `${prefix} Tira Bertovo…`;
|
||||
if (c.step === 'think') return `${prefix} Tira Trappizzio Berti…`;
|
||||
if (c.step === 'rolling') return `${prefix} Sponde: ${c.attempt.cushions}/${c.skill.cushions}.`;
|
||||
return `${prefix} ${c.line} ${need(c)}`;
|
||||
}
|
||||
|
||||
@@ -136,6 +136,17 @@ export class Soundscape {
|
||||
else if (kind === 'gara-sobbalzo') this.tone(160, 90, 0.1, 0.05, 0, pan);
|
||||
else if (kind === 'gara-giro') this.tone(660, 990, 0.15, 0.05, 0, pan);
|
||||
else if (kind === 'gara-arrivo') { this.tone(660, 660, 0.12, 0.06 * strength, 0, pan); this.tone(990, 990, 0.3, 0.06 * strength, 0.14, pan); }
|
||||
// La cerbottana: il soffio, il pallino che si schiaccia sul muro, la lattina, la tosse.
|
||||
else if (kind === 'cerbottana-pff') this.noiseSound(0.12, 2200, 0.05 + strength * 0.05, { pan });
|
||||
else if (kind === 'cerbottana-muro') { this.tone(180, 90, 0.06, 0.05, 0, pan); this.noiseSound(0.05, 600, 0.04, { pan }); }
|
||||
else if (kind === 'cerbottana-latta') { this.tone(2400, 1600, 0.08, 0.05 + strength * 0.04, 0, pan); this.tone(3400, 2600, 0.05, 0.03, 0.03, pan); }
|
||||
else if (kind === 'cerbottana-tosse') { this.noiseSound(0.18, 900, 0.08, { pan }); this.tone(260, 140, 0.12, 0.06, 0.25, pan); this.tone(240, 120, 0.1, 0.05, 0.3, pan); }
|
||||
// Le macchinine: il dito che spinge, le ruote sull'asfalto, l'urto di plastica, fuori pista, il traguardo.
|
||||
else if (kind === 'micro-spinta') { this.tone(1200, 500, 0.04, 0.04 + strength * 0.04, 0, pan); this.noiseSound(0.04, 2600, 0.04, { pan }); }
|
||||
else if (kind === 'micro-strisciata') this.noiseSound(0.3 + strength * 0.7, 900, 0.03 + strength * 0.04, { pan });
|
||||
else if (kind === 'micro-urto') { this.tone(3000, 1800, 0.03, 0.03 + strength * 0.06, 0, pan); this.noiseSound(0.03, 3600, 0.03, { pan }); }
|
||||
else if (kind === 'micro-fuori') { this.tone(420, 160, 0.25, 0.05, 0, pan); this.tone(300, 110, 0.3, 0.04, 0.12, pan); }
|
||||
else if (kind === 'micro-arrivo') { this.tone(660, 660, 0.12, 0.06 * strength, 0, pan); this.tone(990, 990, 0.3, 0.06 * strength, 0.14, pan); }
|
||||
// La pesca: il lancio, il tuffo del galleggiante, il tocco, l'abboccata, la ferrata, la lenza che tira, lo strappo, il pesce a riva.
|
||||
else if (kind === 'pesca-lancio') this.noiseSound(0.22, 1800, 0.05 + strength * 0.06, { pan });
|
||||
else if (kind === 'pesca-tuffo') { this.tone(420, 180, 0.07, 0.07, 0, pan); this.noiseSound(0.12, 900, 0.06, { pan }); }
|
||||
|
||||