Compare commits
2 Commits
819ee0a5c3
...
319436a5f9
| Author | SHA1 | Date | |
|---|---|---|---|
| 319436a5f9 | |||
| 7a69651b6d |
2
.gitignore
vendored
@@ -5,3 +5,5 @@ sprite-generator/output/
|
|||||||
sprite-generator/__pycache__/
|
sprite-generator/__pycache__/
|
||||||
node_modules/
|
node_modules/
|
||||||
*.log
|
*.log
|
||||||
|
tools/shots/
|
||||||
|
.claude/
|
||||||
|
|||||||
76
CLAUDE.md
@@ -14,29 +14,84 @@ keine Namen, Figuren, Arenen, Hausroboter, Grafiken, Sounds oder Code aus dem Or
|
|||||||
|
|
||||||
**Ablauf**
|
**Ablauf**
|
||||||
1. **Werkstatt:** Roboter aus Teilen bauen – je 1 Chassis, Motor, Räder, Batterie (Pflicht), dazu Panzerung,
|
1. **Werkstatt:** Roboter aus Teilen bauen – je 1 Chassis, Motor, Räder, Batterie (Pflicht), dazu Panzerung,
|
||||||
Hauptwaffe (Keil, Flipper, Axt, Säge, Zange, Spinner) und Turm (Flammen, Minigun, Raketen). Max. 100 kg,
|
Hauptwaffe, Turm und Gadget. Stand: 10 Chassis (Formen box/wedge/dome/frame/hex/barrel/arrow/plow/saucer),
|
||||||
|
13 Waffen (Keil, Lanze, Flipper, Schaufel-Heber, Axt, Morgenstern, Säge, Bohrer, Zange, Bar-/Walzen-/
|
||||||
|
Vertikal-Spinner, Schleuder), 7 Räder, 7 Panzerungen (jede mit eigener Optik: Gitter, Platten, Gummipuffer,
|
||||||
|
Stacheln, Kacheln – `style` in parts.js, Zweig in render3d), 3 Türme, 5 Gadgets; jedes Teil zeigt im Detail seinen Hotkey und
|
||||||
|
führt seine Bewegung in der Werkstatt-Vorschau vor. Max. 100 kg,
|
||||||
Batterie muss den Strom liefern. Kaufen / einbauen / verkaufen (50 %), Lack + Akzentfarbe, Name.
|
Batterie muss den Strom liefern. Kaufen / einbauen / verkaufen (50 %), Lack + Akzentfarbe, Name.
|
||||||
2. **Liga:** 8 KI-Gegner nacheinander (Stile: Raufbold, Flankierer, Schieber, Schütze), steigende Preise.
|
2. **Liga:** 8 KI-Gegner nacheinander (Stile: Raufbold, Flankierer, Schieber, Schütze), steigende Preise.
|
||||||
3. **Kampf (2 min, isometrisch 3D):** Arena mit Stachelwänden, 2 Bodensägen, 2 Flammengittern, 2 Arena-Wächtern
|
**Kampfschaden:** Teile reißen bei festen LP-Anteilen ab (Panzer 60 %, Rad 40 %, Hauptwaffe 25 %, Turm 18 % –
|
||||||
in den Ecken (Schmiedepresse, Magnetkran) und einer Grube, die zur Halbzeit aufgeht.
|
deterministisch, `BREAK_AT` in combat.js). Das Teil verlässt das 3D-Modell und poltert über den Boden
|
||||||
|
(`breakPart`/`dropPiece`), wirkt sich aus (Rad: langsamer; Panzer: weniger Schutz; Waffe/Turm: tot) und steht
|
||||||
|
live im HUD (LP-Zahlen + durchgestrichene Teil-Symbole je Roboter, rote Bildschirmkante unter 30 %).
|
||||||
|
**Türme feuern geradeaus** (kein Auto-Zielen) – gezielt wird, indem man den Roboter dreht.
|
||||||
|
|
||||||
|
3. **Kampf (2 min, isometrisch 3D):** 6 Arenen, jede mit eigener Grundform und eigenem Markenzeichen
|
||||||
|
(`RC.ARENAS` in combat.js). `shape`: `square` | `octagon` | `round`; die Wandkollision läuft über
|
||||||
|
`RC.wallPush(A, x, z, rad)` (liefert Normale → Abprall und Stachelschaden), **Achtung:** bei round/octagon
|
||||||
|
müssen Presse und Kran nach innen versetzt werden, sonst stehen sie außerhalb der Wand.
|
||||||
|
Arena-Felder: `blocks` (Deckung: pillar/crate/scrap/barrier – Geschosse detonieren daran, Strahlwaffen gehen
|
||||||
|
hindurch), `belts` (Förderband zieht mit), `oil` (Pfütze: weniger Grip, träge Lenkung über `r.onOil`),
|
||||||
|
`rams` (Wandramme stößt im Takt zu). Dazu wie gehabt Stachelwände, Bodensägen, Flammengitter, 2 Wächter
|
||||||
|
(Schmiedepresse, Magnetkran) und eine Grube ab Halbzeit (Mega-Dome früher, `pitOpensAt`).
|
||||||
|
Workshop 8 ▪ Scrapyard 10 (Wrackberge + Öl) ▪ Foundry 12 achteckig (Band) ▪ Crucible 14 rund (Säule + Rammen)
|
||||||
|
▪ Mega-Dome 16 achteckig (4 Säulen) ▪ Colosseum 20 rund (Mittelblock + Bänder zur Grube).
|
||||||
|
Liga skaliert die Arena mit dem Gegner, Einstellung `arena` (Zufällig/fest), online aus dem Seed.
|
||||||
|
Kamera + Licht + Boden skalieren mit `half`. Harte Rammstöße und Wandtreffer können Roboter auf den
|
||||||
|
Rücken schleudern (`flipped`).
|
||||||
4. **Sieg:** K.o., Gegner in der Grube, oder nach Zeit über Schaden (Fallen-Schaden zählt für den Gegner).
|
4. **Sieg:** K.o., Gegner in der Grube, oder nach Zeit über Schaden (Fallen-Schaden zählt für den Gegner).
|
||||||
5. **Ergebnis:** Preisgeld (+ K.o./Gruben-Bonus) bzw. Antrittsgeld, Reparaturkosten, Ruhm → zurück in die Werkstatt.
|
5. **Ergebnis:** Preisgeld (+ K.o./Gruben-Bonus) bzw. Antrittsgeld (35 %), Schadensbonus (0,6 Credits je Schaden,
|
||||||
|
auch bei Niederlage), Reparatur (6 % Teilewert × Schaden), Ruhm → zurück in die Werkstatt. Start: 800 Credits.
|
||||||
|
6. **Schaukampf:** besiegte Gegner beliebig oft nochmal – halbes Preisgeld, kein Liga-Fortschritt (Geld verdienen).
|
||||||
|
|
||||||
**Ziel / Ende:** Meister der Saison (alle 8 besiegt) → neue Saison, Gegner stärker, Preise ×1,5. Ruhm = Punktestand
|
**Ziel / Ende:** Meister der Saison (alle 8 besiegt) → neue Saison, Gegner stärker, Preise ×1,5. Ruhm = Punktestand
|
||||||
(Online-Rangliste über `Kit.scores`, sobald `DB_URL` gesetzt ist).
|
(Online-Rangliste über `Kit.scores`, sobald `DB_URL` gesetzt ist).
|
||||||
|
|
||||||
**Steuerung:** WASD/Pfeile Panzersteuerung, Leertaste Hauptwaffe, Shift/E Turm, P/Esc Pause, M Ton; Gamepad
|
**Steuerung:** Standard „Panzer“ (W/S fahren, A/D drehen; Michael wollte das ausdrücklich zurück). Option „Einfach“: WASD = Bildschirmrichtung, Roboter dreht sich selbst hin
|
||||||
|
– liegt das Ziel hinter dem Roboter, fährt er rückwärts statt zu wenden.
|
||||||
|
Kamera (Taste C / Einstellung): Standard Cockpit (Ego-Sicht, Wunsch Michael) · Arena (iso) · Verfolger – in Verfolger/Cockpit gilt W/S fahren, A/D drehen,
|
||||||
|
dazu Minikarte unten rechts. Waffen-Hilfe (Standard an) feuert in Reichweite automatisch. Schwierigkeit
|
||||||
|
Leicht (Standard: Spieler-LP ×1,4, KI −0,2) / Normal / Schwer (`DIFF` in game.js). Leertaste Hauptwaffe, Shift/E Turm, P/Esc Pause, M Ton; Gamepad
|
||||||
(Stick, A Waffe, B Turm, Start Pause); Touch-Knöpfe auf Touchgeräten.
|
(Stick, A Waffe, B Turm, Start Pause); Touch-Knöpfe auf Touchgeräten.
|
||||||
|
|
||||||
**Stil:** Industrielle Show-Arena bei Nacht, Flutlicht, kantige Bastel-Roboter aus Blech, Funken, Warnstreifen.
|
**Stil:** Industrielle Show-Arena bei Nacht, Flutlicht, kantige Bastel-Roboter aus Blech, Funken, Warnstreifen.
|
||||||
Akzent `#FF7A1A`, Überschriften „Russo One“ (Fallback Segoe UI Black). Grafik derzeit komplett prozedural (three.js).
|
Akzent `#FF7A1A`, Überschriften „Russo One“ – die Schrift liegt **lokal** in `game/assets/Fonts/RussoOne-Regular.ttf`
|
||||||
|
(SIL OFL 1.1, `@font-face` in `index.html`, wird in die Release-HTML eingebettet); Fallback Segoe UI Black.
|
||||||
|
**Vollbild-Look:** die HUD-Leiste liegt *in* der Bühne (`#hud` in `#stage`, `z-index 7`), kein Rahmen ums Spielfeld;
|
||||||
|
was sie zeigt, steuert `body[data-mode=…]` (Titel: aus · Kampf: nur ⏸ und Ton). Gemeinsame CSS-Tokens in `:root`
|
||||||
|
(`--steel`, `--sheen`, `--hl`, `--chamfer`, `--hazard`) – neue UI damit bauen, nicht mit Einzelwerten.
|
||||||
|
Tap-Ziele ≥ 34 px, Hauptknöpfe ≥ 42 px, Hover nur in `@media (hover: hover)`, kein `backdrop-filter` (CPU).
|
||||||
|
**Keine Scrollbalken:** jede Ansicht muss in die Bühne passen (Spaltenzahl/Größen anpassen statt scrollen);
|
||||||
|
die Balken sind global ausgeblendet, `overflow:auto` bleibt nur als Notnetz für dynamische Listen (Lobby).
|
||||||
|
Grafik sonst prozedural (three.js).
|
||||||
Stilblock für ComfyGen: *isometric 3/4 view game sprite, chunky handmade combat robot, scratched painted steel,
|
Stilblock für ComfyGen: *isometric 3/4 view game sprite, chunky handmade combat robot, scratched painted steel,
|
||||||
bolts and hazard stripes, bold clean shapes, soft studio lighting, high detail, plain solid black background*
|
bolts and hazard stripes, bold clean shapes, soft studio lighting, high detail, plain solid black background*
|
||||||
|
|
||||||
**Erste Version (drin):** Werkstatt mit 25 Teilen in 7 Slots, 1 Arena, 8 Liga-Gegner + Training, Saisons,
|
**Erste Version (drin):** Werkstatt mit 25 Teilen in 7 Slots, 1 Arena, 8 Liga-Gegner + Training, Saisons,
|
||||||
Speichern, en/de, Synth-Sounds. **Später:** Firebase-Rangliste (URL von Michael), asynchrones PvP (hochgeladene
|
Speichern, en/de, Synth-Sounds. **Später:** Firebase-Rangliste (URL von Michael), asynchrones PvP (hochgeladene
|
||||||
Roboter, KI-gesteuert), echtes PvP (WebRTC), Replays/Zuschauer, weitere Arenen + Gewichtsklassen, Icon/Musik/SFX
|
Roboter, KI-gesteuert), echtes PvP (WebRTC), Replays/Zuschauer, weitere Arenen + Gewichtsklassen, Icon/Musik/SFX
|
||||||
über ComfyGen, Schrift „Russo One“ lokal in `assets/Fonts`.
|
über ComfyGen. Titel-Logo `assets/Sprites/logo.png` (Prompt `logo` in `sprite-generator/prompts.py`,
|
||||||
|
`gen adopt --wide --size 1024 logo`) – fehlt es, zeigt der Titel den Schriftzug; ComfyUI muss dafür laufen.
|
||||||
|
|
||||||
|
**Online-Technik:** Der Host rechnet und sendet Snapshots – er schreibt **nur einen** Request gleichzeitig
|
||||||
|
(`sending`-Sperre in netfight.js) und drosselt bei langsamer Leitung, sonst stapeln sich die Uploads und *beim
|
||||||
|
Host* ruckelt es, während der Gast flüssig bleibt. Zahlen werden auf 3 Nachkommastellen gerundet (Paketgröße).
|
||||||
|
Rangliste: `Kit.scores.top()` zeigt **jeden Spieler nur einmal** (bester Lauf) – jeder Eintrag ist eine eigene
|
||||||
|
Zeile in der DB, die Entdopplung passiert beim Lesen (Fix liegt in `_Tools\Library\web\kit\kit-scores.js`).
|
||||||
|
|
||||||
|
**Online (Firebase, optional):** Titel → „Online spielen" (nur wenn `NET_CFG.apiKey` gesetzt), Login per
|
||||||
|
E-Mail/Passwort, globale Lobby (alle Online-Spieler + Länderflagge), Klick auf Spieler = Herausfordern → Live-Kampf.
|
||||||
|
Rangliste läuft schon mit `DB_URL` allein. Einrichtung + Grenzen: `docs/firebase/README.md`.
|
||||||
|
|
||||||
|
**Performance:** Render ist auf ~60 fps gedeckelt (Menüs ~16 fps), Pixel-Ratio-Deckel hoch 1,5 / mittel 1,25 /
|
||||||
|
niedrig 1,0, Schatten-Map 1024 (soft nur bei Hoch), `powerPreference high-performance`. Standard-Grafik „Mittel“.
|
||||||
|
Dev: `?fps` zeigt die effektive Bildrate. Logik (`Kit.loop update`) bleibt fix 60 Hz.
|
||||||
|
|
||||||
|
**Verschleierung:** `.\build.ps1 -Web -Obfuscate` jagt die eigenen Skripte durch terser (lokal via `npm install`).
|
||||||
|
Client bleibt grundsätzlich lesbar – nur erschwert, kein Kopierschutz.
|
||||||
|
|
||||||
|
**Tablet:** Touch-Steuerung (#pad), große Tap-Ziele; bei jeder neuen UI mitdenken.
|
||||||
|
|
||||||
## Dateien
|
## Dateien
|
||||||
|
|
||||||
@@ -44,16 +99,21 @@ Roboter, KI-gesteuert), echtes PvP (WebRTC), Replays/Zuschauer, weitere Arenen +
|
|||||||
Siegregeln · `game/ai.js` KI + Liga-Kader – alle ohne DOM, laufen in Node.
|
Siegregeln · `game/ai.js` KI + Liga-Kader – alle ohne DOM, laufen in Node.
|
||||||
- `game/render3d.js` three.js-Szenen (Werkstatt, Arena), Roboter-Modelle aus Teilen, Partikel.
|
- `game/render3d.js` three.js-Szenen (Werkstatt, Arena), Roboter-Modelle aus Teilen, Partikel.
|
||||||
- `game/shop.js` Werkstatt-Shop (Kategorien, Teile-Karten mit Sprites, Detail mit Vergleich, Mechaniker-Tipps)
|
- `game/shop.js` Werkstatt-Shop (Kategorien, Teile-Karten mit Sprites, Detail mit Vergleich, Mechaniker-Tipps)
|
||||||
|
· `game/net.js` Firebase über REST (Auth + RTDB + Server-Sent-Events, kein SDK) · `game/lobby.js` globale Lobby (Präsenz/Heartbeat, Herausfordern, Match) · `game/netfight.js` Live-PvP-Sync (Host rechnet + sendet Snapshots ~15/s, Gast interpoliert, KI-Übernahme bei Lag)
|
||||||
· `game/painter.js` Lackiererei: selbst auf den Roboter malen (Ebene 512×256: links Draufsicht, rechts Seite,
|
· `game/painter.js` Lackiererei: selbst auf den Roboter malen (Ebene 512×256: links Draufsicht, rechts Seite,
|
||||||
Front jeweils rechts), 3D-Vorschau live; gespeichert als PNG-Data-URL in `save.paint.decal`
|
Front jeweils rechts), 3D-Vorschau live; gespeichert als PNG-Data-URL in `save.paint.decal`
|
||||||
|
· `game/looks.js` Aussehen der Liga-Gegner passend zu ihren Porträts (Skin-Muster + Augen, Kabine, Höcker, Ketten-Optik)
|
||||||
· `game/profiles.js` Konten (v1 lokal: Name + Passwort-Hash, je Konto eigener Spielstand; später Firebase)
|
· `game/profiles.js` Konten (v1 lokal: Name + Passwort-Hash, je Konto eigener Spielstand; später Firebase)
|
||||||
· `game/game.js` Ablauf: Intro (3D-Kamerafahrt) → Titel → Login/Registrieren/Gast → Shop → Liga/VS → Kampf → Ergebnis, Einstellungen.
|
· `game/game.js` Ablauf: Intro (3D-Kamerafahrt) → Titel → Login/Registrieren/Gast → Shop → Liga/VS → Kampf → Ergebnis, Einstellungen.
|
||||||
- `game/vendor/three.min.js` three.js r149 (MIT, letzte Version mit klassischem Build – nicht auf ES-Module updaten).
|
- `game/vendor/three.min.js` three.js r149 (MIT, letzte Version mit klassischem Build – nicht auf ES-Module updaten).
|
||||||
- Tests: `node tests/sim.test.js` (Regeln, Kämpfe ohne NaN, Grube), `node tests/balance.js [-v]` (Zahlen).
|
- Tests: `node tests/sim.test.js` (Regeln, Kämpfe ohne NaN, Grube), `node tests/balance.js [-v]` (Zahlen).
|
||||||
- Grafik/Sound: `sprite-generator/prompts.py` + `audio.py` → `gen generate`, `gen adopt --all` (Sprites), `gen adopt_scene bg_*` (Hintergründe als JPG),
|
- Grafik/Sound: `sprite-generator/prompts.py` + `audio.py` → `gen generate`, `gen adopt --all` (Sprites), `gen adopt_scene bg_*` (Hintergründe als JPG),
|
||||||
`gen make_tileable tex_floor`, `gen adopt_audio --all`. Fehlende Bilder → Ersatz-Symbol (`RC.pic`), fehlende Sounds → Synth.
|
`gen make_tileable tex_floor`, `gen adopt_audio --all`. Fehlende Bilder → Ersatz-Symbol (`RC.pic`), fehlende Sounds → Synth.
|
||||||
|
- `game/uicheck.js` Layout-Selbsttest: `&uicheck` misst Scrollen, Überläufe, Überlappungen, zu kleine Tap-Ziele,
|
||||||
|
abgeschnittene Texte und ob die Schrift geladen ist – Ergebnis als Text in `<pre id="uicheck">` + `document.title`
|
||||||
|
(so per `chrome --headless --dump-dom` auslesbar, **ohne Screenshot**). Nach jeder UI-Änderung laufen lassen.
|
||||||
- Dev-Parameter: `index.html?title` (Titel ohne Intro), `?play` (Shop als Gast), `?fight=N` (Training gegen Liga-Gegner N), `&auto` (KI fährt
|
- Dev-Parameter: `index.html?title` (Titel ohne Intro), `?play` (Shop als Gast), `?fight=N` (Training gegen Liga-Gegner N), `&auto` (KI fährt
|
||||||
für dich), `&ff=30` (30 s vorspulen).
|
für dich), `&ff=30` (30 s vorspulen), `&cam=chase|fpv` (Kamera), `&uicheck` (Layout-Prüfung), `&touch` (Touch-Pad am PC zeigen).
|
||||||
|
|
||||||
## Arbeitsweise
|
## Arbeitsweise
|
||||||
|
|
||||||
|
|||||||
21
README.md
@@ -12,7 +12,8 @@ Angelegt am 2026-11-13 aus `_Tools\Library` (Vorlage `webgame`). Sprachen: Engli
|
|||||||
|
|
||||||
| Taste | Wirkung |
|
| Taste | Wirkung |
|
||||||
|---|---|
|
|---|---|
|
||||||
| W A S D / Pfeile | fahren (Panzersteuerung) |
|
| W A S D / Pfeile | fahren (Einfach: Bildschirmrichtung · Panzer / Verfolger / Cockpit: W/S fahren, A/D drehen) |
|
||||||
|
| C | Kamera: Arena · Verfolger · Cockpit |
|
||||||
| Leertaste | Hauptwaffe (Säge/Spinner: halten) |
|
| Leertaste | Hauptwaffe (Säge/Spinner: halten) |
|
||||||
| Shift / E | Turmwaffe |
|
| Shift / E | Turmwaffe |
|
||||||
| P / Esc | Pause |
|
| P / Esc | Pause |
|
||||||
@@ -20,7 +21,7 @@ Angelegt am 2026-11-13 aus `_Tools\Library` (Vorlage `webgame`). Sprachen: Engli
|
|||||||
| Gamepad | Stick fahren, A Waffe, B Turm, Start Pause |
|
| Gamepad | Stick fahren, A Waffe, B Turm, Start Pause |
|
||||||
|
|
||||||
Dev-Parameter: `index.html?title` (Titel ohne Intro), `?play` (direkt in den Shop, als Gast), `?play&paint` (Lackiererei mit Testbild), `?fight=N` (Training gegen Liga-Gegner N = 0…7),
|
Dev-Parameter: `index.html?title` (Titel ohne Intro), `?play` (direkt in den Shop, als Gast), `?play&paint` (Lackiererei mit Testbild), `?fight=N` (Training gegen Liga-Gegner N = 0…7),
|
||||||
`&auto` (KI fährt deinen Roboter), `&ff=30` (30 Sekunden vorspulen).
|
`&auto` (KI fährt deinen Roboter), `&ff=30` (30 Sekunden vorspulen), `&cam=chase|fpv` (Kamera).
|
||||||
|
|
||||||
Tests (Node, ohne Browser): `node tests/sim.test.js` · Balance-Zahlen: `node tests/balance.js -v`
|
Tests (Node, ohne Browser): `node tests/sim.test.js` · Balance-Zahlen: `node tests/balance.js -v`
|
||||||
|
|
||||||
@@ -31,7 +32,11 @@ game/
|
|||||||
index.html Seite, HUD, Werkstatt-Panel, Overlays (Styles inline)
|
index.html Seite, HUD, Werkstatt-Panel, Overlays (Styles inline)
|
||||||
game.js Ablauf: Intro, Titel, Konten, Einstellungen, Shop, Liga, Kampf, Ergebnis
|
game.js Ablauf: Intro, Titel, Konten, Einstellungen, Shop, Liga, Kampf, Ergebnis
|
||||||
shop.js Werkstatt-Shop (Teile kaufen/einbauen/verkaufen, Vergleich, Lack, Mechaniker)
|
shop.js Werkstatt-Shop (Teile kaufen/einbauen/verkaufen, Vergleich, Lack, Mechaniker)
|
||||||
|
looks.js Aussehen der Liga-Gegner (wie ihre Porträts)
|
||||||
painter.js Lackiererei: selbst auf den Roboter malen, live in 3D
|
painter.js Lackiererei: selbst auf den Roboter malen, live in 3D
|
||||||
|
net.js Firebase über REST (Login, Datenbank, Push) – für Online
|
||||||
|
lobby.js globale Online-Lobby (wer ist da, herausfordern)
|
||||||
|
netfight.js Live-PvP-Synchronisation
|
||||||
profiles.js Konten: registrieren, einloggen, Gast (lokal, später Firebase)
|
profiles.js Konten: registrieren, einloggen, Gast (lokal, später Firebase)
|
||||||
parts.js Teilekatalog (Werte, Preise) ┐
|
parts.js Teilekatalog (Werte, Preise) ┐
|
||||||
robot.js Bauregeln + Kampfwerte aus Teilen │ ohne DOM,
|
robot.js Bauregeln + Kampfwerte aus Teilen │ ohne DOM,
|
||||||
@@ -51,11 +56,17 @@ build-web.mjs → release/robotclash.html (alles in einer Datei)
|
|||||||
build.ps1 → release/RobotClash.exe + robotclash.html + robotclash-web.zip
|
build.ps1 → release/RobotClash.exe + robotclash.html + robotclash-web.zip
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Online (optional)
|
||||||
|
|
||||||
|
Rangliste läuft mit der Firebase-DB-URL allein. Für die Lobby + Live-PvP den Web-API-Key in
|
||||||
|
`game/game.js` (`NET_CFG.apiKey`) eintragen – Anleitung `docs/firebase/README.md`.
|
||||||
|
|
||||||
## Release
|
## Release
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
.\build.ps1 # exe + html + zip
|
.\build.ps1 # exe + html + zip
|
||||||
.\build.ps1 -Web # nur html + zip
|
.\build.ps1 -Web # nur html + zip
|
||||||
|
.\build.ps1 -Web -Obfuscate # zusätzlich Skripte verschleiern (braucht einmal: npm install)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Kit aktualisieren
|
## Kit aktualisieren
|
||||||
@@ -68,5 +79,7 @@ D:\Oculusquest\Projekt\_Tools\Library\new-project.ps1 -UpdateKit -Path .
|
|||||||
|
|
||||||
## Lizenzen
|
## Lizenzen
|
||||||
|
|
||||||
three.js © three.js authors, MIT-Lizenz (`game/vendor/three.min.js`). Eigenes Spiel – keine Inhalte aus
|
three.js © three.js authors, MIT-Lizenz (`game/vendor/three.min.js`).
|
||||||
|
Schrift „Russo One" © 2011–2012 Jovanny Lemonad, SIL Open Font License 1.1
|
||||||
|
(`game/assets/Fonts/RussoOne-Regular.ttf`, Lizenztext daneben in `OFL.txt`). Eigenes Spiel – keine Inhalte aus
|
||||||
Robot Rage / Robot Kampen oder deren Ports.
|
Robot Rage / Robot Kampen oder deren Ports.
|
||||||
|
|||||||
@@ -39,8 +39,28 @@ const safe = s => s.replace(/<\/script/gi, '<\\/script');
|
|||||||
|
|
||||||
html = html.replace(/<link\s+rel="stylesheet"\s+href="([^"]+)"\s*\/?>/g, (m, p) =>
|
html = html.replace(/<link\s+rel="stylesheet"\s+href="([^"]+)"\s*\/?>/g, (m, p) =>
|
||||||
local(p) ? `<style>\n${fs.readFileSync(path.join(game, p), 'utf8')}\n</style>` : m);
|
local(p) ? `<style>\n${fs.readFileSync(path.join(game, p), 'utf8')}\n</style>` : m);
|
||||||
html = html.replace(/<script\s+src="([^"]+)"\s*><\/script>/g, (m, p) =>
|
// optional: run each own script through terser (mangle locals, compress) -> harder to read.
|
||||||
local(p) ? `<script>\n${safe(fs.readFileSync(path.join(game, p), 'utf8'))}\n</script>` : m);
|
// Enabled with RC_OBFUSCATE=1 (build.ps1 -Obfuscate). vendor/three.min.js is already minified -> skip.
|
||||||
|
const obf = process.env.RC_OBFUSCATE === '1';
|
||||||
|
let terser = null;
|
||||||
|
if (obf) {
|
||||||
|
try { terser = await import('terser'); }
|
||||||
|
catch { console.error('RC_OBFUSCATE=1 but terser is missing - run: npm install'); process.exit(1); }
|
||||||
|
}
|
||||||
|
const minify = async (code, name) => {
|
||||||
|
if (!terser || /vendor\/three/.test(name)) return code;
|
||||||
|
const r = await terser.minify(code, { compress: true, mangle: true, format: { comments: false } });
|
||||||
|
if (r.error) { console.error(`terser failed on ${name}:`, r.error); process.exit(1); }
|
||||||
|
return r.code;
|
||||||
|
};
|
||||||
|
const scriptJobs = [];
|
||||||
|
html = html.replace(/<script\s+src="([^"]+)"\s*><\/script>/g, (m, p) => {
|
||||||
|
if (!local(p)) return m;
|
||||||
|
const token = `\u0000SCRIPT${scriptJobs.length}\u0000`;
|
||||||
|
scriptJobs.push(minify(fs.readFileSync(path.join(game, p), 'utf8'), p).then(code => [token, `<script>\n${safe(code)}\n</script>`]));
|
||||||
|
return token;
|
||||||
|
});
|
||||||
|
for (const [token, tag] of await Promise.all(scriptJobs)) html = html.replace(token, () => tag);
|
||||||
// static references in CSS / HTML attributes
|
// static references in CSS / HTML attributes
|
||||||
html = html.replace(/url\((['"]?)(assets\/[^'")]+)\1\)/g, (m, q, p) => (assets[p] ? `url('${assets[p]}')` : m));
|
html = html.replace(/url\((['"]?)(assets\/[^'")]+)\1\)/g, (m, q, p) => (assets[p] ? `url('${assets[p]}')` : m));
|
||||||
html = html.replace(/(src|href)="(assets\/[^"]+)"/g, (m, a, p) => (assets[p] ? `${a}="${assets[p]}"` : m));
|
html = html.replace(/(src|href)="(assets\/[^"]+)"/g, (m, a, p) => (assets[p] ? `${a}="${assets[p]}"` : m));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# robotclash-web.zip upload package for itch.io & co (the page as index.html)
|
# robotclash-web.zip upload package for itch.io & co (the page as index.html)
|
||||||
# Needs .NET 8+ SDK and Node. The PC running the exe needs the Edge WebView2 Runtime (Win 10/11 has it).
|
# Needs .NET 8+ SDK and Node. The PC running the exe needs the Edge WebView2 Runtime (Win 10/11 has it).
|
||||||
# .\build.ps1 all .\build.ps1 -Web only HTML + zip .\build.ps1 -Exe only exe
|
# .\build.ps1 all .\build.ps1 -Web only HTML + zip .\build.ps1 -Exe only exe
|
||||||
param([switch]$Web, [switch]$Exe)
|
param([switch]$Web, [switch]$Exe, [switch]$Obfuscate)
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$root = $PSScriptRoot
|
$root = $PSScriptRoot
|
||||||
$out = Join-Path $root 'release'
|
$out = Join-Path $root 'release'
|
||||||
@@ -29,6 +29,8 @@ if ($Exe) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($Web) {
|
if ($Web) {
|
||||||
|
# -Obfuscate: minify/mangle own scripts in the single-file HTML (needs `npm install`, terser)
|
||||||
|
$env:RC_OBFUSCATE = if ($Obfuscate) { '1' } else { '0' }
|
||||||
node (Join-Path $root 'build-web.mjs')
|
node (Join-Path $root 'build-web.mjs')
|
||||||
if ($LASTEXITCODE -ne 0) { throw "web build failed ($LASTEXITCODE)" }
|
if ($LASTEXITCODE -ne 0) { throw "web build failed ($LASTEXITCODE)" }
|
||||||
$tmp = Join-Path $env:TEMP 'robotclash-web'
|
$tmp = Join-Path $env:TEMP 'robotclash-web'
|
||||||
|
|||||||
@@ -1,26 +1,36 @@
|
|||||||
# Online-Highscores (Firebase Realtime Database)
|
# Firebase: Rangliste + Online-Lobby (ohne SDK, reines REST)
|
||||||
|
|
||||||
Das Spiel spricht die Datenbank über die REST-API an (`game/kit/kit-scores.js`), ohne SDK und ohne Login.
|
Das Spiel spricht Firebase komplett über REST an (`game/net.js`, `game/kit/kit-scores.js`) – kein SDK,
|
||||||
Solange `DB_URL` in `game/game.js` leer ist, läuft alles offline (keine Namenseingabe, keine Liste).
|
läuft per `file://` und als eine HTML-Datei.
|
||||||
|
|
||||||
## Einrichten (einmal, ~5 Minuten)
|
- **Rangliste** braucht nur die DB-URL (`DB_URL` in `game/game.js`), **kein Login**.
|
||||||
|
- **Online-Lobby + Live-PvP** braucht zusätzlich den **Web-API-Key** (`NET_CFG.apiKey`) und aktivierte
|
||||||
|
Anmeldung. Ohne Key bleibt der „Online spielen"-Knopf aus; der Rest funktioniert.
|
||||||
|
|
||||||
1. [Firebase-Konsole](https://console.firebase.google.com/) → **Projekt hinzufügen** (Name z. B. `robotclash`, Analytics aus).
|
## Einrichten
|
||||||
2. **Build → Realtime Database → Datenbank erstellen** → Standort **europe-west1** → „Im gesperrten Modus starten“.
|
|
||||||
3. Tab **Regeln**: alles durch den Inhalt von `database.rules.json` ersetzen → **Veröffentlichen**.
|
1. [Firebase-Konsole](https://console.firebase.google.com/) → Projekt `robot-clash-aa37b` (schon angelegt).
|
||||||
4. Die URL oben im Tab **Daten** (`https://<projekt>-default-rtdb.europe-west1.firebasedatabase.app`)
|
2. **Realtime Database** (Standort europe-west1 o. ä.): Tab **Regeln** → Inhalt von `database.rules.json`
|
||||||
in `game/game.js` bei `DB_URL` eintragen.
|
einfügen → **Veröffentlichen**. Die DB-URL ist schon in `game/game.js` eingetragen
|
||||||
|
(`https://robot-clash-aa37b-default-rtdb.firebaseio.com`).
|
||||||
|
3. **Für die Lobby:** **Authentication → Anmeldemethode** → **E-Mail/Passwort** aktivieren
|
||||||
|
(optional **Anonym** für Gast-Login).
|
||||||
|
4. **Web-API-Key** holen: ⚙ **Projekteinstellungen → Allgemein → Web-API-Schlüssel** (beginnt mit `AIza…`).
|
||||||
|
In `game/game.js` bei `NET_CFG = { apiKey: '…' }` eintragen → `.\build.ps1 -Web -Obfuscate` neu bauen.
|
||||||
|
(Der Web-API-Key ist **nicht geheim**; er darf im Client stehen. Geschützt wird über die DB-Regeln.)
|
||||||
|
|
||||||
## Was die Regeln erlauben
|
## Was die Regeln erlauben
|
||||||
|
|
||||||
- Lesen: nur `highscores` (sortiert/begrenzt nach `score`).
|
- `highscores`: lesen offen, nur **neue** Einträge schreiben (Format/Bereich geprüft).
|
||||||
- Schreiben: nur **neue** Einträge unter `highscores` – bestehende können nicht geändert/gelöscht werden.
|
- `users/$uid`, `lobby/$uid`, `matches/$id`, `challenges`: nur eingeloggte Nutzer; jeder schreibt nur seinen
|
||||||
- Jeder Eintrag hat genau `name` (1–20 Zeichen), `score` (1–10 000 000), `level` (1–999), `time` (Server-Zeit).
|
eigenen Lobby-Eintrag / seine Eingaben; den Kampf-Zustand schreibt nur der **Host** (kleinere uid).
|
||||||
|
|
||||||
## Grenzen
|
## Grenzen (ehrlich)
|
||||||
|
|
||||||
Punkte lassen sich per Hand-Request fälschen; die Regeln prüfen nur Format und Bereich. Echter Schutz
|
- Client-Code ist im Browser immer lesbar/ladbar. `-Obfuscate` erschwert das nur, verhindert es nicht.
|
||||||
bräuchte eine Server-Prüfung (Cloud Function). Einträge löschen: Konsole → **Daten** → `highscores` →
|
Echter Schutz liegt serverseitig (Auth + Regeln).
|
||||||
Eintrag → ⋮ / Papierkorb. Schimpfwort-Namen blockt `Kit.badName` bei der Eingabe und blendet sie in der Liste aus.
|
- Punkte/Daten lassen sich per Hand-Request fälschen; die Regeln prüfen nur Format/Besitzer, keine Spiel-Logik.
|
||||||
|
Fälschungssicher nur mit Cloud Functions (nicht eingebaut).
|
||||||
Referenz im Einsatz: `D:\Oculusquest\Projekt\Pipefix\docs\firebase\`.
|
- Live-PvP: der Host schreibt ~15 Snapshots/s (~1800 Writes pro 2-Minuten-Kampf). Für wenige gleichzeitige
|
||||||
|
Kämpfe im Spark-Gratis-Tarif ok; bei vielen Spielern RTDB-Nutzung im Blick behalten.
|
||||||
|
- Stockt der Gegner > 1,5 s, übernimmt die KI seinen Roboter, der Kampf läuft zu Ende.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
"rules": {
|
"rules": {
|
||||||
".read": false,
|
".read": false,
|
||||||
".write": false,
|
".write": false,
|
||||||
|
|
||||||
"highscores": {
|
"highscores": {
|
||||||
".read": true,
|
".read": true,
|
||||||
".indexOn": ["score"],
|
".indexOn": ["score"],
|
||||||
@@ -14,6 +15,48 @@
|
|||||||
"time": { ".validate": "newData.val() == now" },
|
"time": { ".validate": "newData.val() == now" },
|
||||||
"$other": { ".validate": false }
|
"$other": { ".validate": false }
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"users": {
|
||||||
|
"$uid": {
|
||||||
|
".read": "auth != null && auth.uid == $uid",
|
||||||
|
".write": "auth != null && auth.uid == $uid"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"lobby": {
|
||||||
|
".read": "auth != null",
|
||||||
|
"$uid": {
|
||||||
|
".write": "auth != null && auth.uid == $uid",
|
||||||
|
".validate": "newData.hasChildren(['name', 'ts'])",
|
||||||
|
"name": { ".validate": "newData.isString() && newData.val().length <= 20" },
|
||||||
|
"flag": { ".validate": "newData.isString() && newData.val().length <= 4" },
|
||||||
|
"ts": { ".validate": "newData.isNumber()" },
|
||||||
|
"$other": { ".validate": true }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"challenges": {
|
||||||
|
"$to": {
|
||||||
|
".read": "auth != null && auth.uid == $to",
|
||||||
|
"$from": {
|
||||||
|
".write": "auth != null && (auth.uid == $from || auth.uid == $to)",
|
||||||
|
".validate": "!newData.exists() || (newData.child('from').val() == $from)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"matches": {
|
||||||
|
"$id": {
|
||||||
|
".read": "auth != null && $id.contains(auth.uid)",
|
||||||
|
".write": "auth != null && $id.contains(auth.uid)",
|
||||||
|
"state": {
|
||||||
|
".validate": "$id.beginsWith(auth.uid + '_')"
|
||||||
|
},
|
||||||
|
"in": {
|
||||||
|
".validate": "$id.endsWith('_' + auth.uid)"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
63
game/ai.js
@@ -6,16 +6,19 @@
|
|||||||
(function (root) {
|
(function (root) {
|
||||||
'use strict';
|
'use strict';
|
||||||
const RC = (root.RC = root.RC || {});
|
const RC = (root.RC = root.RC || {});
|
||||||
const A = () => RC.ARENA;
|
|
||||||
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
|
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
|
||||||
const wrap = a => { while (a > Math.PI) a -= 2 * Math.PI; while (a < -Math.PI) a += 2 * Math.PI; return a; };
|
const wrap = a => { while (a > Math.PI) a -= 2 * Math.PI; while (a < -Math.PI) a += 2 * Math.PI; return a; };
|
||||||
|
|
||||||
function danger(s, x, z, me) {
|
function danger(s, x, z, me) {
|
||||||
const ar = A(), m = 0.35;
|
const ar = s.arena || RC.ARENA, m = 0.35;
|
||||||
if (s.left < ar.pitOpensAt + 2 && Math.abs(x - ar.pit.x) < ar.pit.hw + me.st.rad && Math.abs(z - ar.pit.z) < ar.pit.hd + me.st.rad) return 3;
|
if (s.left < ar.pitOpensAt + 2 && Math.abs(x - ar.pit.x) < ar.pit.hw + me.st.rad && Math.abs(z - ar.pit.z) < ar.pit.hd + me.st.rad) return 3;
|
||||||
for (const h of ar.saws) if (RC.hazardOn(h, s.t + 0.4) && Math.hypot(x - h.x, z - h.z) < h.r + me.st.rad) return 2;
|
for (const h of ar.saws) if (RC.hazardOn(h, s.t + 0.4) && Math.hypot(x - h.x, z - h.z) < h.r + me.st.rad) return 2;
|
||||||
for (const h of ar.flames) if (RC.hazardOn(h, s.t + 0.4) && Math.abs(x - h.x) < h.hw + m && Math.abs(z - h.z) < h.hd + m) return 2;
|
for (const h of ar.flames) if (RC.hazardOn(h, s.t + 0.4) && Math.abs(x - h.x) < h.hw + m && Math.abs(z - h.z) < h.hd + m) return 2;
|
||||||
for (const g of [ar.press, ar.crane]) if (Math.abs(x - g.x) < g.hw + m && Math.abs(z - g.z) < g.hd + m) return 2;
|
for (const g of [ar.press, ar.crane]) if (Math.abs(x - g.x) < g.hw + m && Math.abs(z - g.z) < g.hd + m) return 2;
|
||||||
|
for (const r of ar.rams || []) if (RC.hazardOn(r, s.t + 0.4) && Math.abs(x - r.x) < r.hw + m && Math.abs(z - r.z) < r.hd + m) return 2;
|
||||||
|
// solid cover and slicks: drive round them, they are not deadly
|
||||||
|
for (const b of ar.blocks || []) if (Math.abs(x - b.x) < b.hw + me.st.rad && Math.abs(z - b.z) < b.hd + me.st.rad) return 1;
|
||||||
|
for (const o of ar.oil || []) if (Math.hypot(x - o.x, z - o.z) < o.r) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,23 +55,21 @@
|
|||||||
const back = e.a + Math.PI + (rand() < 0.5 ? 0.9 : -0.9);
|
const back = e.a + Math.PI + (rand() < 0.5 ? 0.9 : -0.9);
|
||||||
tx = e.x + Math.cos(back) * 1.8; tz = e.z + Math.sin(back) * 1.8;
|
tx = e.x + Math.cos(back) * 1.8; tz = e.z + Math.sin(back) * 1.8;
|
||||||
} else if (style === 'pusher') { // line up enemy -> pit (or press corner) and shove
|
} else if (style === 'pusher') { // line up enemy -> pit (or press corner) and shove
|
||||||
const ar = A(), goal = s.pitOpen >= 1 ? ar.pit : ar.press;
|
const ar = s.arena, goal = s.pitOpen >= 1 ? ar.pit : ar.press;
|
||||||
const gx = goal.x - e.x, gz = goal.z - e.z, gl = Math.hypot(gx, gz) || 1;
|
const gx = goal.x - e.x, gz = goal.z - e.z, gl = Math.hypot(gx, gz) || 1;
|
||||||
const bx = e.x - gx / gl * 1.6, bz = e.z - gz / gl * 1.6;
|
const bx = e.x - gx / gl * 1.6, bz = e.z - gz / gl * 1.6;
|
||||||
const lined = Math.hypot(me.x - bx, me.z - bz) < 1.0 || dist < me.st.rad + e.st.rad + 0.25;
|
const lined = Math.hypot(me.x - bx, me.z - bz) < 1.0 || dist < me.st.rad + e.st.rad + 0.25;
|
||||||
if (!lined && dist > 1.1) { tx = bx; tz = bz; }
|
if (!lined && dist > 1.1) { tx = bx; tz = bz; }
|
||||||
} else if (style === 'gunner' && t) { // keep distance, circle
|
} else if (style === 'gunner' && t) { // face the enemy (fixed turret), hold the range
|
||||||
const want = t.type === 'flamer' ? 1.8 : 4.2;
|
tx = e.x; tz = e.z;
|
||||||
if (dist < want) {
|
|
||||||
const away = Math.atan2(me.z - e.z, me.x - e.x) + 0.9;
|
|
||||||
tx = e.x + Math.cos(away) * want; tz = e.z + Math.sin(away) * want;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let cmd = steer(me, tx, tz, 0.75 + skill * 0.25);
|
let cmd = steer(me, tx, tz, 0.75 + skill * 0.25);
|
||||||
|
// gunner too close: back off but keep the nose (and the turret) on the enemy
|
||||||
|
if (style === 'gunner' && t && dist < ((t.type === 'flamer' || t.type === 'zapper') ? 1.4 : 2.8)) cmd = { turn: cmd.turn, throttle: -0.7 };
|
||||||
|
|
||||||
// avoid hazards in front (skilled robots look further)
|
// avoid hazards in front (skilled robots look further)
|
||||||
const look = 0.9 + skill * 1.0, fx = Math.cos(me.a), fz = Math.sin(me.a);
|
const look = 0.9 + skill * 1.0, fx = Math.cos(me.a), fz = Math.sin(me.a);
|
||||||
const dng = danger(s, me.x + fx * look, me.z + fz * look, me);
|
const dng = danger(s, me.x + fx * look, me.z + fz * look, me); // includes blocks + oil now
|
||||||
// enemy right in front and closer than the hazard: keep attacking (it lands in there, not me)
|
// enemy right in front and closer than the hazard: keep attacking (it lands in there, not me)
|
||||||
const enemyAhead = dist < look + me.st.rad + e.st.rad && Math.abs(wrap(Math.atan2(e.z - me.z, e.x - me.x) - me.a)) < 0.6;
|
const enemyAhead = dist < look + me.st.rad + e.st.rad && Math.abs(wrap(Math.atan2(e.z - me.z, e.x - me.x) - me.a)) < 0.6;
|
||||||
if (dng && !enemyAhead && (dng === 3 || dist > 2.2) && rand() < 0.3 + skill * 0.6) {
|
if (dng && !enemyAhead && (dng === 3 || dist > 2.2) && rand() < 0.3 + skill * 0.6) {
|
||||||
@@ -85,7 +86,7 @@
|
|||||||
const pushing = style === 'pusher' && s.pitOpen >= 1;
|
const pushing = style === 'pusher' && s.pitOpen >= 1;
|
||||||
contact = rammer && !pushing && dist < me.st.rad + e.st.rad + 0.3 ? contact + react : 0;
|
contact = rammer && !pushing && dist < me.st.rad + e.st.rad + 0.3 ? contact + react : 0;
|
||||||
// only back off with room behind (no spike wall, no trap)
|
// only back off with room behind (no spike wall, no trap)
|
||||||
const half = A().half - me.st.rad - 0.4;
|
const half = s.arena.half - me.st.rad - 0.4;
|
||||||
const bx = me.x - fx * 1.4, bz = me.z - fz * 1.4;
|
const bx = me.x - fx * 1.4, bz = me.z - fz * 1.4;
|
||||||
const roomBehind = Math.abs(bx) < half && Math.abs(bz) < half && !danger(s, bx, bz, me);
|
const roomBehind = Math.abs(bx) < half && Math.abs(bz) < half && !danger(s, bx, bz, me);
|
||||||
if (contact > 0.45 && retreat <= 0 && roomBehind && rand() < 0.25 + skill * 0.7) { retreat = 0.35 + rand() * 0.3; contact = 0; }
|
if (contact > 0.45 && retreat <= 0 && roomBehind && rand() < 0.25 + skill * 0.7) { retreat = 0.35 + rand() * 0.3; contact = 0; }
|
||||||
@@ -101,12 +102,18 @@
|
|||||||
const out = { throttle: h.throttle, turn: h.turn, fire: false, fire2: false };
|
const out = { throttle: h.throttle, turn: h.turn, fire: false, fire2: false };
|
||||||
if (style === 'dummy') return out;
|
if (style === 'dummy') return out;
|
||||||
if (w) {
|
if (w) {
|
||||||
if (w.type === 'spinner') out.fire = dist < 6;
|
if (w.type === 'spinner' || w.type === 'vspinner') out.fire = dist < 6;
|
||||||
|
else if (w.type === 'lifter') out.fire = inZ && rand() < 0.5 + skill * 0.5;
|
||||||
else if (w.type === 'saw') out.fire = dist < 2.6;
|
else if (w.type === 'saw') out.fire = dist < 2.6;
|
||||||
else if (w.type === 'wedge') out.fire = dist > 1.6 && dist < 4.5 && Math.abs(wrap(Math.atan2(e.z - me.z, e.x - me.x) - me.a)) < 0.25 && rand() < 0.08 + skill * 0.1;
|
else if (w.type === 'wedge') out.fire = dist > 1.6 && dist < 4.5 && Math.abs(wrap(Math.atan2(e.z - me.z, e.x - me.x) - me.a)) < 0.25 && rand() < 0.08 + skill * 0.1;
|
||||||
else out.fire = inZ && rand() < 0.25 + skill * 0.7;
|
else out.fire = inZ && rand() < 0.25 + skill * 0.7;
|
||||||
}
|
}
|
||||||
if (t) out.fire2 = dist < t.range * (t.type === 'flamer' ? 1.05 : 0.9);
|
if (t) {
|
||||||
|
const ahead = Math.abs(wrap(Math.atan2(e.z - me.z, e.x - me.x) - me.a));
|
||||||
|
const close = t.type === 'flamer' || t.type === 'zapper';
|
||||||
|
out.fire2 = dist < t.range * (close ? 1.05 : 0.9) && ahead < (close ? 0.5 : 0.3);
|
||||||
|
}
|
||||||
|
if (me.st.gadget) out.fire3 = RC.Combat.wantGadget(s, me, e);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
return { think };
|
return { think };
|
||||||
@@ -114,22 +121,22 @@
|
|||||||
|
|
||||||
const pal = (body, accent) => ({ body, accent });
|
const pal = (body, accent) => ({ body, accent });
|
||||||
RC.LEAGUE = [
|
RC.LEAGUE = [
|
||||||
{ id: 'rustbucket', name: 'Rustbucket', style: 'brawler', skill: 0.15, prize: 180,
|
{ id: 'rustbucket', name: 'Rustbucket', style: 'brawler', skill: 0.1, prize: 250,
|
||||||
build: { chassis: 'crate', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'wedge', tower: null }, paint: pal(0x8a5a3a, 0xd9a066) },
|
build: { chassis: 'cage', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'wedge', tower: null }, paint: pal(0x8a5a3a, 0xd9a066) },
|
||||||
{ id: 'tintoad', name: 'Tin Toad', style: 'pusher', skill: 0.25, prize: 240,
|
{ id: 'tintoad', name: 'Tin Toad', style: 'pusher', skill: 0.2, prize: 330,
|
||||||
build: { chassis: 'doorstop', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'wedge', tower: null }, paint: pal(0x5d8a3a, 0xc8e070) },
|
build: { chassis: 'doorstop', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'wedge', tower: null }, paint: pal(0x5d8a3a, 0xc8e070) },
|
||||||
{ id: 'buzzkill', name: 'Buzzkill', style: 'brawler', skill: 0.35, prize: 320,
|
{ id: 'buzzkill', name: 'Buzzkill', style: 'brawler', skill: 0.3, prize: 430,
|
||||||
build: { chassis: 'crate', motor: 'hornet', wheels: 'rubber', battery: 'nicd', armour: 'steel', weapon: 'saw', tower: null }, paint: pal(0xd8b020, 0x202020) },
|
build: { chassis: 'hexpod', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: null, weapon: 'saw', tower: null }, paint: pal(0xd8b020, 0x202020) },
|
||||||
{ id: 'flapjack', name: 'Flapjack', style: 'flanker', skill: 0.45, prize: 420,
|
{ id: 'flapjack', name: 'Flapjack', style: 'flanker', skill: 0.38, prize: 560,
|
||||||
build: { chassis: 'doorstop', motor: 'hornet', wheels: 'bigtyre', battery: 'nicd', armour: 'steel', weapon: 'flipper', tower: null }, paint: pal(0x2a6fd8, 0xffffff) },
|
build: { chassis: 'fang', motor: 'sparky', wheels: 'bigtyre', battery: 'lead', armour: null, weapon: 'flipper', tower: null }, paint: pal(0x2a6fd8, 0xffffff) },
|
||||||
{ id: 'pincer', name: 'Pincer', style: 'pusher', skill: 0.55, prize: 540,
|
{ id: 'pincer', name: 'Pincer', style: 'pusher', skill: 0.55, prize: 700,
|
||||||
build: { chassis: 'bulwark', motor: 'bulldog', wheels: 'tracks', battery: 'nicd', armour: 'steel', weapon: 'crusher', tower: null }, paint: pal(0xc0392b, 0xf0c040) },
|
build: { chassis: 'boiler', motor: 'bulldog', wheels: 'tracks', battery: 'lipo', armour: 'steel', weapon: 'crusher', tower: null, gadget: 'repair' }, paint: pal(0xc0392b, 0xf0c040) },
|
||||||
{ id: 'thunderclap', name: 'Thunderclap', style: 'brawler', skill: 0.65, prize: 680,
|
{ id: 'thunderclap', name: 'Thunderclap', style: 'brawler', skill: 0.65, prize: 880,
|
||||||
build: { chassis: 'bulwark', motor: 'hornet', wheels: 'bigtyre', battery: 'nicd', armour: 'titan', weapon: 'hammer', tower: 'flamer' }, paint: pal(0x6a3fb0, 0xffa020) },
|
build: { chassis: 'plough', motor: 'hornet', wheels: 'bigtyre', battery: 'lipo', armour: 'titan', weapon: 'hammer', tower: 'flamer', gadget: 'shield' }, paint: pal(0x6a3fb0, 0xffa020) },
|
||||||
{ id: 'gravedigger', name: 'Gravedigger', style: 'gunner', skill: 0.8, prize: 860,
|
{ id: 'gravedigger', name: 'Gravedigger', style: 'brawler', skill: 0.8, prize: 1100,
|
||||||
build: { chassis: 'scarab', motor: 'hornet', wheels: 'tracks', battery: 'lipo', armour: 'titan', weapon: 'wedge', tower: 'rockets' }, paint: pal(0x2b2f36, 0x50e080) },
|
build: { chassis: 'scarab', motor: 'hornet', wheels: 'tracks', battery: 'lipo', armour: 'titan', weapon: 'flipper', tower: 'rockets', gadget: 'turbo' }, paint: pal(0x2b2f36, 0x50e080) },
|
||||||
{ id: 'overlord', name: 'Overlord', style: 'flanker', skill: 0.95, prize: 1200,
|
{ id: 'overlord', name: 'Overlord', style: 'flanker', skill: 0.95, prize: 1450,
|
||||||
build: { chassis: 'scarab', motor: 'comet', wheels: 'rubber', battery: 'lipo', armour: 'steel', weapon: 'spinner', tower: null }, paint: pal(0x101418, 0xff3030) },
|
build: { chassis: 'discus', motor: 'comet', wheels: 'rubber', battery: 'lipo', armour: 'steel', weapon: 'spinner', tower: null, gadget: 'righter' }, paint: pal(0x101418, 0xff3030) },
|
||||||
];
|
];
|
||||||
RC.DUMMY = { id: 'dummy', name: 'Dummy', style: 'dummy', skill: 0, prize: 0,
|
RC.DUMMY = { id: 'dummy', name: 'Dummy', style: 'dummy', skill: 0, prize: 0,
|
||||||
build: { chassis: 'crate', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: 'steel', weapon: null, tower: null }, paint: pal(0x8c8c8c, 0xff7a1a) };
|
build: { chassis: 'crate', motor: 'sparky', wheels: 'rubber', battery: 'lead', armour: 'steel', weapon: null, tower: null }, paint: pal(0x8c8c8c, 0xff7a1a) };
|
||||||
|
|||||||
93
game/assets/Fonts/OFL.txt
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright (c) 2011-2012, Jovanny Lemonad (jovanny.ru), with Reserved Font Name "Russo"
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
BIN
game/assets/Fonts/RussoOne-Regular.ttf
Normal file
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 6.4 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 281 KiB After Width: | Height: | Size: 175 KiB |
BIN
game/assets/Sprites/logo.png
Normal file
|
After Width: | Height: | Size: 620 KiB |
BIN
game/assets/Sprites/logo_emblem.png
Normal file
|
After Width: | Height: | Size: 408 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 60 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
BIN
game/assets/Sprites/part_boiler.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
game/assets/Sprites/part_buffer.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 35 KiB |
BIN
game/assets/Sprites/part_cage.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
game/assets/Sprites/part_ceramic.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 33 KiB |
BIN
game/assets/Sprites/part_discus.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 34 KiB |
BIN
game/assets/Sprites/part_drill.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
game/assets/Sprites/part_drum.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
game/assets/Sprites/part_drumwh.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
game/assets/Sprites/part_emp.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
game/assets/Sprites/part_fang.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 40 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 30 KiB |
BIN
game/assets/Sprites/part_hexpod.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 60 KiB |
BIN
game/assets/Sprites/part_hover.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
game/assets/Sprites/part_lance.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
game/assets/Sprites/part_launcher.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 51 KiB |
BIN
game/assets/Sprites/part_lifter.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 56 KiB |
BIN
game/assets/Sprites/part_mace.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
game/assets/Sprites/part_mesh.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 30 KiB |
BIN
game/assets/Sprites/part_mortar.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 48 KiB |
BIN
game/assets/Sprites/part_omni.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
game/assets/Sprites/part_plough.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
game/assets/Sprites/part_repair.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
game/assets/Sprites/part_righter.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 28 KiB |
BIN
game/assets/Sprites/part_shield.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
BIN
game/assets/Sprites/part_spiked.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 28 KiB |
BIN
game/assets/Sprites/part_studs.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
game/assets/Sprites/part_swarm.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 25 KiB |
BIN
game/assets/Sprites/part_turbo.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
game/assets/Sprites/part_vdisc.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 32 KiB |
BIN
game/assets/Sprites/part_zapper.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
game/assets/Sprites/slot_gadget.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
game/assets/Sprites/tex_wall.jpg
Normal file
|
After Width: | Height: | Size: 35 KiB |
408
game/combat.js
@@ -12,17 +12,73 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const RC = (root.RC = root.RC || {});
|
const RC = (root.RC = root.RC || {});
|
||||||
|
|
||||||
const ARENA = (RC.ARENA = {
|
// Arena definitions. `half` = floor from -half..half. Hazards scale with the size. The active arena is
|
||||||
half: 8, // floor from -8..8
|
// RC.ARENA; a fight snapshots it into s.arena so several arenas can exist. render3d.js reads s.arena.
|
||||||
duration: 120, // seconds
|
function arena(o) {
|
||||||
pitOpensAt: 60, // seconds left when the pit opens
|
const h = o.half, shape = o.shape || 'square';
|
||||||
pit: { x: 0, z: 4.6, hw: 1.35, hd: 1.35 },
|
// guardians sit in the corners of a square arena; on a round/octagon floor they move inwards
|
||||||
saws: [{ x: -3.2, z: -3.4, r: 0.95, period: 6, on: 2.2, phase: 0 }, { x: 3.2, z: -3.4, r: 0.95, period: 6, on: 2.2, phase: 3 }],
|
// along the diagonal, otherwise they would stand outside the wall
|
||||||
flames: [{ x: -2.7, z: 3.3, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase: 1 }, { x: 2.7, z: 3.3, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase: 4.5 }],
|
const g = (h - 1.75) * (shape === 'square' ? 1 : shape === 'round' ? 0.7 : 0.66);
|
||||||
press: { x: 6.25, z: -6.25, hw: 1.6, hd: 1.6 }, // guardian 1: forge press (corner)
|
return {
|
||||||
crane: { x: -6.25, z: 6.25, hw: 1.6, hd: 1.6 }, // guardian 2: magnet crane (corner)
|
id: o.id, name: o.name, theme: o.theme || 'steel', half: h,
|
||||||
starts: [{ x: -5, z: 1.5, a: 0 }, { x: 5, z: 1.5, a: Math.PI }],
|
shape: o.shape || 'square', // square | octagon | round
|
||||||
});
|
blocks: o.blocks || [], belts: o.belts || [], oil: o.oil || [], rams: o.rams || [],
|
||||||
|
duration: 120, pitOpensAt: o.pitOpensAt || 60,
|
||||||
|
pit: { x: 0, z: o.pitZ != null ? o.pitZ : h * 0.52, hw: o.pitW || 1.35, hd: o.pitW || 1.35 },
|
||||||
|
saws: o.saws, flames: o.flames,
|
||||||
|
press: { x: g, z: -g, hw: 1.6, hd: 1.6 }, // guardian 1: forge press (corner)
|
||||||
|
crane: { x: -g, z: g, hw: 1.6, hd: 1.6 }, // guardian 2: magnet crane (corner)
|
||||||
|
starts: [{ x: -h * 0.6, z: h * 0.2, a: 0 }, { x: h * 0.6, z: h * 0.2, a: Math.PI }],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const saw = (x, z, phase) => ({ x, z, r: 0.95, period: 6, on: 2.2, phase });
|
||||||
|
const flame = (x, z, phase) => ({ x, z, hw: 0.9, hd: 0.9, period: 7, on: 1.8, phase });
|
||||||
|
const saw2 = saw, flame2 = flame;
|
||||||
|
const block = (kind, x, z, hw, hd, h2) => ({ kind, x, z, hw, hd, h: h2 || 0.8 });
|
||||||
|
const belt = (x, z, hw, hd, ax, az, force) => ({ x, z, hw, hd, ax, az, force });
|
||||||
|
const ram = (x, z, hw, hd, nx, nz, phase) => ({ x, z, hw, hd, nx, nz, period: 5, on: 1.3, phase });
|
||||||
|
RC.ARENAS = [
|
||||||
|
// tight starter pit: two scrap heaps are the only cover
|
||||||
|
arena({ id: 'workshop', name: 'Workshop Pit', theme: 'steel', half: 8, shape: 'square',
|
||||||
|
saws: [saw(-3.2, -3.4, 0), saw(3.2, -3.4, 3)],
|
||||||
|
flames: [flame(-2.7, 3.3, 1), flame(2.7, 3.3, 4.5)],
|
||||||
|
blocks: [block('scrap', -2.7, -1.2, 0.8, 0.8), block('scrap', 2.7, -1.2, 0.8, 0.8)] }),
|
||||||
|
// wreck yard: lots of cover and two oil slicks that kill your steering
|
||||||
|
arena({ id: 'scrapyard', name: 'Scrapyard', theme: 'steel', half: 10, shape: 'square', pitW: 1.5,
|
||||||
|
saws: [saw(-4, -4, 0), saw(4, -4, 2.5), saw(0, 4.5, 1.5)],
|
||||||
|
flames: [flame(-5.5, 2, 0), flame(5.5, 2, 3), flame(0, -6, 2)],
|
||||||
|
blocks: [block('scrap', -3.8, -1.5, 1.0, 0.9, 1.0), block('scrap', 3.8, -1.5, 1.0, 0.9, 1.0),
|
||||||
|
block('scrap', 0, -5.2, 1.4, 0.8, 0.9), block('crate', -2.8, 3.0, 0.6, 0.6, 0.7), block('crate', 2.8, 3.0, 0.6, 0.6, 0.7)],
|
||||||
|
oil: [{ x: -2.4, z: 1.0, r: 1.6 }, { x: 2.6, z: -3.4, r: 1.5 }] }),
|
||||||
|
// foundry: a belt drags you sideways into the flame channel
|
||||||
|
arena({ id: 'foundry', name: 'The Foundry', theme: 'lava', half: 12, shape: 'octagon', pitW: 1.7,
|
||||||
|
saws: [saw(-5, -4.5, 0), saw(5, -4.5, 3), saw(0, 4.5, 1.5)],
|
||||||
|
flames: [flame(-4.5, 1, 0), flame(4.5, 1, 3.5), flame(0, -7.5, 2), flame(-7, 6, 5)],
|
||||||
|
blocks: [block('barrier', -6.2, -5, 1.3, 0.4, 0.6), block('barrier', 6.2, -5, 1.3, 0.4, 0.6)],
|
||||||
|
belts: [belt(0, 1, 4.0, 1.1, 1, 0, 9)] }),
|
||||||
|
// crucible: one pillar in the middle, two wall rams punching inwards
|
||||||
|
arena({ id: 'crucible', name: 'The Crucible', theme: 'lava', half: 14, shape: 'round', pitW: 1.9,
|
||||||
|
saws: [saw(-5.5, -5, 0), saw(5.5, -5, 3), saw(-5.5, 5, 1.5), saw(5.5, 5, 4.5)],
|
||||||
|
flames: [flame(-6, 1.5, 0), flame(6, 1.5, 3), flame(0, 8, 2), flame(0, -8, 4.5)],
|
||||||
|
blocks: [block('pillar', 0, 0, 1.1, 1.1, 1.8)],
|
||||||
|
rams: [ram(-11.8, 0, 1.5, 2.2, 1, 0, 0), ram(11.8, 0, 1.5, 2.2, -1, 0, 2.5)] }),
|
||||||
|
// dome: four pillars to duck behind, and the pit opens early
|
||||||
|
arena({ id: 'arena64', name: 'Mega Dome', theme: 'blue', half: 16, shape: 'octagon', pitW: 2.1, pitOpensAt: 80,
|
||||||
|
saws: [saw(-6.5, -6, 0), saw(6.5, -6, 3), saw(-6.5, 6, 1.5), saw(6.5, 6, 4.5), saw(0, 0, 2)],
|
||||||
|
flames: [flame(-8, 2, 0), flame(8, 2, 2), flame(0, 9, 4), flame(0, -9, 1), flame(-10, -4, 3), flame(10, -4, 5)],
|
||||||
|
blocks: [block('pillar', -5, -5, 0.9, 0.9, 2.0), block('pillar', 5, -5, 0.9, 0.9, 2.0),
|
||||||
|
block('pillar', -5, 5, 0.9, 0.9, 2.0), block('pillar', 5, 5, 0.9, 0.9, 2.0)] }),
|
||||||
|
// colosseum: huge, a wreck mound in the centre and two belts feeding the pit
|
||||||
|
arena({ id: 'colosseum', name: 'Grand Colosseum', theme: 'blue', half: 20, shape: 'round', pitW: 2.4,
|
||||||
|
saws: [saw(-8, -7, 0), saw(8, -7, 3), saw(-8, 7, 1.5), saw(8, 7, 4.5), saw(0, -11, 3.5)],
|
||||||
|
flames: [flame(-10, 2, 0), flame(10, 2, 2), flame(0, 13, 4), flame(0, -13, 1), flame(-13, -5, 3), flame(13, -5, 5)],
|
||||||
|
blocks: [block('scrap', 0, 0, 2.0, 1.6, 1.3), block('crate', -7, -2, 0.8, 0.8, 0.9), block('crate', 7, -2, 0.8, 0.8, 0.9)],
|
||||||
|
belts: [belt(-3.6, 6.5, 1.3, 3.0, 0, 1, 9), belt(3.6, 6.5, 1.3, 3.0, 0, 1, 9)] }),
|
||||||
|
];
|
||||||
|
|
||||||
|
let ARENA = RC.ARENAS[0];
|
||||||
|
RC.ARENA = ARENA;
|
||||||
|
RC.setArena = id => { ARENA = RC.ARENAS.find(a => a.id === id) || RC.ARENAS[0]; RC.ARENA = ARENA; return ARENA; };
|
||||||
|
|
||||||
const G = 22; // gravity
|
const G = 22; // gravity
|
||||||
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
|
const clamp = (v, a, b) => (v < a ? a : v > b ? b : v);
|
||||||
@@ -31,33 +87,97 @@
|
|||||||
let s = seed >>> 0 || 1;
|
let s = seed >>> 0 || 1;
|
||||||
return () => { s = (s + 0x6d2b79f5) >>> 0; let t = s; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
|
return () => { s = (s + 0x6d2b79f5) >>> 0; let t = s; t = Math.imul(t ^ (t >>> 15), t | 1); t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
|
||||||
}
|
}
|
||||||
|
// Keep a point inside the arena outline. null = clear of the wall, otherwise the corrected
|
||||||
|
// spot plus the wall normal pointing INTO the arena. Used by the physics, the AI and the map.
|
||||||
|
function wallPush(A, x, z, rad) {
|
||||||
|
const lim = A.half - rad;
|
||||||
|
if (A.shape === 'round') {
|
||||||
|
const d = Math.hypot(x, z);
|
||||||
|
if (d <= lim || d < 1e-6) return null;
|
||||||
|
return { x: (x / d) * lim, z: (z / d) * lim, nx: -x / d, nz: -z / d };
|
||||||
|
}
|
||||||
|
let cx = x, cz = z, nx = 0, nz = 0, hit = false;
|
||||||
|
if (cx > lim) { cx = lim; nx = -1; hit = true; } else if (cx < -lim) { cx = -lim; nx = 1; hit = true; }
|
||||||
|
if (cz > lim) { cz = lim; nz = -1; hit = true; } else if (cz < -lim) { cz = -lim; nz = 1; hit = true; }
|
||||||
|
if (A.shape === 'octagon') { // four corner cuts: |x| + |z| <= dlim
|
||||||
|
const dlim = lim * 1.34, sx = Math.sign(cx) || 1, sz = Math.sign(cz) || 1;
|
||||||
|
const over = Math.abs(cx) + Math.abs(cz) - dlim;
|
||||||
|
if (over > 0) {
|
||||||
|
cx -= sx * over / 2; cz -= sz * over / 2;
|
||||||
|
nx = -sx * Math.SQRT1_2; nz = -sz * Math.SQRT1_2; hit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!hit) return null;
|
||||||
|
const len = Math.hypot(nx, nz) || 1;
|
||||||
|
return { x: cx, z: cz, nx: nx / len, nz: nz / len };
|
||||||
|
}
|
||||||
|
// Is this spot inside a static obstacle? Returns the push-out normal, or null.
|
||||||
|
function blockPush(A, r, rad) {
|
||||||
|
for (const b of A.blocks) {
|
||||||
|
const dx = r.x - b.x, dz = r.z - b.z;
|
||||||
|
const ox = b.hw + rad - Math.abs(dx), oz = b.hd + rad - Math.abs(dz);
|
||||||
|
if (ox <= 0 || oz <= 0) continue;
|
||||||
|
if (ox < oz) { const sx = Math.sign(dx) || 1; r.x = b.x + sx * (b.hw + rad); return { nx: sx, nz: 0 }; }
|
||||||
|
const sz = Math.sign(dz) || 1; r.z = b.z + sz * (b.hd + rad); return { nx: 0, nz: sz };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
RC.wallPush = wallPush;
|
||||||
|
RC.inBlock = (A, x, z, m = 0) => A.blocks.some(b => Math.abs(x - b.x) < b.hw + m && Math.abs(z - b.z) < b.hd + m);
|
||||||
|
|
||||||
const inRect = (o, x, z, m = 0) => Math.abs(x - o.x) < o.hw + m && Math.abs(z - o.z) < o.hd + m;
|
const inRect = (o, x, z, m = 0) => Math.abs(x - o.x) < o.hw + m && Math.abs(z - o.z) < o.hd + m;
|
||||||
const hazardOn = (h, t) => ((t + h.phase) % h.period) < h.on;
|
const hazardOn = (h, t) => ((t + h.phase) % h.period) < h.on;
|
||||||
RC.hazardOn = hazardOn;
|
RC.hazardOn = hazardOn;
|
||||||
|
|
||||||
function makeRobot(st, i, name) {
|
function makeRobot(st, i, name, A) {
|
||||||
const p = ARENA.starts[i];
|
const p = A.starts[i];
|
||||||
return {
|
return {
|
||||||
i, name, st, x: p.x, z: p.z, a: p.a, vx: 0, vz: 0, av: 0, y: 0, vy: 0,
|
i, name, st, x: p.x, z: p.z, a: p.a, vx: 0, vz: 0, av: 0, y: 0, vy: 0,
|
||||||
hp: st.hp, maxHp: st.hp, dead: false, out: null, fall: 0,
|
hp: st.hp, maxHp: st.hp, dead: false, out: null, fall: 0,
|
||||||
flipped: 0, stun: 0, lifted: 0, grabbedBy: null, grab: 0,
|
flipped: 0, stun: 0, lifted: 0, grabbedBy: null, grab: 0,
|
||||||
|
shield: 0, gcd: 0, gUses: st.gadget && st.gadget.charges || 0,
|
||||||
|
lost: { armour: false, wheels: false, weapon: false, tower: false }, // parts torn off during the fight
|
||||||
|
onOil: false, // standing in a slick: less grip, lazy steering
|
||||||
cd: 0, cd2: 0, spin: 0, swing: 0, flipAnim: 0, boost: 0, sawOn: false, flameOn: false, gunOn: false,
|
cd: 0, cd2: 0, spin: 0, swing: 0, flipAnim: 0, boost: 0, sawOn: false, flameOn: false, gunOn: false,
|
||||||
turretA: p.a, dealt: 0, taken: 0, pressT: 0, craneT: 0, fx: 0,
|
turretA: p.a, dealt: 0, taken: 0, pressT: 0, craneT: 0, fx: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function create(opt) {
|
function create(opt) {
|
||||||
|
const A = opt.arena ? (RC.ARENAS.find(a => a.id === opt.arena) || RC.ARENA) : RC.ARENA;
|
||||||
const s = {
|
const s = {
|
||||||
t: 0, left: ARENA.duration, pitOpen: 0, rand: rng(opt.seed || 1),
|
arena: A, t: 0, left: A.duration, pitOpen: 0, rand: rng(opt.seed || 1),
|
||||||
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1))),
|
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1), A)),
|
||||||
rockets: [], events: [], result: null, endIn: 0,
|
rockets: [], events: [], result: null, endIn: 0,
|
||||||
press: { st: 'idle', t: 0, y: 1 }, // idle | warn | slam | up ; y 1 = top, 0 = floor
|
press: { st: 'idle', t: 0, y: 1 }, // idle | warn | slam | up ; y 1 = top, 0 = floor
|
||||||
crane: { st: 'idle', t: 0, who: -1, tx: 0, tz: 0, x: ARENA.crane.x, z: ARENA.crane.z },
|
crane: { st: 'idle', t: 0, who: -1, tx: 0, tz: 0, x: A.crane.x, z: A.crane.z },
|
||||||
pitAlarm: false,
|
pitAlarm: false,
|
||||||
};
|
};
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// a part that broke off no longer works (and bare metal takes more damage)
|
||||||
|
const weaponOf = r => (r.lost.weapon ? null : r.st.weapon);
|
||||||
|
const towerOf = r => (r.lost.tower ? null : r.st.tower);
|
||||||
|
const reduceOf = r => (r.lost.armour ? r.st.reduce * 0.3 : r.st.reduce);
|
||||||
|
|
||||||
|
// battle damage: at these shares of health the next hit tears a part off (no randomness,
|
||||||
|
// so both sides of an online fight and the tests see exactly the same thing)
|
||||||
|
const BREAK_AT = [['armour', 0.6], ['wheels', 0.4], ['weapon', 0.25], ['tower', 0.18]];
|
||||||
|
function breakCheck(s, r) {
|
||||||
|
if (r.dead || r.out) return;
|
||||||
|
const f = r.hp / r.maxHp;
|
||||||
|
for (const [part, at] of BREAK_AT) {
|
||||||
|
if (r.lost[part] || f >= at) continue;
|
||||||
|
if (part === 'armour' && !r.st.armour) continue;
|
||||||
|
if (part === 'weapon' && !r.st.weapon) continue;
|
||||||
|
if (part === 'tower' && !r.st.tower) continue;
|
||||||
|
r.lost[part] = true;
|
||||||
|
if (part === 'weapon') { r.spin = 0; r.swing = 0; if (r.grab > 0) release(s, r, s.robots[1 - r.i]); }
|
||||||
|
s.events.push({ type: 'broke', who: r.i, part, x: r.x, z: r.z });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const fwd = r => [Math.cos(r.a), Math.sin(r.a)];
|
const fwd = r => [Math.cos(r.a), Math.sin(r.a)];
|
||||||
// enemy position in my frame: [forward, side]
|
// enemy position in my frame: [forward, side]
|
||||||
function local(me, e) {
|
function local(me, e) {
|
||||||
@@ -66,7 +186,7 @@
|
|||||||
}
|
}
|
||||||
function inZone(s, me, e, extra = 0) {
|
function inZone(s, me, e, extra = 0) {
|
||||||
if (e.out || me.out) return false;
|
if (e.out || me.out) return false;
|
||||||
const w = me.st.weapon; if (!w) return false;
|
const w = weaponOf(me); if (!w) return false;
|
||||||
const [lf, ls] = local(me, e);
|
const [lf, ls] = local(me, e);
|
||||||
return lf > 0 && lf < me.st.len / 2 + w.reach + e.st.rad * 0.75 + extra && Math.abs(ls) < me.st.wid / 2 + e.st.rad * 0.55;
|
return lf > 0 && lf < me.st.len / 2 + w.reach + e.st.rad * 0.75 + extra && Math.abs(ls) < me.st.wid / 2 + e.st.rad * 0.55;
|
||||||
}
|
}
|
||||||
@@ -81,7 +201,8 @@
|
|||||||
|
|
||||||
function damage(s, target, amount, src, opt = {}) {
|
function damage(s, target, amount, src, opt = {}) {
|
||||||
if (target.dead || target.out || amount <= 0 || s.result) return 0;
|
if (target.dead || target.out || amount <= 0 || s.result) return 0;
|
||||||
let d = amount * (1 - target.st.reduce * (1 - (opt.pierce || 0)));
|
let d = amount * (1 - reduceOf(target) * (1 - (opt.pierce || 0)));
|
||||||
|
if (target.shield > 0 && target.st.gadget) d *= (1 - (target.st.gadget.reduce || 0.6)); // deflector field
|
||||||
const from = opt.from || src; // where the hit comes from (rockets: impact point)
|
const from = opt.from || src; // where the hit comes from (rockets: impact point)
|
||||||
if (from && !opt.noZone) d *= zoneMul(target, from.x, from.z);
|
if (from && !opt.noZone) d *= zoneMul(target, from.x, from.z);
|
||||||
d = Math.min(d, target.hp);
|
d = Math.min(d, target.hp);
|
||||||
@@ -89,6 +210,7 @@
|
|||||||
// judges: hazard damage counts for the opponent (pushing into traps pays off)
|
// judges: hazard damage counts for the opponent (pushing into traps pays off)
|
||||||
if (src) src.dealt += d; else s.robots[1 - target.i].dealt += d;
|
if (src) src.dealt += d; else s.robots[1 - target.i].dealt += d;
|
||||||
if (d >= 0.5 || opt.tick) s.events.push({ type: 'dmg', who: target.i, amount: d, x: target.x, z: target.z, tick: !!opt.tick, kind: opt.kind || 'hit' });
|
if (d >= 0.5 || opt.tick) s.events.push({ type: 'dmg', who: target.i, amount: d, x: target.x, z: target.z, tick: !!opt.tick, kind: opt.kind || 'hit' });
|
||||||
|
breakCheck(s, target);
|
||||||
if (target.hp <= 0.001) {
|
if (target.hp <= 0.001) {
|
||||||
target.hp = 0; target.dead = true;
|
target.hp = 0; target.dead = true;
|
||||||
s.events.push({ type: 'ko', who: target.i, x: target.x, z: target.z });
|
s.events.push({ type: 'ko', who: target.i, x: target.x, z: target.z });
|
||||||
@@ -107,17 +229,18 @@
|
|||||||
function step(s, dt, inputs) {
|
function step(s, dt, inputs) {
|
||||||
if (s.endIn > 0) { s.endIn -= dt; }
|
if (s.endIn > 0) { s.endIn -= dt; }
|
||||||
s.t += dt;
|
s.t += dt;
|
||||||
if (!s.result) s.left = Math.max(0, ARENA.duration - s.t);
|
if (!s.result) s.left = Math.max(0, s.arena.duration - s.t);
|
||||||
const R = s.robots;
|
const R = s.robots;
|
||||||
|
|
||||||
// pit: opens at half time
|
// pit: opens at half time
|
||||||
if (s.left <= ARENA.pitOpensAt) {
|
if (s.left <= s.arena.pitOpensAt) {
|
||||||
if (!s.pitAlarm) { s.pitAlarm = true; s.events.push({ type: 'pit_open' }); }
|
if (!s.pitAlarm) { s.pitAlarm = true; s.events.push({ type: 'pit_open' }); }
|
||||||
s.pitOpen = Math.min(1, s.pitOpen + dt * 0.8);
|
s.pitOpen = Math.min(1, s.pitOpen + dt * 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let k = 0; k < 2; k++) drive(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
|
for (let k = 0; k < 2; k++) drive(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
|
||||||
collide(s, R[0], R[1], dt);
|
collide(s, R[0], R[1], dt);
|
||||||
|
for (let k = 0; k < 2; k++) gadgets(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
|
||||||
for (let k = 0; k < 2; k++) weapons(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
|
for (let k = 0; k < 2; k++) weapons(s, R[k], R[1 - k], (s.result ? null : inputs[k]) || {}, dt);
|
||||||
rockets(s, dt);
|
rockets(s, dt);
|
||||||
hazards(s, dt);
|
hazards(s, dt);
|
||||||
@@ -145,17 +268,19 @@
|
|||||||
let vf = r.vx * fx + r.vz * fz, vs = -r.vx * fz + r.vz * fx;
|
let vf = r.vx * fx + r.vz * fz, vs = -r.vx * fz + r.vz * fx;
|
||||||
if (canDrive) {
|
if (canDrive) {
|
||||||
const thr = clamp(inp.throttle || 0, -1, 1), trn = clamp(inp.turn || 0, -1, 1);
|
const thr = clamp(inp.throttle || 0, -1, 1), trn = clamp(inp.turn || 0, -1, 1);
|
||||||
let top = st.top * (r.boost > 0 ? 1.65 : 1) * (r.grab > 0 ? 0.6 : 1) * (thr < 0 ? 0.75 : 1);
|
const hurt = r.lost.wheels ? 0.75 : 1; // burst wheel: slower, clumsier
|
||||||
const target = thr * top, acc = st.accel * (r.boost > 0 ? 2 : 1);
|
const oil = r.onOil ? 0.55 : 1; // oil slick: hardly any steering
|
||||||
|
let top = st.top * hurt * (r.boost > 0 ? 1.65 : 1) * (r.grab > 0 ? 0.6 : 1) * (thr < 0 ? 0.75 : 1);
|
||||||
|
const target = thr * top, acc = st.accel * (r.lost.wheels ? 0.85 : 1) * (r.boost > 0 ? 2 : 1);
|
||||||
const braking = Math.abs(target) < Math.abs(vf) || target * vf < 0;
|
const braking = Math.abs(target) < Math.abs(vf) || target * vf < 0;
|
||||||
const rate = acc * (braking ? 1.6 : 1) * dt;
|
const rate = acc * (braking ? 1.6 : 1) * dt;
|
||||||
vf += clamp(target - vf, -rate, rate);
|
vf += clamp(target - vf, -rate, rate);
|
||||||
r.av += (trn * st.turn - r.av) * Math.min(1, 12 * dt);
|
r.av += (trn * st.turn * (r.lost.wheels ? 0.8 : 1) * oil - r.av) * Math.min(1, 12 * dt);
|
||||||
} else {
|
} else {
|
||||||
r.av *= Math.max(0, 1 - 6 * dt);
|
r.av *= Math.max(0, 1 - 6 * dt);
|
||||||
}
|
}
|
||||||
if (grounded && !held) {
|
if (grounded && !held) {
|
||||||
vs *= Math.max(0, 1 - st.grip * dt);
|
vs *= Math.max(0, 1 - st.grip * (r.onOil ? 0.3 : 1) * dt);
|
||||||
if (!canDrive) vf *= Math.max(0, 1 - 2.5 * dt);
|
if (!canDrive) vf *= Math.max(0, 1 - 2.5 * dt);
|
||||||
else if (!(inp.throttle)) vf *= Math.max(0, 1 - 3 * dt);
|
else if (!(inp.throttle)) vf *= Math.max(0, 1 - 3 * dt);
|
||||||
}
|
}
|
||||||
@@ -175,20 +300,32 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// spike walls
|
// spike walls (follow the arena outline: square, octagon or round)
|
||||||
const lim = ARENA.half - st.rad * 0.9;
|
const rad = st.rad * 0.9;
|
||||||
for (const ax of ['x', 'z']) {
|
const w = wallPush(s.arena, r.x, r.z, rad);
|
||||||
const vk = ax === 'x' ? 'vx' : 'vz';
|
if (w) {
|
||||||
if (Math.abs(r[ax]) > lim) {
|
r.x = w.x; r.z = w.z;
|
||||||
const sgn = Math.sign(r[ax]), vn = r[vk] * sgn;
|
const vn = -(r.vx * w.nx + r.vz * w.nz); // speed straight into the wall
|
||||||
r[ax] = sgn * lim;
|
if (vn > 0) {
|
||||||
if (vn > 0) {
|
if (vn > 1.8 && !r.out) {
|
||||||
if (vn > 1.8 && !r.out) {
|
s.events.push({ type: 'wall', who: r.i, x: r.x, z: r.z, speed: vn });
|
||||||
s.events.push({ type: 'wall', who: r.i, x: r.x, z: r.z, speed: vn });
|
damage(s, r, (vn - 1.8) * 4.5, null, { kind: 'spikes' });
|
||||||
damage(s, r, (vn - 1.8) * 4.5, null, { kind: 'spikes' });
|
// slammed into the spikes hard -> bounces up and can land on its back
|
||||||
}
|
if (vn > 3.5 && r.y < 0.05 && !r.st.invertible && !r.st.lowProfile && s.rand() < 0.3) { r.vy = Math.max(r.vy, 2); r.flipped = 2.2; r.av += (s.rand() - 0.5) * 6; }
|
||||||
r[vk] = -r[vk] * 0.45;
|
|
||||||
}
|
}
|
||||||
|
r.vx += w.nx * vn * 1.45; r.vz += w.nz * vn * 1.45; // bounce (0.45 restitution)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// static obstacles: drive into one and you stop, hit it hard and it hurts
|
||||||
|
const bp = blockPush(s.arena, r, rad);
|
||||||
|
if (bp) {
|
||||||
|
const vn = -(r.vx * bp.nx + r.vz * bp.nz);
|
||||||
|
if (vn > 0) {
|
||||||
|
if (vn > 2.2 && !r.out) {
|
||||||
|
s.events.push({ type: 'wall', who: r.i, x: r.x, z: r.z, speed: vn });
|
||||||
|
damage(s, r, (vn - 2.2) * 2.6, null, { kind: 'ram' });
|
||||||
|
}
|
||||||
|
r.vx += bp.nx * vn * 1.3; r.vz += bp.nz * vn * 1.3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,17 +356,25 @@
|
|||||||
const facing = fx * sx + fz * sz;
|
const facing = fx * sx + fz * sz;
|
||||||
const myV = me.vx * sx + me.vz * sz;
|
const myV = me.vx * sx + me.vz * sz;
|
||||||
if (facing > 0.55 && myV > 1.2) {
|
if (facing > 0.55 && myV > 1.2) {
|
||||||
const w = me.st.weapon;
|
const w = weaponOf(me);
|
||||||
const ram = w && w.type === 'wedge' ? w.ram : 1;
|
const ram = w && w.type === 'wedge' ? w.ram : 1;
|
||||||
damage(s, e, (impact - 1) * 2.2 * ram, me, { kind: 'ram' });
|
damage(s, e, (impact - 1) * 2.2 * ram, me, { kind: 'ram' });
|
||||||
if (w && w.type === 'wedge' && e.y < 0.05 && !e.st.lowProfile) { e.vy = 2.6; e.stun = Math.max(e.stun, 0.25); }
|
// a wedge scoops lighter robots up; any hard enough ram can send one tumbling onto its roof
|
||||||
|
if (w && w.type === 'wedge' && e.y < 0.05 && !e.st.lowProfile) {
|
||||||
|
const light = Math.sqrt(me.st.mass / e.st.mass);
|
||||||
|
e.vy = Math.max(e.vy, 2.3 * light); e.stun = Math.max(e.stun, 0.25);
|
||||||
|
if (!e.st.invertible && !e.st.lowProfile && s.rand() < 0.3 * light && impact > 3) { e.flipped = 2.2; e.av += (s.rand() - 0.5) * 6; }
|
||||||
|
} else if (impact > 4.5 && e.y < 0.05 && !e.st.lowProfile && !e.st.invertible) {
|
||||||
|
const light = Math.sqrt(me.st.mass / e.st.mass);
|
||||||
|
if (s.rand() < 0.22 * light) { e.vy = Math.max(e.vy, 1.8 * light); e.flipped = 2.2; e.av += (s.rand() - 0.5) * 5; s.events.push({ type: 'flip', who: e.i, x: e.x, z: e.z }); }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function weapons(s, r, e, inp, dt) {
|
function weapons(s, r, e, inp, dt) {
|
||||||
const ok = !r.dead && !r.out && r.lifted <= 0 && r.grabbedBy === null && r.flipped <= 0;
|
const ok = !r.dead && !r.out && r.lifted <= 0 && r.grabbedBy === null && r.flipped <= 0;
|
||||||
const w = r.st.weapon, [fx, fz] = fwd(r);
|
const w = weaponOf(r), [fx, fz] = fwd(r);
|
||||||
r.sawOn = false; r.flameOn = false; r.gunOn = false;
|
r.sawOn = false; r.flameOn = false; r.gunOn = false;
|
||||||
if (r.swing > 0) { // hammer comes down
|
if (r.swing > 0) { // hammer comes down
|
||||||
r.swing -= dt;
|
r.swing -= dt;
|
||||||
@@ -262,7 +407,7 @@
|
|||||||
e.vx += fx * 3 * light; e.vz += fz * 3 * light;
|
e.vx += fx * 3 * light; e.vz += fz * 3 * light;
|
||||||
e.av += (s.rand() - 0.5) * 6;
|
e.av += (s.rand() - 0.5) * 6;
|
||||||
damage(s, e, w.dmg, r, { kind: 'flip' });
|
damage(s, e, w.dmg, r, { kind: 'flip' });
|
||||||
if (!e.st.invertible && s.rand() < (e.st.lowProfile ? 0.3 : 0.55)) e.flipped = 3.5;
|
if (!e.st.invertible && s.rand() < (e.st.lowProfile ? 0.25 : 0.45)) e.flipped = 2.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -284,6 +429,33 @@
|
|||||||
s.events.push({ type: 'grab', who: r.i, x: e.x, z: e.z });
|
s.events.push({ type: 'grab', who: r.i, x: e.x, z: e.z });
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'lifter':
|
||||||
|
// scoop: tips the enemy up again and again (short cooldown) - made for shoving into the pit
|
||||||
|
if (inp.fire && r.cd <= 0) {
|
||||||
|
r.cd = w.cd; r.flipAnim = 0.3;
|
||||||
|
s.events.push({ type: 'flip', who: r.i, x: r.x + fx, z: r.z + fz });
|
||||||
|
if (inZone(s, r, e) && e.y < 0.2 && e.grabbedBy === null && e.lifted <= 0) {
|
||||||
|
const light = Math.sqrt(70 / e.st.mass);
|
||||||
|
e.vy = Math.max(e.vy, w.launch * light * 0.8);
|
||||||
|
e.vx += fx * 1.6 * light; e.vz += fz * 1.6 * light;
|
||||||
|
e.stun = Math.max(e.stun, 0.3); // wheels off the floor: no steering
|
||||||
|
damage(s, e, w.dmg, r, { kind: 'flip' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'vspinner':
|
||||||
|
// vertical disc: throws the enemy into the air instead of sideways
|
||||||
|
r.spin = inp.fire ? Math.min(1, r.spin + dt / w.spinup) : Math.max(0, r.spin - dt * 0.35);
|
||||||
|
if (r.spin > 0.25 && r.cd <= 0 && inZone(s, r, e)) {
|
||||||
|
const k = r.spin, light = Math.sqrt(70 / e.st.mass);
|
||||||
|
damage(s, e, w.dmg * k, r, { kind: 'spin' });
|
||||||
|
e.vy = Math.max(e.vy, 6.5 * k * light);
|
||||||
|
e.vx += fx * 1.5 * k; e.vz += fz * 1.5 * k; e.av += 7 * k;
|
||||||
|
if (!e.st.invertible && s.rand() < 0.5 * k) e.flipped = 2.2;
|
||||||
|
r.spin *= 0.3; r.cd = 0.35;
|
||||||
|
s.events.push({ type: 'spinhit', who: r.i, x: (r.x + e.x) / 2, z: (r.z + e.z) / 2, k });
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'spinner':
|
case 'spinner':
|
||||||
r.spin = inp.fire ? Math.min(1, r.spin + dt / w.spinup) : Math.max(0, r.spin - dt * 0.35);
|
r.spin = inp.fire ? Math.min(1, r.spin + dt / w.spinup) : Math.max(0, r.spin - dt * 0.35);
|
||||||
if (r.spin > 0.25 && r.cd <= 0 && inZone(s, r, e)) {
|
if (r.spin > 0.25 && r.cd <= 0 && inZone(s, r, e)) {
|
||||||
@@ -297,27 +469,45 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (w && w.type === 'spinner') r.spin = Math.max(0, r.spin - dt * 0.5);
|
} else if (w && (w.type === 'spinner' || w.type === 'vspinner')) r.spin = Math.max(0, r.spin - dt * 0.5);
|
||||||
|
|
||||||
// turret: turns towards the enemy by itself
|
// turret is bolted facing forward: you aim it by turning the robot, it does not track the enemy
|
||||||
const t = r.st.tower;
|
const t = towerOf(r);
|
||||||
if (!t) return;
|
if (!t) return;
|
||||||
const want = Math.atan2(e.z - r.z, e.x - r.x), diff = wrap(want - r.turretA);
|
r.turretA = r.a;
|
||||||
r.turretA = wrap(r.turretA + clamp(diff, -3.2 * dt, 3.2 * dt));
|
|
||||||
if (!ok || !inp.fire2) return;
|
if (!ok || !inp.fire2) return;
|
||||||
|
const want = Math.atan2(e.z - r.z, e.x - r.x);
|
||||||
const dist = Math.hypot(e.x - r.x, e.z - r.z), aimed = Math.abs(wrap(want - r.turretA));
|
const dist = Math.hypot(e.x - r.x, e.z - r.z), aimed = Math.abs(wrap(want - r.turretA));
|
||||||
if (t.type === 'flamer') {
|
if (t.type === 'flamer') {
|
||||||
r.flameOn = true;
|
r.flameOn = true;
|
||||||
if (dist < t.range + e.st.rad && aimed < t.cone && !e.out) damage(s, e, t.dps * dt, r, { pierce: 0.5, noZone: true, kind: 'fire', tick: true });
|
if (dist < t.range + e.st.rad && aimed < t.cone && !e.out) damage(s, e, t.dps * dt, r, { pierce: 0.5, noZone: true, kind: 'fire', tick: true });
|
||||||
} else if (t.type === 'minigun') {
|
} else if (t.type === 'minigun') {
|
||||||
r.gunOn = aimed < 0.25;
|
r.gunOn = true; // always fires straight ahead, hits only what is in front
|
||||||
if (r.gunOn && dist < t.range && !e.out) {
|
if (aimed < 0.25 && dist < t.range && !e.out) {
|
||||||
damage(s, e, t.dps * dt, r, { kind: 'bullet', tick: true });
|
damage(s, e, t.dps * dt, r, { kind: 'bullet', tick: true });
|
||||||
r.fx -= dt; if (r.fx <= 0) { r.fx = 0.08; s.events.push({ type: 'sparks', x: e.x, z: e.z, n: 2, y: 0.4 }); }
|
r.fx -= dt; if (r.fx <= 0) { r.fx = 0.08; s.events.push({ type: 'sparks', x: e.x, z: e.z, n: 2, y: 0.4 }); }
|
||||||
}
|
}
|
||||||
} else if (t.type === 'rockets' && r.cd2 <= 0) {
|
} else if (t.type === 'zapper') {
|
||||||
|
r.gunOn = true; // short electric arc straight ahead
|
||||||
|
if (aimed < 0.4 && dist < t.range + e.st.rad && !e.out) {
|
||||||
|
damage(s, e, t.dps * dt, r, { pierce: 0.8, noZone: true, kind: 'bullet', tick: true });
|
||||||
|
e.stun = Math.max(e.stun, 0.12);
|
||||||
|
}
|
||||||
|
} else if (t.type === 'mortar' && r.cd2 <= 0) {
|
||||||
r.cd2 = t.cd;
|
r.cd2 = t.cd;
|
||||||
s.rockets.push({ owner: r.i, x: r.x, z: r.z, y: r.st.h + 0.45, a: r.turretA, t: 3.2, sp: 6.5 });
|
// lobbed shell: flies a real arc and bursts where it lands
|
||||||
|
const flight = clamp(dist / 9, 0.5, 1.8);
|
||||||
|
s.rockets.push({ kind: 'mortar', owner: r.i, x: r.x, z: r.z, y: r.st.h + 0.5, a: r.turretA,
|
||||||
|
sp: Math.min(dist / flight, 14), vy: 9 * flight, t: 5, dmg: t.dmg, splash: t.splash });
|
||||||
|
s.events.push({ type: 'launch', who: r.i, x: r.x, z: r.z });
|
||||||
|
} else if ((t.type === 'rockets' || t.type === 'swarm') && r.cd2 <= 0) {
|
||||||
|
r.cd2 = t.cd;
|
||||||
|
const swarm = t.type === 'swarm', n = swarm ? (t.shots || 3) : 1;
|
||||||
|
for (let k = 0; k < n; k++) {
|
||||||
|
const spread = swarm ? (k - (n - 1) / 2) * 0.35 : 0;
|
||||||
|
s.rockets.push({ kind: 'rocket', owner: r.i, x: r.x, z: r.z, y: r.st.h + 0.45, a: r.turretA + spread,
|
||||||
|
t: swarm ? 8 : 5, sp: 6.5, max: swarm ? 13 : 11, turn: swarm ? 3.4 : 2.4, dmg: t.dmg });
|
||||||
|
}
|
||||||
s.events.push({ type: 'launch', who: r.i, x: r.x, z: r.z });
|
s.events.push({ type: 'launch', who: r.i, x: r.x, z: r.z });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -327,21 +517,87 @@
|
|||||||
if (e.grabbedBy === r.i) { e.grabbedBy = null; }
|
if (e.grabbedBy === r.i) { e.grabbedBy = null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gadgets (input.fire3): one-shot abilities on a cooldown
|
||||||
|
function gadgets(s, r, e, inp, dt) {
|
||||||
|
r.gcd = Math.max(0, r.gcd - dt);
|
||||||
|
if (r.shield > 0) r.shield = Math.max(0, r.shield - dt);
|
||||||
|
const g = r.st.gadget;
|
||||||
|
if (!g || r.out || r.dead || !inp.fire3 || r.gcd > 0) return;
|
||||||
|
const held = r.lifted > 0 || r.grabbedBy !== null;
|
||||||
|
switch (g.type) {
|
||||||
|
case 'righter': // flip back upright
|
||||||
|
if (r.flipped > 0) { r.flipped = 0; r.av += (s.rand() - 0.5) * 2; }
|
||||||
|
r.gcd = g.cd;
|
||||||
|
s.events.push({ type: 'righted', who: r.i, x: r.x, z: r.z });
|
||||||
|
break;
|
||||||
|
case 'turbo': // speed burst (reuses the boost mechanic)
|
||||||
|
if (held || r.flipped > 0 || r.stun > 0) return;
|
||||||
|
r.boost = Math.max(r.boost, g.dur); r.gcd = g.cd;
|
||||||
|
break;
|
||||||
|
case 'shield': // temporary damage field
|
||||||
|
r.shield = g.dur; r.gcd = g.cd;
|
||||||
|
break;
|
||||||
|
case 'repair': // one charge = flat heal
|
||||||
|
if (r.gUses <= 0) return;
|
||||||
|
r.hp = Math.min(r.maxHp, r.hp + r.maxHp * g.heal); r.gUses--; r.gcd = g.cd;
|
||||||
|
break;
|
||||||
|
case 'emp': // stun the enemy if close
|
||||||
|
r.gcd = g.cd;
|
||||||
|
if (!e.out && Math.hypot(e.x - r.x, e.z - r.z) < g.range + e.st.rad) {
|
||||||
|
e.stun = Math.max(e.stun, g.stun); e.spin = 0; e.boost = 0; e.shield = 0;
|
||||||
|
s.events.push({ type: 'emp_hit', who: e.i, x: e.x, z: e.z });
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
s.events.push({ type: 'gadget', who: r.i, g: g.type, x: r.x, z: r.z });
|
||||||
|
}
|
||||||
|
|
||||||
|
// should the AI / autofire helper fire the gadget now?
|
||||||
|
function wantGadget(s, me, e) {
|
||||||
|
const g = me.st.gadget;
|
||||||
|
if (!g || me.gcd > 0 || me.out || me.dead) return false;
|
||||||
|
const dist = e.out ? 999 : Math.hypot(e.x - me.x, e.z - me.z);
|
||||||
|
switch (g.type) {
|
||||||
|
case 'righter': return me.flipped > 0;
|
||||||
|
case 'turbo': return me.flipped <= 0 && me.stun <= 0 && dist > 2 && dist < 9;
|
||||||
|
case 'shield': return dist < 3 && me.flipped <= 0;
|
||||||
|
case 'repair': return me.gUses > 0 && me.hp < me.maxHp * 0.45;
|
||||||
|
case 'emp': return !e.out && dist < g.range * 0.9 && (e.boost > 0 || e.spin > 0.2 || dist < 2.5);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function rockets(s, dt) {
|
function rockets(s, dt) {
|
||||||
for (let i = s.rockets.length - 1; i >= 0; i--) {
|
for (let i = s.rockets.length - 1; i >= 0; i--) {
|
||||||
const k = s.rockets[i], tgt = s.robots[1 - k.owner], own = s.robots[k.owner];
|
const k = s.rockets[i], tgt = s.robots[1 - k.owner], own = s.robots[k.owner];
|
||||||
k.t -= dt;
|
k.t -= dt;
|
||||||
|
const wall = () => Math.abs(k.x) > s.arena.half || Math.abs(k.z) > s.arena.half;
|
||||||
|
if (k.kind === 'mortar') {
|
||||||
|
// thrown in an arc, bursts on the floor with a blast radius
|
||||||
|
k.vy -= 17 * dt;
|
||||||
|
k.x += Math.cos(k.a) * k.sp * dt; k.z += Math.sin(k.a) * k.sp * dt; k.y += k.vy * dt;
|
||||||
|
const direct = !tgt.out && k.y < 0.9 && Math.hypot(tgt.x - k.x, tgt.z - k.z) < tgt.st.rad + 0.2;
|
||||||
|
if (direct || k.y <= 0.06 || wall() || k.t <= 0) {
|
||||||
|
s.events.push({ type: 'boom', x: k.x, z: k.z, y: Math.max(0.12, k.y), big: true });
|
||||||
|
if (!tgt.out) {
|
||||||
|
const d = Math.hypot(tgt.x - k.x, tgt.z - k.z);
|
||||||
|
if (d < k.splash) damage(s, tgt, k.dmg * (1 - (d / k.splash) * 0.6), own, { from: { x: k.x, z: k.z }, kind: 'rocket' });
|
||||||
|
}
|
||||||
|
s.rockets.splice(i, 1);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// seeker: turns after the target and can chase it across the arena
|
||||||
const want = Math.atan2(tgt.z - k.z, tgt.x - k.x);
|
const want = Math.atan2(tgt.z - k.z, tgt.x - k.x);
|
||||||
if (!tgt.out) k.a = wrap(k.a + clamp(wrap(want - k.a), -2.4 * dt, 2.4 * dt));
|
if (!tgt.out) k.a = wrap(k.a + clamp(wrap(want - k.a), -(k.turn || 2.4) * dt, (k.turn || 2.4) * dt));
|
||||||
k.sp = Math.min(11, k.sp + dt * 6);
|
k.sp = Math.min(k.max || 11, k.sp + dt * 6);
|
||||||
k.x += Math.cos(k.a) * k.sp * dt; k.z += Math.sin(k.a) * k.sp * dt;
|
k.x += Math.cos(k.a) * k.sp * dt; k.z += Math.sin(k.a) * k.sp * dt;
|
||||||
k.y += ((tgt.y + 0.35) - k.y) * Math.min(1, dt * 3);
|
k.y += ((tgt.y + 0.35) - k.y) * Math.min(1, dt * 3);
|
||||||
const hit = !tgt.out && Math.hypot(tgt.x - k.x, tgt.z - k.z) < tgt.st.rad + 0.1;
|
const hit = !tgt.out && Math.hypot(tgt.x - k.x, tgt.z - k.z) < tgt.st.rad + 0.1;
|
||||||
const wall = Math.abs(k.x) > ARENA.half || Math.abs(k.z) > ARENA.half;
|
if (hit || wall() || k.t <= 0) {
|
||||||
if (hit || wall || k.t <= 0) {
|
|
||||||
s.events.push({ type: 'boom', x: k.x, z: k.z, y: k.y });
|
s.events.push({ type: 'boom', x: k.x, z: k.z, y: k.y });
|
||||||
if (hit) {
|
if (hit) {
|
||||||
damage(s, tgt, own.st.tower.dmg, own, { from: { x: k.x - Math.cos(k.a), z: k.z - Math.sin(k.a) }, kind: 'rocket' });
|
damage(s, tgt, k.dmg != null ? k.dmg : 17, own, { from: { x: k.x - Math.cos(k.a), z: k.z - Math.sin(k.a) }, kind: 'rocket' });
|
||||||
tgt.vx += Math.cos(k.a) * 1.6; tgt.vz += Math.sin(k.a) * 1.6;
|
tgt.vx += Math.cos(k.a) * 1.6; tgt.vz += Math.sin(k.a) * 1.6;
|
||||||
}
|
}
|
||||||
s.rockets.splice(i, 1);
|
s.rockets.splice(i, 1);
|
||||||
@@ -350,7 +606,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hazards(s, dt) {
|
function hazards(s, dt) {
|
||||||
const A = ARENA, R = s.robots;
|
const A = s.arena, R = s.robots;
|
||||||
for (const r of R) {
|
for (const r of R) {
|
||||||
if (r.out) continue;
|
if (r.out) continue;
|
||||||
const ground = r.y < 0.15 && r.lifted <= 0;
|
const ground = r.y < 0.15 && r.lifted <= 0;
|
||||||
@@ -364,6 +620,15 @@
|
|||||||
}
|
}
|
||||||
// flame grilles
|
// flame grilles
|
||||||
for (const h of A.flames) if (ground && hazardOn(h, s.t) && inRect(h, r.x, r.z, r.st.rad * 0.3)) damage(s, r, 14 * dt, null, { pierce: 0.5, kind: 'fire', tick: true });
|
for (const h of A.flames) if (ground && hazardOn(h, s.t) && inRect(h, r.x, r.z, r.st.rad * 0.3)) damage(s, r, 14 * dt, null, { pierce: 0.5, kind: 'fire', tick: true });
|
||||||
|
// conveyor belts drag everything that stands on them
|
||||||
|
for (const b of A.belts) if (ground && inRect(b, r.x, r.z, r.st.rad * 0.2)) { r.vx += b.ax * b.force * dt; r.vz += b.az * b.force * dt; }
|
||||||
|
// oil slicks (checked here, used by drive() on the next step)
|
||||||
|
r.onOil = ground && A.oil.some(o => Math.hypot(r.x - o.x, r.z - o.z) < o.r + r.st.rad * 0.4);
|
||||||
|
// wall rams shove anyone loitering in front of them
|
||||||
|
for (const m of A.rams) if (ground && hazardOn(m, s.t) && inRect(m, r.x, r.z, r.st.rad * 0.3)) {
|
||||||
|
r.vx += m.nx * 26 * dt; r.vz += m.nz * 26 * dt;
|
||||||
|
damage(s, r, 9 * dt, null, { kind: 'ram', tick: true });
|
||||||
|
}
|
||||||
// pit
|
// pit
|
||||||
if (s.pitOpen >= 1 && ground && r.grabbedBy === null && inRect(A.pit, r.x, r.z, -0.15)) {
|
if (s.pitOpen >= 1 && ground && r.grabbedBy === null && inRect(A.pit, r.x, r.z, -0.15)) {
|
||||||
r.out = 'pit'; r.vx *= 0.2; r.vz *= 0.2;
|
r.out = 'pit'; r.vx *= 0.2; r.vz *= 0.2;
|
||||||
@@ -416,13 +681,40 @@
|
|||||||
c.st = 'idle'; c.t = 2.5; r.lifted = 0; r.vy = 0; r.craneT = 0;
|
c.st = 'idle'; c.t = 2.5; r.lifted = 0; r.vy = 0; r.craneT = 0;
|
||||||
s.events.push({ type: 'drop', who: r.i, x: r.x, z: r.z });
|
s.events.push({ type: 'drop', who: r.i, x: r.x, z: r.z });
|
||||||
damage(s, r, 8, null, { kind: 'drop' });
|
damage(s, r, 8, null, { kind: 'drop' });
|
||||||
if (!r.st.invertible && s.rand() < 0.5) r.flipped = 3.5;
|
if (!r.st.invertible && s.rand() < 0.4) r.flipped = 2.2;
|
||||||
c.who = -1;
|
c.who = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RC.Combat = { create, step, inZone, local };
|
// What the HUD shows per equipped slot (no DOM, so Node tests can check it):
|
||||||
|
// p = share of the cooldown still running (1 = just used, 0 = ready), on = doing its thing right now,
|
||||||
|
// n = charges left where a part has them (repair kit).
|
||||||
|
function cooldowns(r) {
|
||||||
|
const out = [], w = r.st.weapon, t = r.st.tower, g = r.st.gadget;
|
||||||
|
const broke = k => (r.lost && r.lost[k]) || false;
|
||||||
|
const frac = (left, full) => (full > 0 ? clamp(left / full, 0, 1) : 0);
|
||||||
|
if (w) {
|
||||||
|
const e = { slot: 'weapon', id: w.id, p: 0, on: false, broke: broke('weapon') };
|
||||||
|
if (w.type === 'saw') e.on = !!r.sawOn;
|
||||||
|
else if (w.type === 'spinner' || w.type === 'vspinner') { e.p = 1 - clamp(r.spin, 0, 1); e.on = r.spin > 0.25; }
|
||||||
|
else {
|
||||||
|
e.p = frac(r.cd, w.cd);
|
||||||
|
e.on = (w.type === 'hammer' && r.swing > 0) || (w.type === 'crusher' && r.grab > 0) || (w.type === 'wedge' && r.boost > 0);
|
||||||
|
}
|
||||||
|
out.push(e);
|
||||||
|
}
|
||||||
|
if (t) {
|
||||||
|
const e = { slot: 'tower', id: t.id, p: 0, on: false, broke: broke('tower') };
|
||||||
|
if (t.type === 'rockets' || t.type === 'mortar' || t.type === 'swarm') e.p = frac(r.cd2, t.cd);
|
||||||
|
else e.on = t.type === 'flamer' ? !!r.flameOn : !!r.gunOn; // minigun + zapper
|
||||||
|
out.push(e);
|
||||||
|
}
|
||||||
|
if (g) out.push({ slot: 'gadget', id: g.id, p: frac(r.gcd, g.cd), on: r.shield > 0 || (g.type === 'turbo' && r.boost > 0), n: g.charges ? r.gUses : undefined });
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
RC.Combat = { create, step, inZone, local, wantGadget, cooldowns };
|
||||||
if (typeof module !== 'undefined' && module.exports) module.exports = RC;
|
if (typeof module !== 'undefined' && module.exports) module.exports = RC;
|
||||||
})(typeof window !== 'undefined' ? window : globalThis);
|
})(typeof window !== 'undefined' ? window : globalThis);
|
||||||
|
|||||||
642
game/game.js
@@ -5,12 +5,17 @@
|
|||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
const $ = Kit.$;
|
const $ = Kit.$;
|
||||||
const W = 960, H = 540; // design size of the stage
|
const W = 1280, H = 720; // design size of the stage (16:9, higher res = denser UI)
|
||||||
const ID = 'robotclash'; // localStorage prefix
|
const ID = 'robotclash'; // localStorage prefix
|
||||||
|
|
||||||
// Paste the Firebase Realtime Database URL here to switch the online fame ranking on
|
// Paste the Firebase Realtime Database URL here to switch the online fame ranking on
|
||||||
// (docs/firebase/README.md). Empty = offline.
|
// (docs/firebase/README.md). Empty = offline.
|
||||||
const DB_URL = '';
|
const DB_URL = 'https://robot-clash-aa37b-default-rtdb.firebaseio.com';
|
||||||
|
// Online lobby + live PvP: paste the Web API key (Firebase console -> Project settings -> Web API key).
|
||||||
|
// Empty key -> leaderboard still works, but no login/lobby (menu hides 'Online').
|
||||||
|
const NET_CFG = { apiKey: 'AIzaSyCE29VQnubM_9ok46nnosg07MpvhZH3O5w', dbUrl: DB_URL };
|
||||||
|
// dev/test: ?netkey=<API key> tries online without editing the file; ?online jumps to the lobby/login
|
||||||
|
if (new URLSearchParams(location.search).get('netkey')) NET_CFG.apiKey = new URLSearchParams(location.search).get('netkey');
|
||||||
|
|
||||||
// Credits (standard for every game): shown on the title screen, links open in the normal browser
|
// Credits (standard for every game): shown on the title screen, links open in the normal browser
|
||||||
const DISCORD = 'https://discord.gg/Ej4JPmCZva';
|
const DISCORD = 'https://discord.gg/Ej4JPmCZva';
|
||||||
@@ -20,16 +25,32 @@
|
|||||||
const L = Kit.i18n(window.LANG, { prefix: ID });
|
const L = Kit.i18n(window.LANG, { prefix: ID });
|
||||||
const t = L.t;
|
const t = L.t;
|
||||||
const store = Kit.store(ID);
|
const store = Kit.store(ID);
|
||||||
const settings = Object.assign({ gfx: 'high', intro: true }, store.get('settings', {}));
|
// steer: 'simple' (keys = screen direction) | 'tank' · diff: 'easy' | 'normal' | 'hard' · autofire: weapon fires by itself in reach
|
||||||
|
const settings = Object.assign({ gfx: 'medium', intro: true, steer: 'tank', diff: 'easy', autofire: true, cam: 'fpv', arena: 'random' }, store.get('settings', {}));
|
||||||
|
// v2: Michael found "simple" steering worse -> tank is the default again, old saved choice reset once
|
||||||
|
// v3: fights start in first person (cockpit) -> old saved camera reset once
|
||||||
|
if (!settings.v || settings.v < 2) settings.steer = 'tank';
|
||||||
|
if (!settings.v || settings.v < 3) { settings.cam = 'fpv'; settings.v = 3; store.set('settings', settings); }
|
||||||
|
// difficulty: player hit points x, AI skill +
|
||||||
|
const DIFF = { easy: { hp: 1.4, skill: -0.2 }, normal: { hp: 1.15, skill: -0.05 }, hard: { hp: 0.95, skill: 0.12 } };
|
||||||
const saveSettings = () => store.set('settings', settings);
|
const saveSettings = () => store.set('settings', settings);
|
||||||
const accounts = RC.Accounts(ID);
|
const accounts = RC.Accounts(ID);
|
||||||
const newSave = () => ({
|
const newSave = () => ({
|
||||||
money: 400, fame: 0, best: 0, season: 1, beaten: 0, wins: 0, losses: 0, games: 0,
|
money: 800, fame: 0, best: 0, season: 1, beaten: 0, wins: 0, losses: 0, games: 0,
|
||||||
owned: Object.values(RC.STARTER).filter(Boolean), build: Object.assign({}, RC.STARTER),
|
owned: Object.values(RC.STARTER).filter(Boolean), build: Object.assign({}, RC.STARTER),
|
||||||
paint: { body: 0xff7a1a, accent: 0x15171b }, robotName: 'Clank', tutorialSeen: false,
|
paint: { body: 0xff7a1a, accent: 0x15171b }, robotName: 'Clank', flag: 'XX', tutorialSeen: false,
|
||||||
|
robots: [], active: 0, // hangar: saved robot builds; the active one mirrors build/paint/robotName
|
||||||
});
|
});
|
||||||
|
const MAX_ROBOTS = 6;
|
||||||
|
const newRobotDef = n => ({ name: n || 'Robot', build: Object.assign({}, RC.STARTER), paint: { body: 0xff7a1a, accent: 0x15171b, decal: null, drawn: false } });
|
||||||
|
// keep the active hangar slot in sync with the live build/paint/robotName before saving
|
||||||
|
function syncActive() {
|
||||||
|
if (!save || !save.robots || !save.robots[save.active]) return;
|
||||||
|
const r = save.robots[save.active];
|
||||||
|
r.name = save.robotName; r.build = save.build; r.paint = save.paint;
|
||||||
|
}
|
||||||
let slot = null, save = null; // per account, set by enterAccount()
|
let slot = null, save = null; // per account, set by enterAccount()
|
||||||
const persist = () => { if (slot && save) slot.save(save); };
|
const persist = () => { if (slot && save) { syncActive(); slot.save(save); } };
|
||||||
const audio = Kit.createAudio({
|
const audio = Kit.createAudio({
|
||||||
prefix: ID,
|
prefix: ID,
|
||||||
files: ['sfx_click', 'sfx_buy', 'sfx_hit', 'sfx_saw', 'sfx_boom', 'sfx_win', 'sfx_lose', 'music_title', 'music_garage', 'music_fight'],
|
files: ['sfx_click', 'sfx_buy', 'sfx_hit', 'sfx_saw', 'sfx_boom', 'sfx_win', 'sfx_lose', 'music_title', 'music_garage', 'music_fight'],
|
||||||
@@ -37,17 +58,23 @@
|
|||||||
});
|
});
|
||||||
const scores = Kit.scores({ url: DB_URL });
|
const scores = Kit.scores({ url: DB_URL });
|
||||||
const DEV = new URLSearchParams(location.search);
|
const DEV = new URLSearchParams(location.search);
|
||||||
|
if (DEV.has('touch')) document.body.classList.add('forcetouch'); // dev: &touch shows the touch pad on desktop
|
||||||
|
const net = RC.Net(NET_CFG);
|
||||||
|
const FLAGS = ['DE', 'AT', 'CH', 'GB', 'US', 'FR', 'ES', 'IT', 'NL', 'PL', 'TR', 'RU', 'BR', 'JP', 'KR', 'XX'];
|
||||||
|
const flagHtml = c => `<span class="fl fl-${FLAGS.includes(c) ? c : 'XX'}"></span>`;
|
||||||
|
const lobby = net.enabled ? RC.Lobby({ net, getProfile: () => ({ name: playerName(), flag: save.flag || 'XX', build: save.build, paint: { body: save.paint.body, accent: save.paint.accent }, fame: save.fame | 0 }) }) : null;
|
||||||
const fx = Kit.fx();
|
const fx = Kit.fx();
|
||||||
|
|
||||||
const input = Kit.input({
|
const input = Kit.input({
|
||||||
keys: {
|
keys: {
|
||||||
ArrowUp: 'up', w: 'up', ArrowDown: 'down', s: 'down', ArrowLeft: 'left', a: 'left', ArrowRight: 'right', d: 'right',
|
ArrowUp: 'up', w: 'up', ArrowDown: 'down', s: 'down', ArrowLeft: 'left', a: 'left', ArrowRight: 'right', d: 'right',
|
||||||
' ': 'fire', Shift: 'fire2', e: 'fire2', p: 'pause', Escape: 'pause', m: 'mute', Enter: 'ok',
|
' ': 'fire', Shift: 'fire2', e: 'fire2', g: 'fire3', p: 'pause', Escape: 'pause', m: 'mute', Enter: 'ok', c: 'cam',
|
||||||
},
|
},
|
||||||
onPress(a) {
|
onPress(a) {
|
||||||
if (mode === 'intro') { skipIntro(); return; }
|
if (mode === 'intro') { skipIntro(); return; }
|
||||||
if (a === 'pause') togglePause();
|
if (a === 'pause') togglePause();
|
||||||
else if (a === 'mute') toggleMute();
|
else if (a === 'mute') toggleMute();
|
||||||
|
else if (a === 'cam' && mode === 'fight') cycleCam();
|
||||||
else if (a === 'ok') { const b = overlay.querySelector('button.primary'); if (b && !b.disabled) b.click(); }
|
else if (a === 'ok') { const b = overlay.querySelector('button.primary'); if (b && !b.disabled) b.click(); }
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -79,6 +106,7 @@
|
|||||||
case 'press': audio.sfx('sfx_hit'); audio.noise(0.5, 0.65, 300); audio.tone(55, 0.5, 'sine', 0.6, -20); break;
|
case 'press': audio.sfx('sfx_hit'); audio.noise(0.5, 0.65, 300); audio.tone(55, 0.5, 'sine', 0.6, -20); break;
|
||||||
case 'crane': audio.tone(140, 0.6, 'sawtooth', 0.07, 140); break;
|
case 'crane': audio.tone(140, 0.6, 'sawtooth', 0.07, 140); break;
|
||||||
case 'drop': case 'land': audio.noise(0.22, 0.35, 500); break;
|
case 'drop': case 'land': audio.noise(0.22, 0.35, 500); break;
|
||||||
|
case 'broke': audio.sfx('sfx_hit'); audio.noise(0.45, 0.5, 900); audio.tone(240, 0.35, 'sawtooth', 0.22, -190); break;
|
||||||
case 'pit_open': for (let k = 0; k < 3; k++) audio.tone(700, 0.3, 'square', 0.12, -250, k * 0.4); break;
|
case 'pit_open': for (let k = 0; k < 3; k++) audio.tone(700, 0.3, 'square', 0.12, -250, k * 0.4); break;
|
||||||
case 'pit': audio.tone(420, 1.2, 'sawtooth', 0.14, -360); break;
|
case 'pit': audio.tone(420, 1.2, 'sawtooth', 0.14, -360); break;
|
||||||
case 'grab': audio.tone(150, 0.25, 'square', 0.12, -60); break;
|
case 'grab': audio.tone(150, 0.25, 'square', 0.12, -60); break;
|
||||||
@@ -100,7 +128,9 @@
|
|||||||
let ctx = cv.getContext('2d');
|
let ctx = cv.getContext('2d');
|
||||||
let view = null;
|
let view = null;
|
||||||
try { view = RC.Render($('gl'), W, H); view.setQuality(settings.gfx); } catch (err) { console.error(err); }
|
try { view = RC.Render($('gl'), W, H); view.setQuality(settings.gfx); } catch (err) { console.error(err); }
|
||||||
Kit.fit($('app'), { canvases: [[cv, W, H]], onFit(sc) { ctx = cv.getContext('2d'); if (view) view.resize(sc); } });
|
// cap upscaling so the UI does not get huge on big / high-DPI screens (960x540 stage, max ~2x)
|
||||||
|
Kit.fit($('app'), { max: 2.0, margin: document.documentElement.classList.contains('exe') ? 1 : 0.98,
|
||||||
|
canvases: [[cv, W, H]], onFit(sc) { ctx = cv.getContext('2d'); if (view) view.resize(sc); } });
|
||||||
Kit.host.dragArea(document.body);
|
Kit.host.dragArea(document.body);
|
||||||
const hex = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
const hex = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
||||||
const img = name => Kit.asset('assets/Sprites/' + name);
|
const img = name => Kit.asset('assets/Sprites/' + name);
|
||||||
@@ -109,9 +139,11 @@
|
|||||||
$('icoFame').innerHTML = `<img src="${img('ico_fame.png')}" alt="" onerror="this.classList.add('missing')">`;
|
$('icoFame').innerHTML = `<img src="${img('ico_fame.png')}" alt="" onerror="this.classList.add('missing')">`;
|
||||||
|
|
||||||
const shop = RC.Shop({
|
const shop = RC.Shop({
|
||||||
t, getSave: () => save, onSave: persist,
|
t, getSave: () => save, onSave: () => { persist(); hud(); }, // buy/sell/rename -> header
|
||||||
onBuild: () => view.showGarage(save.build, paintObj()),
|
onBuild: () => view.showGarage(save.build, paintObj()),
|
||||||
onPaint: () => view.setPaint(paintObj()),
|
onPaint: () => view.setPaint(paintObj()),
|
||||||
|
onPreview: b => { if (mode === 'garage') view.showGarage(b, paintObj()); }, // show the selected part on the robot
|
||||||
|
onHangarView: el => renderHangar(el), // Hangar tab content
|
||||||
sfx: SFX,
|
sfx: SFX,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -147,21 +179,33 @@
|
|||||||
overlay.style.backgroundImage = opt.bg ? `linear-gradient(rgba(5,6,10,.55), rgba(5,6,10,.75)), url("${img(opt.bg)}")` : '';
|
overlay.style.backgroundImage = opt.bg ? `linear-gradient(rgba(5,6,10,.55), rgba(5,6,10,.75)), url("${img(opt.bg)}")` : '';
|
||||||
}
|
}
|
||||||
function hideOverlay() { overlay.classList.add('hide'); overlay.innerHTML = ''; overlay.style.backgroundImage = ''; }
|
function hideOverlay() { overlay.classList.add('hide'); overlay.innerHTML = ''; overlay.style.backgroundImage = ''; }
|
||||||
|
// fade a menu in once; the class is dropped again so live lists (lobby) do not flicker on every refresh
|
||||||
|
let enterT = 0;
|
||||||
|
function overlayEnter() { overlay.classList.add('enter'); clearTimeout(enterT); enterT = setTimeout(() => overlay.classList.remove('enter'), 220); }
|
||||||
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
const esc = s => String(s).replace(/[&<>"]/g, c => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c]));
|
||||||
const seasonMul = () => 1 + (save.season - 1) * 0.5;
|
const seasonMul = () => 1 + (save.season - 1) * 0.5;
|
||||||
const weaponName = b => (b.weapon ? RC.PARTS[b.weapon].name : t('unarmed')) + (b.tower ? ' + ' + RC.PARTS[b.tower].name : '');
|
const weaponName = b => (b.weapon ? RC.PARTS[b.weapon].name : t('unarmed')) + (b.tower ? ' + ' + RC.PARTS[b.tower].name : '');
|
||||||
const playerName = () => (accounts.current && !accounts.current.guest ? accounts.current.name : save ? save.robotName : '');
|
// league robots dressed like their ComfyGen portraits (looks.js)
|
||||||
|
const oppPaint = o => (RC.LOOKS && RC.LOOKS[o.id] ? Object.assign({}, o.paint, { layer: RC.lookLayer(o.id, o.paint), drawn: true, look: RC.LOOKS[o.id] }) : o.paint);
|
||||||
|
const fbUser = () => (net && net.enabled ? net.auth.current : null);
|
||||||
|
const fbAcc = () => (fbUser() && !fbUser().guest ? fbUser() : null); // real (e-mail) account
|
||||||
|
const playerName = () => (fbUser() ? fbUser().name : accounts.current && !accounts.current.guest ? accounts.current.name : save ? save.robotName : '');
|
||||||
|
// save slot: Firebase account -> robotclash.save.fb_<uid>, else local profile / guest
|
||||||
|
const saveKey = () => (fbAcc() ? ID + '.save.fb_' + fbAcc().uid : accounts.saveKey());
|
||||||
|
|
||||||
function hud() {
|
function hud() {
|
||||||
$('hMoney').textContent = save ? Kit.fmt(save.money) : '–';
|
$('hMoney').textContent = save ? Kit.fmt(save.money) : '–';
|
||||||
$('hFame').textContent = save ? Kit.fmt(save.fame) : '–';
|
$('hFame').textContent = save ? Kit.fmt(save.fame) : '–';
|
||||||
$('hLeague').textContent = save ? t('league_chip', { s: save.season, n: save.beaten, m: RC.LEAGUE.length }) : '–';
|
$('hLeague').textContent = save ? t('league_chip', { s: save.season, n: save.beaten, m: RC.LEAGUE.length }) : '–';
|
||||||
$('hUser').textContent = accounts.current ? (accounts.current.guest ? '👤 ' + t('guest') : '👤 ' + accounts.current.name) : '👤 –';
|
$('hUser').textContent = fbUser() ? '👤 ' + fbUser().name : accounts.current ? (accounts.current.guest ? '👤 ' + t('guest') : '👤 ' + accounts.current.name) : save ? '👤 ' + t('guest') : '👤 –';
|
||||||
$('bMute').textContent = audio.muted ? t('sound_off') : t('sound_on');
|
$('bMute').textContent = audio.muted ? '🔇' : '🔊';
|
||||||
|
$('bMute').title = (audio.muted ? t('sound_off') : t('sound_on')) + ' (M)';
|
||||||
}
|
}
|
||||||
function setScreen(m) {
|
function setScreen(m) {
|
||||||
if (m !== 'garage' && painter.isOpen) painter.close();
|
if (m !== 'garage' && painter.isOpen) painter.close();
|
||||||
|
if (m !== mode) overlayEnter();
|
||||||
mode = m;
|
mode = m;
|
||||||
|
document.body.dataset.mode = m; // CSS shows/places the HUD per screen
|
||||||
document.body.classList.toggle('fighting', m === 'fight' || m === 'pause');
|
document.body.classList.toggle('fighting', m === 'fight' || m === 'pause');
|
||||||
show('shop', m === 'garage');
|
show('shop', m === 'garage');
|
||||||
show('fightHud', m === 'fight' || m === 'pause' || m === 'result');
|
show('fightHud', m === 'fight' || m === 'pause' || m === 'result');
|
||||||
@@ -175,7 +219,7 @@
|
|||||||
hideOverlay();
|
hideOverlay();
|
||||||
if (!view) { showTitle(); return; }
|
if (!view) { showTitle(); return; }
|
||||||
const a = RC.LEAGUE[7], b = RC.LEAGUE[4];
|
const a = RC.LEAGUE[7], b = RC.LEAGUE[4];
|
||||||
view.showIntro([a.build, b.build], [a.paint, b.paint]);
|
view.showIntro([a.build, b.build], [oppPaint(a), oppPaint(b)]);
|
||||||
introCue = 0;
|
introCue = 0;
|
||||||
audio.music('music_title');
|
audio.music('music_title');
|
||||||
if (!settings.intro) view.skipIntro();
|
if (!settings.intro) view.skipIntro();
|
||||||
@@ -196,22 +240,31 @@
|
|||||||
function showTitle() {
|
function showTitle() {
|
||||||
setScreen('title');
|
setScreen('title');
|
||||||
audio.music('music_title');
|
audio.music('music_title');
|
||||||
const acc = accounts.current && !accounts.current.guest ? accounts.current : null;
|
const fb = net && net.enabled;
|
||||||
|
const acc = fb ? fbAcc() : (accounts.current && !accounts.current.guest ? accounts.current : null);
|
||||||
|
const online = fb ? `<button id="bOnline">🌍 ${t('online_play')}</button>` : '';
|
||||||
const btns = acc
|
const btns = acc
|
||||||
? `<button class="primary" id="bPlay">${t('play_as', { name: esc(acc.name) })}</button><button id="bSwitch">${t('switch_account')}</button>`
|
? `<button class="primary" id="bPlay">${t('play_as', { name: esc(acc.name) })}</button>${online}<button id="bSwitch">${t('switch_account')}</button>`
|
||||||
: `<button class="primary" id="bLogin">${t('login')}</button><button id="bReg">${t('register')}</button><button id="bGuest">${t('play_guest')}</button>`;
|
: `<button class="primary" id="bLogin">${t('login')}</button><button id="bReg">${t('register')}</button><button id="bGuest">${t('play_guest')}</button>${online}`;
|
||||||
overlay.innerHTML = `<div class="title"><div class="big">ROBOT CLASH</div><div class="tag">${t('menu_text')}</div>
|
// logo picture when ComfyGen made one, otherwise the lettering (never both, never nothing)
|
||||||
<div class="row">${btns}</div>
|
const logo = `<img class="tlogoimg" src="${Kit.asset('assets/Sprites/logo.png')}" alt="ROBOT CLASH"
|
||||||
<div class="row"><button id="bSet">⚙ ${t('settings')}</button><button id="bHelp">${t('how_to')}</button>
|
onerror="this.remove()" onload="this.nextElementSibling.style.display='none'"><div class="big">ROBOT CLASH</div>`;
|
||||||
|
overlay.innerHTML = `<div class="title"><div class="tpanel">
|
||||||
|
${logo}
|
||||||
|
<div class="tag">${t('menu_text')}</div>
|
||||||
|
<div class="hazbar"></div>
|
||||||
|
<div class="tmenu">${btns}</div>
|
||||||
|
<div class="trow2"><button id="bSet">⚙ ${t('settings')}</button><button id="bHelp">${t('how_to')}</button>
|
||||||
<button id="bLang" title="English / Deutsch">🌐 ${t('lang_self')}</button>${scores.enabled ? `<button id="bRank">🏆 ${t('ranking')}</button>` : ''}</div>
|
<button id="bLang" title="English / Deutsch">🌐 ${t('lang_self')}</button>${scores.enabled ? `<button id="bRank">🏆 ${t('ranking')}</button>` : ''}</div>
|
||||||
<p class="credits">${CREDITS}</p></div>`;
|
<p class="credits">${CREDITS}</p></div></div>`;
|
||||||
overlay.classList.remove('hide'); overlay.classList.add('clear'); overlay.style.backgroundImage = '';
|
overlay.classList.remove('hide'); overlay.classList.add('clear'); overlay.style.backgroundImage = '';
|
||||||
const on = (id, f) => { const el = $(id); if (el) el.onclick = () => { SFX.click(); f(); }; };
|
const on = (id, f) => { const el = $(id); if (el) el.onclick = () => { SFX.click(); f(); }; };
|
||||||
on('bPlay', () => enterAccount());
|
on('bPlay', () => enterAccount());
|
||||||
on('bSwitch', () => { accounts.logout(); hud(); showLogin(); });
|
on('bOnline', () => startOnline());
|
||||||
on('bLogin', () => showLogin());
|
on('bSwitch', () => { signOut(); fb ? showOnlineLogin(false, null, 'career') : showLogin(); });
|
||||||
on('bReg', () => showRegister());
|
on('bLogin', () => (fb ? showOnlineLogin(false, null, 'career') : showLogin()));
|
||||||
on('bGuest', () => { accounts.guest(); enterAccount(); });
|
on('bReg', () => (fb ? showOnlineLogin(true, null, 'career') : showRegister()));
|
||||||
|
on('bGuest', () => { if (fbAcc()) net.auth.logout(); accounts.guest(); enterAccount(); });
|
||||||
on('bSet', () => showSettings(showTitle));
|
on('bSet', () => showSettings(showTitle));
|
||||||
on('bHelp', () => showHelp(showTitle));
|
on('bHelp', () => showHelp(showTitle));
|
||||||
on('bLang', () => L.next());
|
on('bLang', () => L.next());
|
||||||
@@ -219,6 +272,103 @@
|
|||||||
hud();
|
hud();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- online lobby
|
||||||
|
let onlineReady = false, lobbyRows = [], pendingOut = null, lobbyRoom = null; // lobbyRoom = country code or null (room picker)
|
||||||
|
async function startOnline() {
|
||||||
|
if (!net.enabled) return;
|
||||||
|
if (!net.auth.current) {
|
||||||
|
if (save && !fbAcc()) return joinAnon(); // playing as guest -> straight in, anonymously
|
||||||
|
showOnlineLogin(false, null, 'online'); return;
|
||||||
|
}
|
||||||
|
if (!save || !slot) { if (!fbAcc()) accounts.guest(); loadSave(); }
|
||||||
|
if (!onlineReady) {
|
||||||
|
lobby.enter(); onlineReady = true;
|
||||||
|
lobby.onList(rows => { lobbyRows = rows; if (mode === 'lobby') renderLobby(); });
|
||||||
|
lobby.onIncoming(c => { if (mode === 'lobby' || mode === 'garage') showIncoming(c); });
|
||||||
|
lobby.onMatch(m => startFight({ name: m.opp.name, build: m.opp.build, paint: m.opp.paint || { body: 0x888888, accent: 0xff7a1a }, style: 'brawler', skill: 0.6, flag: m.opp.flag }, false, false, { id: m.id, host: m.host, seed: m.seed }));
|
||||||
|
lobby.onCancel(() => { pendingOut = null; if (mode === 'lobby') { renderLobby(); SFX.deny(); } });
|
||||||
|
}
|
||||||
|
showLobby();
|
||||||
|
}
|
||||||
|
async function joinAnon() {
|
||||||
|
if (!save) { accounts.guest(); loadSave(); }
|
||||||
|
const r = await net.auth.guest(playerName() || t('guest'));
|
||||||
|
if (!r.ok) { SFX.deny(); showOnlineLogin(false, r.error, 'online'); return; }
|
||||||
|
hud(); startOnline();
|
||||||
|
}
|
||||||
|
const errText = c => (window.LANG.en['e_' + c] ? t('e_' + c) : t('e_ERROR') + ' (' + esc(c) + ')');
|
||||||
|
function showOnlineLogin(reg, errKey, next) {
|
||||||
|
next = next || 'career';
|
||||||
|
setScreen('account');
|
||||||
|
const f = reg
|
||||||
|
? `<label>${t('f_name')}</label><input type="text" id="oName" maxlength="18" autocomplete="nickname">`
|
||||||
|
: '';
|
||||||
|
card(`<h2>${reg ? t('register') : t('login')}</h2><p>${t('online_login_text')}</p>
|
||||||
|
<div class="form">${f}<label>${t('f_email')}</label><input type="email" id="oMail" autocomplete="email" autocapitalize="off" autocorrect="off" spellcheck="false" inputmode="email">
|
||||||
|
<label>${t('f_pass')}</label><input type="password" id="oPass" autocomplete="${reg ? 'new-password' : 'current-password'}"></div>
|
||||||
|
<div class="err" id="oErr">${errKey ? errText(errKey) : ''}</div>
|
||||||
|
<div class="row"><button id="oBack">${t('back')}</button><button class="primary" id="oGo">${reg ? t('register_go') : t('login')}</button></div>
|
||||||
|
<p class="muted">${reg ? '' : t('no_account') + ' '}<button class="link" id="oToggle">${reg ? t('login') : t('register')}</button></p>
|
||||||
|
${next === 'online' ? `<div class="row"><button id="oAnon">👤 ${t('online_guest')}</button></div>` : ''}`, { bg: 'bg_title.jpg' });
|
||||||
|
if ($('oAnon')) $('oAnon').onclick = () => { SFX.click(); joinAnon(); };
|
||||||
|
$('oBack').onclick = () => { SFX.click(); showTitle(); };
|
||||||
|
$('oToggle').onclick = () => { SFX.click(); showOnlineLogin(!reg, null, next); };
|
||||||
|
$('oGo').onclick = async () => {
|
||||||
|
$('oGo').disabled = true;
|
||||||
|
const r = reg ? await net.auth.register($('oMail').value.trim(), $('oPass').value, $('oName') ? $('oName').value : '')
|
||||||
|
: await net.auth.login($('oMail').value.trim(), $('oPass').value);
|
||||||
|
if (!r.ok) { SFX.deny(); showOnlineLogin(reg, r.error, next); return; }
|
||||||
|
SFX.click(); hud();
|
||||||
|
if (next === 'online') startOnline(); else enterAccount(reg);
|
||||||
|
};
|
||||||
|
overlay.querySelectorAll('input').forEach(el => el.addEventListener('keydown', e => { e.stopPropagation(); if (e.key === 'Enter') $('oGo').click(); }));
|
||||||
|
}
|
||||||
|
function showLobby() {
|
||||||
|
if (!lobbyRoom) lobbyRoom = 'all'; // filter: 'all' or a country code
|
||||||
|
setScreen('lobby'); renderLobby();
|
||||||
|
}
|
||||||
|
// compact one-view lobby: country filter + flag dropdowns, slim player list
|
||||||
|
// two-pane lobby: country rooms on the left, players of the chosen room on the right (own style, not copied art)
|
||||||
|
function renderLobby() {
|
||||||
|
const code = r => (FLAGS.includes(r.flag) ? r.flag : 'XX');
|
||||||
|
const all = lobbyRows;
|
||||||
|
const myFlag = FLAGS.includes(save.flag) ? save.flag : 'XX';
|
||||||
|
// I am in the lobby too: count myself in my own country (and in "all"), and only list me there
|
||||||
|
const total = all.length + 1;
|
||||||
|
const cnt = f => all.filter(r => code(r) === f).length + (f === myFlag ? 1 : 0);
|
||||||
|
const here = lobbyRoom === 'all' ? all : all.filter(r => code(r) === lobbyRoom);
|
||||||
|
const showMe = lobbyRoom === 'all' || lobbyRoom === myFlag;
|
||||||
|
const flagOpts = FLAGS.map(f => `<option value="${f}" ${f === myFlag ? 'selected' : ''}>${t('cc_' + f)}</option>`).join('');
|
||||||
|
const room = (f, label, flag) => `<button class="rroom ${lobbyRoom === f ? 'on' : ''}" data-f="${f}"><span class="rfl">${flag ? flagHtml(f) : ''}</span><span class="rn">${label}</span><span class="cnt ${cnt(f) ? 'live' : ''}">${f === 'all' ? total : cnt(f)}</span></button>`;
|
||||||
|
const rooms = room('all', t('all_countries'), false) + FLAGS.map(f => room(f, t('cc_' + f), true)).join('');
|
||||||
|
const prow = (r, me) => `<div class="prow ${me ? 'me' : ''}" ${me ? '' : `data-uid="${r.uid}"`}><span class="pf">${flagHtml(me ? save.flag : r.flag)}</span><span class="pn">${esc(me ? playerName() : r.name)}${me ? ` <span class="muted">(${t('you')})</span>` : ''}</span><span class="pfame">\u2B50 ${Kit.fmt((me ? save.fame : r.fame) | 0)}</span>${me ? '<span class="pbusy"></span>' : (r.state === 'idle' ? `<button class="chal" data-uid="${r.uid}">${t('challenge')}</button>` : `<span class="pbusy">${t('busy')}</span>`)}</div>`;
|
||||||
|
const list = here.map(r => prow(r, false)).join('');
|
||||||
|
const title = lobbyRoom === 'all' ? '🌍 ' + t('all_countries') : flagHtml(lobbyRoom) + ' ' + t('cc_' + lobbyRoom);
|
||||||
|
overlay.innerHTML = `<div class="lobbyfull">
|
||||||
|
<div class="lobbyL"><div class="lobbyLh">🌍 ${t('lobby')}</div><div class="roomlist">${rooms}</div></div>
|
||||||
|
<div class="lobbyR">
|
||||||
|
<div class="lobbyRh">${title} <span class="muted">(${here.length + (showMe ? 1 : 0)})</span><span class="grow"></span>
|
||||||
|
<label class="flagpick">${t('your_flag')} <select id="lFlag">${flagOpts}</select></label></div>
|
||||||
|
<div class="plist">${showMe ? prow(null, true) : ''}${list || (showMe ? '' : `<div class="muted" style="padding:16px;text-align:center">${t('lobby_empty')}</div>`)}</div>
|
||||||
|
${pendingOut ? `<p class="muted" style="margin:6px 0 0">${t('waiting_accept')} <button class="link" id="lCancel">${t('cancel')}</button></p>` : ''}
|
||||||
|
<div class="row" style="margin-top:8px"><button id="lBack">${t('back')}</button><button class="primary" id="lQuick">${t('quick_match')}</button></div>
|
||||||
|
</div></div>`;
|
||||||
|
overlay.classList.remove('hide'); overlay.classList.remove('clear');
|
||||||
|
overlay.style.backgroundImage = `linear-gradient(rgba(5,6,10,.6), rgba(5,6,10,.8)), url("${img('bg_title.jpg')}")`;
|
||||||
|
overlay.querySelectorAll('.rroom').forEach(b => { b.onclick = () => { SFX.click(); lobbyRoom = b.dataset.f; renderLobby(); }; });
|
||||||
|
$('lFlag').onchange = e => { save.flag = e.target.value; persist(); if (lobby) lobby.refresh(); renderLobby(); };
|
||||||
|
overlay.querySelectorAll('.chal').forEach(b => { b.onclick = () => { SFX.click(); pendingOut = b.dataset.uid; lobby.challenge(b.dataset.uid); renderLobby(); }; });
|
||||||
|
if ($('lCancel')) $('lCancel').onclick = () => { SFX.click(); lobby.cancel(); pendingOut = null; renderLobby(); };
|
||||||
|
$('lQuick').onclick = () => { const idle = here.find(r => r.state === 'idle') || all.find(r => r.state === 'idle'); if (idle) { SFX.click(); pendingOut = idle.uid; lobby.challenge(idle.uid); renderLobby(); } else SFX.deny(); };
|
||||||
|
$('lBack').onclick = () => { SFX.click(); if (save) openGarage(); else showTitle(); };
|
||||||
|
}
|
||||||
|
function showIncoming(c) {
|
||||||
|
card(`<h2>${t('challenge_in')}</h2><p>${flagHtml(c.fromFlag)} <b>${esc(c.fromName)}</b> ${t('wants_fight')}</p>
|
||||||
|
<div class="row"><button id="cNo">${t('decline')}</button><button class="primary" id="cYes">${t('accept')}</button></div>`);
|
||||||
|
$('cYes').onclick = () => { SFX.click(); lobby.accept(c.from); };
|
||||||
|
$('cNo').onclick = () => { SFX.click(); lobby.decline(c.from); if (mode === 'lobby') renderLobby(); else hideOverlay(); };
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- accounts
|
// ---------------------------------------------------------------- accounts
|
||||||
function showLogin(errKey) {
|
function showLogin(errKey) {
|
||||||
setScreen('account');
|
setScreen('account');
|
||||||
@@ -270,35 +420,95 @@
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterAccount(fresh) {
|
function loadSave() {
|
||||||
slot = Kit.saveSlot(accounts.saveKey(), newSave);
|
slot = Kit.saveSlot(saveKey(), newSave);
|
||||||
save = slot.load();
|
save = slot.load();
|
||||||
repairSave();
|
repairSave();
|
||||||
RC.layerFromData(layer, save.paint.decal, () => { if (mode === 'garage') view.showGarage(save.build, paintObj()); });
|
RC.layerFromData(layer, save.paint.decal, () => { if (mode === 'garage') view.showGarage(save.build, paintObj()); });
|
||||||
if (fresh && accounts.current && !accounts.current.guest) save.robotName = accounts.current.name.slice(0, 18);
|
}
|
||||||
|
function enterAccount(fresh) {
|
||||||
|
loadSave();
|
||||||
|
const who = fbAcc() || (accounts.current && !accounts.current.guest ? accounts.current : null);
|
||||||
|
if (fresh && who) save.robotName = who.name.slice(0, 18);
|
||||||
persist();
|
persist();
|
||||||
hud();
|
hud();
|
||||||
shop.reset();
|
shop.reset();
|
||||||
if (!save.tutorialSeen) { save.tutorialSeen = true; persist(); showHelp(openGarage); } else openGarage();
|
if (!save.tutorialSeen) { save.tutorialSeen = true; persist(); showHelp(openGarage); } else openGarage();
|
||||||
}
|
}
|
||||||
// saves from older versions: missing parts, invalid ids
|
// saves from older versions: missing parts, invalid ids, hangar migration
|
||||||
function repairSave() {
|
function repairSave() {
|
||||||
save.owned = (save.owned || []).filter(id => RC.PARTS[id]);
|
save.owned = (save.owned || []).filter(id => RC.PARTS[id]);
|
||||||
for (const sl of RC.SLOTS) {
|
// hangar migration: older saves have only build/paint/robotName -> make it robot slot 0
|
||||||
if (save.build[sl] && !RC.PARTS[save.build[sl]]) save.build[sl] = null;
|
if (!Array.isArray(save.robots) || !save.robots.length) {
|
||||||
if (save.build[sl] && !save.owned.includes(save.build[sl])) save.owned.push(save.build[sl]);
|
save.robots = [{ name: save.robotName || 'Clank', build: save.build || Object.assign({}, RC.STARTER), paint: save.paint || { body: 0xff7a1a, accent: 0x15171b } }];
|
||||||
|
save.active = 0;
|
||||||
}
|
}
|
||||||
for (const sl of Object.keys(RC.REQUIRED)) if (!save.build[sl]) { save.build[sl] = RC.STARTER[sl]; if (!save.owned.includes(RC.STARTER[sl])) save.owned.push(RC.STARTER[sl]); }
|
save.active = Kit.clamp(save.active | 0, 0, save.robots.length - 1);
|
||||||
|
const fixBuild = b => {
|
||||||
|
for (const sl of RC.SLOTS) {
|
||||||
|
if (b[sl] && !RC.PARTS[b[sl]]) b[sl] = null;
|
||||||
|
if (b[sl] && !save.owned.includes(b[sl])) save.owned.push(b[sl]);
|
||||||
|
}
|
||||||
|
for (const sl of Object.keys(RC.REQUIRED)) if (!b[sl]) { b[sl] = RC.STARTER[sl]; if (!save.owned.includes(RC.STARTER[sl])) save.owned.push(RC.STARTER[sl]); }
|
||||||
|
};
|
||||||
|
for (const r of save.robots) { r.build = r.build || Object.assign({}, RC.STARTER); r.paint = r.paint || { body: 0xff7a1a, accent: 0x15171b }; r.name = r.name || 'Robot'; fixBuild(r.build); }
|
||||||
|
// load the active robot into the live fields the rest of the game uses
|
||||||
|
const a = save.robots[save.active];
|
||||||
|
save.build = a.build; save.paint = a.paint; save.robotName = a.name;
|
||||||
save.beaten = Kit.clamp(save.beaten | 0, 0, RC.LEAGUE.length - 1);
|
save.beaten = Kit.clamp(save.beaten | 0, 0, RC.LEAGUE.length - 1);
|
||||||
}
|
}
|
||||||
function logout() { persist(); accounts.logout(); save = null; slot = null; F = null; hud(); startIntroOrTitle(); }
|
// hangar: switch / add / delete robot slots (owned parts are shared)
|
||||||
function startIntroOrTitle() { if (view) { const a = RC.LEAGUE[7], b = RC.LEAGUE[4]; view.showIntro([a.build, b.build], [a.paint, b.paint]); view.skipIntro(); } showTitle(); }
|
function switchRobot(i) {
|
||||||
|
if (i === save.active || !save.robots[i]) return;
|
||||||
|
syncActive();
|
||||||
|
save.active = i;
|
||||||
|
const a = save.robots[i];
|
||||||
|
save.build = a.build; save.paint = a.paint; save.robotName = a.name;
|
||||||
|
persist();
|
||||||
|
RC.layerFromData(layer, save.paint.decal, () => { if (mode === 'garage') view.showGarage(save.build, paintObj()); });
|
||||||
|
shop.reset(); shop.render(); view.showGarage(save.build, paintObj()); renderHangar();
|
||||||
|
}
|
||||||
|
function addRobot() {
|
||||||
|
if (save.robots.length >= MAX_ROBOTS) { SFX.deny(); return; }
|
||||||
|
syncActive();
|
||||||
|
save.robots.push(newRobotDef(t('robot_n', { n: save.robots.length + 1 })));
|
||||||
|
switchRobot(save.robots.length - 1);
|
||||||
|
SFX.buy();
|
||||||
|
}
|
||||||
|
function delRobot(i) {
|
||||||
|
if (save.robots.length <= 1) { SFX.deny(); return; }
|
||||||
|
save.robots.splice(i, 1);
|
||||||
|
save.active = Kit.clamp(save.active >= i ? save.active - (save.active === i ? 0 : 1) : save.active, 0, save.robots.length - 1);
|
||||||
|
const a = save.robots[save.active]; save.build = a.build; save.paint = a.paint; save.robotName = a.name;
|
||||||
|
persist(); RC.layerFromData(layer, save.paint.decal, () => {}); shop.reset(); shop.render(); view.showGarage(save.build, paintObj()); renderHangar();
|
||||||
|
}
|
||||||
|
// hangar management (shop top-tab): list of robots with weapon, switch / delete + add button
|
||||||
|
function renderHangar(el) {
|
||||||
|
el = el || $('hangarView'); if (!el) return;
|
||||||
|
const rows = save.robots.map((r, i) => `<div class="hmrow ${i === save.active ? 'on' : ''}" data-i="${i}">
|
||||||
|
<div><div class="hmn">${esc(r.name)}</div><div class="hmw">${esc(weaponName(r.build))}</div></div>
|
||||||
|
${i === save.active ? `<span class="muted" style="font-size:12px">${t('active_robot')}</span>` : `<button data-use="${i}">${t('use')}</button>`}
|
||||||
|
${save.robots.length > 1 ? `<button data-del="${i}" title="${t('delete')}">✕</button>` : '<span></span>'}</div>`).join('');
|
||||||
|
el.innerHTML = `<div class="hmgr">${rows}</div>
|
||||||
|
${save.robots.length < MAX_ROBOTS ? `<button class="primary" id="hAdd" style="margin-top:8px">+ ${t('new_robot')}</button>` : `<p class="muted" style="margin-top:8px">${t('hangar_full')}</p>`}`;
|
||||||
|
el.querySelectorAll('[data-use]').forEach(b => { b.onclick = () => { SFX.click(); switchRobot(+b.dataset.use); shop.setTab('build'); } ; });
|
||||||
|
el.querySelectorAll('[data-del]').forEach(b => { b.onclick = () => { SFX.click(); delRobot(+b.dataset.del); renderHangar(); } ; });
|
||||||
|
if ($('hAdd')) $('hAdd').onclick = () => { addRobot(); shop.setTab('build'); };
|
||||||
|
}
|
||||||
|
function signOut() {
|
||||||
|
persist();
|
||||||
|
if (lobby && onlineReady) { lobby.leave(); onlineReady = false; lobbyRows = []; pendingOut = null; }
|
||||||
|
if (net && net.enabled) net.auth.logout();
|
||||||
|
accounts.logout(); save = null; slot = null; F = null; hud();
|
||||||
|
}
|
||||||
|
function logout() { signOut(); startIntroOrTitle(); }
|
||||||
|
function startIntroOrTitle() { if (view) { const a = RC.LEAGUE[7], b = RC.LEAGUE[4]; view.showIntro([a.build, b.build], [oppPaint(a), oppPaint(b)]); view.skipIntro(); } showTitle(); }
|
||||||
$('hUser').onclick = () => {
|
$('hUser').onclick = () => {
|
||||||
if (!accounts.current || mode === 'fight' || mode === 'pause') return;
|
if (!save || mode === 'fight' || mode === 'pause') return;
|
||||||
SFX.click();
|
SFX.click();
|
||||||
const back = currentBack();
|
const back = currentBack(), who = fbAcc() || (accounts.current && !accounts.current.guest ? accounts.current : null);
|
||||||
card(`<h2>${t('account')}</h2><p>${accounts.current.guest ? t('guest_text') : t('logged_in_as', { name: esc(accounts.current.name) })}</p>
|
card(`<h2>${t('account')}</h2><p>${who ? t('logged_in_as', { name: esc(who.name) }) + (who.email ? `<br><span class="muted">${esc(who.email)}</span>` : '') : t('guest_text')}</p>
|
||||||
<div class="row"><button id="bOut">${accounts.current.guest ? t('to_title') : t('logout')}</button><button class="primary" id="bBack">${t('back')}</button></div>`);
|
<div class="row"><button id="bOut">${who ? t('logout') : t('to_title')}</button><button class="primary" id="bBack">${t('back')}</button></div>`);
|
||||||
$('bOut').onclick = () => { SFX.click(); logout(); };
|
$('bOut').onclick = () => { SFX.click(); logout(); };
|
||||||
$('bBack').onclick = () => { SFX.click(); back(); };
|
$('bBack').onclick = () => { SFX.click(); back(); };
|
||||||
};
|
};
|
||||||
@@ -306,43 +516,61 @@
|
|||||||
|
|
||||||
// ---------------------------------------------------------------- settings / help / ranking
|
// ---------------------------------------------------------------- settings / help / ranking
|
||||||
function showSettings(back) {
|
function showSettings(back) {
|
||||||
|
overlayEnter();
|
||||||
const prev = mode;
|
const prev = mode;
|
||||||
const seg = (id, val, opts) => `<div class="seg" id="${id}">${opts.map(([v, label]) => `<button data-v="${v}" class="${v === val ? 'on' : ''}">${label}</button>`).join('')}</div>`;
|
const seg = (id, val, opts) => `<div class="seg" id="${id}">${opts.map(([v, label]) => `<button data-v="${v}" class="${v === val ? 'on' : ''}">${label}</button>`).join('')}</div>`;
|
||||||
card(`<h2>${t('settings')}</h2><div class="set">
|
const who = fbAcc() || (accounts.current && !accounts.current.guest ? accounts.current : null);
|
||||||
<span>${t('s_lang')}</span>${seg('sLang', L.lang, L.langs.map(l => [l, window.LANG[l].lang_self]))}
|
const item = (label, ctl) => `<span class="sl">${label}</span>${ctl}`;
|
||||||
<span>${t('s_music')}</span><input type="range" id="sMusic" min="0" max="1" step="0.05" value="${audio.musicVol}">
|
card(`<h2>${t('settings')}</h2><div class="set2">
|
||||||
<span>${t('s_sfx')}</span><input type="range" id="sSfx" min="0" max="1" step="0.05" value="${audio.sfxVol}">
|
${item(t('s_lang'), seg('sLang', L.lang, L.langs.map(l => [l, window.LANG[l].lang_self])))}
|
||||||
<span>${t('s_mute')}</span>${seg('sMute', audio.muted ? '1' : '0', [['0', t('on')], ['1', t('off')]])}
|
${item(t('s_mute'), seg('sMute', audio.muted ? '1' : '0', [['0', t('on')], ['1', t('off')]]))}
|
||||||
<span>${t('s_gfx')}</span>${seg('sGfx', settings.gfx, [['low', t('gfx_low')], ['medium', t('gfx_medium')], ['high', t('gfx_high')]])}
|
${item(t('s_music'), `<input type="range" id="sMusic" min="0" max="1" step="0.05" value="${audio.musicVol}">`)}
|
||||||
<span>${t('s_intro')}</span>${seg('sIntro', settings.intro ? '1' : '0', [['1', t('on')], ['0', t('off')]])}
|
${item(t('s_sfx'), `<input type="range" id="sSfx" min="0" max="1" step="0.05" value="${audio.sfxVol}">`)}
|
||||||
<span>${t('s_screen')}</span><div><button id="sFull">${t('win_full')}</button></div>
|
${item(t('s_gfx'), seg('sGfx', settings.gfx, [['low', t('gfx_low')], ['medium', t('gfx_medium')], ['high', t('gfx_high')]]))}
|
||||||
|
${item(t('s_diff'), seg('sDiff', settings.diff, [['easy', t('diff_easy')], ['normal', t('diff_normal')], ['hard', t('diff_hard')]]))}
|
||||||
|
${item(t('s_cam'), seg('sCam', settings.cam, CAMS.map(c => [c, t('cam_' + c)])))}
|
||||||
|
${item(t('s_steer'), seg('sSteer', settings.steer, [['tank', t('steer_tank')], ['simple', t('steer_simple')]]))}
|
||||||
|
${item(t('s_autofire'), seg('sAuto', settings.autofire ? '1' : '0', [['1', t('on')], ['0', t('off')]]))}
|
||||||
|
${item(t('s_arena'), seg('sArena', settings.arena, [['random', t('arena_random')]].concat(RC.ARENAS.map(a => [a.id, t('arena_' + a.id)]))))}
|
||||||
|
${item(t('s_intro'), seg('sIntro', settings.intro ? '1' : '0', [['1', t('on')], ['0', t('off')]]))}
|
||||||
</div>
|
</div>
|
||||||
<h3>${t('s_controls')}</h3>${keysHtml()}
|
<div class="setacc"><span class="sl">${t('s_account')}</span>
|
||||||
${save ? `<h3>${t('s_career')}</h3><div style="text-align:left"><button id="sReset">${t('reset')}</button></div>` : ''}
|
<span class="who">${who ? '👤 <b>' + esc(who.name) + '</b>' + (who.email ? ' <span class="muted">' + esc(who.email) + '</span>' : '') : '👤 ' + t('guest')}</span>
|
||||||
<div class="row"><button class="primary" id="bBack">${t('back')}</button></div>`, { wide: true, clear: prev === 'title' || prev === 'intro' });
|
${save ? `<button id="sOut">${who ? t('logout') : t('to_title')}</button>` : ''}</div>
|
||||||
|
<div class="row"><button id="sFull">⛶ ${t('win_full')}</button><button id="sKeys">🎮 ${t('s_controls')}</button>
|
||||||
|
${save ? `<button id="sReset">${t('reset')}</button>` : ''}<button class="primary" id="bBack">${t('back')}</button></div>`, { wide: true, clear: prev === 'title' || prev === 'intro' });
|
||||||
const segOn = (id, f) => $(id).querySelectorAll('button').forEach(b => { b.onclick = () => { SFX.click(); f(b.dataset.v); $(id).querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); }; });
|
const segOn = (id, f) => $(id).querySelectorAll('button').forEach(b => { b.onclick = () => { SFX.click(); f(b.dataset.v); $(id).querySelectorAll('button').forEach(x => x.classList.toggle('on', x === b)); }; });
|
||||||
segOn('sLang', v => { L.set(v); showSettings(back); });
|
segOn('sLang', v => { L.set(v); showSettings(back); });
|
||||||
segOn('sMute', v => { if ((v === '1') !== audio.muted) audio.toggleMute(); hud(); });
|
segOn('sMute', v => { if ((v === '1') !== audio.muted) audio.toggleMute(); hud(); });
|
||||||
segOn('sGfx', v => { settings.gfx = v; saveSettings(); if (view) view.setQuality(v); });
|
segOn('sGfx', v => { settings.gfx = v; saveSettings(); if (view) view.setQuality(v); });
|
||||||
segOn('sIntro', v => { settings.intro = v === '1'; saveSettings(); });
|
segOn('sIntro', v => { settings.intro = v === '1'; saveSettings(); });
|
||||||
|
segOn('sDiff', v => { settings.diff = v; saveSettings(); });
|
||||||
|
segOn('sSteer', v => { settings.steer = v; saveSettings(); });
|
||||||
|
segOn('sCam', v => { settings.cam = v; saveSettings(); if (view) view.setCam(v); });
|
||||||
|
segOn('sAuto', v => { settings.autofire = v === '1'; saveSettings(); });
|
||||||
|
segOn('sArena', v => { settings.arena = v; saveSettings(); });
|
||||||
$('sMusic').oninput = e => audio.setVolume(+e.target.value, audio.sfxVol);
|
$('sMusic').oninput = e => audio.setVolume(+e.target.value, audio.sfxVol);
|
||||||
$('sSfx').oninput = e => audio.setVolume(audio.musicVol, +e.target.value);
|
$('sSfx').oninput = e => audio.setVolume(audio.musicVol, +e.target.value);
|
||||||
$('sSfx').onchange = () => SFX.click();
|
$('sSfx').onchange = () => SFX.click();
|
||||||
$('sFull').onclick = () => { SFX.click(); Kit.host.fullscreen(); };
|
$('sFull').onclick = () => { SFX.click(); Kit.host.fullscreen(); };
|
||||||
if ($('sReset')) $('sReset').onclick = () => { SFX.click(); confirmReset(() => showSettings(back)); };
|
if ($('sReset')) $('sReset').onclick = () => { SFX.click(); confirmReset(() => showSettings(back)); };
|
||||||
|
if ($('sOut')) $('sOut').onclick = () => { SFX.click(); logout(); };
|
||||||
|
$('sKeys').onclick = () => { SFX.click(); showHelp(() => showSettings(back)); };
|
||||||
$('bBack').onclick = () => { SFX.click(); back(); };
|
$('bBack').onclick = () => { SFX.click(); back(); };
|
||||||
}
|
}
|
||||||
function keysHtml() {
|
function keysHtml() {
|
||||||
return `<div class="keys"><b>W A S D / ↑ ← ↓ →</b><span>${t('key_drive')}</span><b>${t('key_space')}</b><span>${t('key_weapon')}</span>
|
return `<div class="keys"><b>W A S D / ↑ ← ↓ →</b><span>${t('key_drive')}</span><b>${t('key_space')}</b><span>${t('key_weapon')}</span>
|
||||||
<b>Shift / E</b><span>${t('key_tower')}</span><b>P / Esc</b><span>${t('pause')}</span><b>M</b><span>${t('sound_on')} / ${t('sound_off')}</span>
|
<b>Shift / E</b><span>${t('key_tower')}</span><b>C</b><span>${t('key_cam')}</span><b>P / Esc</b><span>${t('pause')}</span><b>M</b><span>${t('sound_on')} / ${t('sound_off')}</span>
|
||||||
<b>${t('key_pad')}</b><span>${t('key_pad_text')}</span></div>`;
|
<b>${t('key_pad')}</b><span>${t('key_pad_text')}</span></div>`;
|
||||||
}
|
}
|
||||||
function showHelp(back) {
|
function showHelp(back) {
|
||||||
|
overlayEnter();
|
||||||
card(`<h2>${t('how_to')}</h2><p>${t('help_text')}</p>${keysHtml()}
|
card(`<h2>${t('how_to')}</h2><p>${t('help_text')}</p>${keysHtml()}
|
||||||
<p style="margin-top:12px">${t('help_arena')}</p><button class="primary" id="bOk">${t('ok')}</button>`, { bg: 'bg_title.jpg' });
|
<p style="margin-top:12px">${t('help_arena')}</p><button class="primary" id="bOk">${t('ok')}</button>`, { bg: 'bg_title.jpg' });
|
||||||
$('bOk').onclick = () => { SFX.click(); back(); };
|
$('bOk').onclick = () => { SFX.click(); back(); };
|
||||||
}
|
}
|
||||||
function showRanking(back) {
|
function showRanking(back) {
|
||||||
|
overlayEnter();
|
||||||
card(`<h2>🏆 ${t('ranking')}</h2><ol class="board" id="board"><li class="muted">${t('loading')}</li></ol><div class="row"><button class="primary" id="bBack">${t('back')}</button></div>`, { bg: 'bg_title.jpg' });
|
card(`<h2>🏆 ${t('ranking')}</h2><ol class="board" id="board"><li class="muted">${t('loading')}</li></ol><div class="row"><button class="primary" id="bBack">${t('back')}</button></div>`, { bg: 'bg_title.jpg' });
|
||||||
$('bBack').onclick = () => { SFX.click(); back(); };
|
$('bBack').onclick = () => { SFX.click(); back(); };
|
||||||
fillBoard();
|
fillBoard();
|
||||||
@@ -379,8 +607,12 @@
|
|||||||
view.showGarage(save.build, paintObj());
|
view.showGarage(save.build, paintObj());
|
||||||
audio.music('music_garage');
|
audio.music('music_garage');
|
||||||
shop.render(); hud();
|
shop.render(); hud();
|
||||||
|
$('zIn').onclick = () => { SFX.click(); view.zoomGarage(1.18); };
|
||||||
|
$('zOut').onclick = () => { SFX.click(); view.zoomGarage(1 / 1.18); };
|
||||||
}
|
}
|
||||||
$('bGMenu').onclick = () => { SFX.click(); persist(); startIntroOrTitle(); };
|
$('bGMenu').onclick = () => { SFX.click(); persist(); startIntroOrTitle(); };
|
||||||
|
$('bGOnline').onclick = () => { SFX.click(); persist(); startOnline(); };
|
||||||
|
if (!(net && net.enabled)) $('bGOnline').style.display = 'none';
|
||||||
$('bTrain').onclick = () => { SFX.click(); startFight(RC.DUMMY, true); };
|
$('bTrain').onclick = () => { SFX.click(); startFight(RC.DUMMY, true); };
|
||||||
$('bLeague').onclick = () => { SFX.click(); showLeague(); };
|
$('bLeague').onclick = () => { SFX.click(); showLeague(); };
|
||||||
|
|
||||||
@@ -393,33 +625,51 @@
|
|||||||
<div class="pz">${RC.pic('ico_credits', '🪙')}${Kit.fmt(Math.round(o.prize * seasonMul()))}</div></div>`;
|
<div class="pz">${RC.pic('ico_credits', '🪙')}${Kit.fmt(Math.round(o.prize * seasonMul()))}</div></div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
card(`<h2>${t('league_title', { s: save.season })}</h2><p>${t('league_text')}</p><div class="opps">${cards}</div>
|
card(`<h2>${t('league_title', { s: save.season })}</h2><p>${t('league_text')}</p><div class="opps">${cards}</div>
|
||||||
<div class="row"><button id="bBack">${t('back')}</button><button class="primary" id="bFight">${t('fight_vs', { name: RC.LEAGUE[save.beaten].name })}</button></div>`,
|
<div class="row"><button id="bBack">${t('back')}</button><button class="primary" id="bFight">${t('fight_vs', { name: RC.LEAGUE[save.beaten].name })}</button></div>
|
||||||
|
${save.beaten ? `<p class="muted">${t('exhibition_hint')}</p>` : ''}`,
|
||||||
{ wide: true, bg: 'bg_title.jpg' });
|
{ wide: true, bg: 'bg_title.jpg' });
|
||||||
overlay.querySelectorAll('.opp.next').forEach(el => { el.style.cursor = 'pointer'; el.onclick = () => { SFX.click(); showVs(RC.LEAGUE[save.beaten]); }; });
|
overlay.querySelectorAll('.opp.next').forEach(el => { el.style.cursor = 'pointer'; el.onclick = () => { SFX.click(); showVs(RC.LEAGUE[save.beaten]); }; });
|
||||||
|
// beaten opponents: repeatable exhibition fights for half the prize (steady income)
|
||||||
|
overlay.querySelectorAll('.opp.done').forEach(el => { el.style.cursor = 'pointer'; el.title = t('exhibition_note'); el.onclick = () => { SFX.click(); showVs(RC.LEAGUE[+el.dataset.i], true); }; });
|
||||||
$('bFight').onclick = () => { SFX.click(); showVs(RC.LEAGUE[save.beaten]); };
|
$('bFight').onclick = () => { SFX.click(); showVs(RC.LEAGUE[save.beaten]); };
|
||||||
$('bBack').onclick = () => { SFX.click(); openGarage(); };
|
$('bBack').onclick = () => { SFX.click(); openGarage(); };
|
||||||
}
|
}
|
||||||
function showVs(opp) {
|
function showVs(opp, exhibition) {
|
||||||
const me = RC.stats(save.build), en = RC.stats(opp.build);
|
const me = RC.stats(save.build), en = RC.stats(opp.build);
|
||||||
const line = s => `${Math.round(s.hp)} ${t('m_hp')} · ${Math.round(s.reduce * 100)}% ${t('m_armour')} · ${s.top.toFixed(1)} m/s`;
|
const line = s => `${Math.round(s.hp)} ${t('m_hp')} · ${Math.round(s.reduce * 100)}% ${t('m_armour')} · ${s.top.toFixed(1)} m/s`;
|
||||||
card(`<div class="vs"><div class="side">${RC.pic('icon', '🤖')}<div class="nm">${esc(save.robotName)}</div><div class="muted">${weaponName(save.build)}</div><div class="muted">${line(me)}</div></div>
|
const mine = view.portrait(save.build, paintObj());
|
||||||
|
const myPic = mine ? `<span class="pic"><img src="${mine}" alt="" draggable="false"></span>` : RC.pic('icon', '🤖');
|
||||||
|
card(`<div class="vs"><div class="side">${myPic}<div class="nm">${esc(save.robotName)}</div><div class="muted">${weaponName(save.build)}</div><div class="muted">${line(me)}</div></div>
|
||||||
<div class="mid">VS</div>
|
<div class="mid">VS</div>
|
||||||
<div class="side">${RC.pic('opp_' + opp.id, '🤖')}<div class="nm">${opp.name}</div><div class="muted">${weaponName(opp.build)}</div><div class="muted">${line(en)}</div></div></div>
|
<div class="side">${RC.pic('opp_' + opp.id, '🤖')}<div class="nm">${opp.name}</div><div class="muted">${weaponName(opp.build)}</div><div class="muted">${line(en)}</div></div></div>
|
||||||
<p>${t('style_' + opp.style)}</p>
|
<p>${t('style_' + opp.style)}</p>${exhibition ? `<p class="muted">${t('exhibition_note')}</p>` : ''}
|
||||||
<div class="row"><button id="bBack">${t('back')}</button><button class="primary" id="bGo">${t('fight_go_btn')}</button></div>`, { wide: true, bg: 'bg_title.jpg' });
|
<div class="row"><button id="bBack">${t('back')}</button><button class="primary" id="bGo">${exhibition ? t('exhibition_btn') : t('fight_go_btn')}</button></div>`, { wide: true, bg: 'bg_title.jpg' });
|
||||||
$('bBack').onclick = () => { SFX.click(); showLeague(); };
|
$('bBack').onclick = () => { SFX.click(); showLeague(); };
|
||||||
$('bGo').onclick = () => { SFX.click(); startFight(opp, false); };
|
$('bGo').onclick = () => { SFX.click(); startFight(opp, false, exhibition); };
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- fight
|
// ---------------------------------------------------------------- fight
|
||||||
function startFight(opp, training) {
|
function startFight(opp, training, exhibition, online) {
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
|
const D = DIFF[settings.diff] || DIFF.easy;
|
||||||
const stA = RC.stats(save.build), stB = RC.stats(opp.build);
|
const stA = RC.stats(save.build), stB = RC.stats(opp.build);
|
||||||
const seed = (Date.now() & 0xffff) + save.games * 31;
|
if (!online) stA.hp = Math.round(stA.hp * D.hp); // no handicap in live PvP
|
||||||
const s = RC.Combat.create({ robots: [stA, stB], seed, names: [save.robotName, opp.name] });
|
const seed = online ? online.seed : (Date.now() & 0xffff) + save.games * 31;
|
||||||
const skill = Math.min(1, opp.skill + (save.season - 1) * 0.12);
|
// arena: league scales with the opponent, online derives from the shared seed, training uses the setting
|
||||||
F = { s, opp, training, brain: RC.AI.create({ style: opp.style, skill, seed: seed + 5 }), count: 3.5, beat: 4,
|
const ids = RC.ARENAS.map(a => a.id), idx = RC.LEAGUE.indexOf(opp);
|
||||||
|
const bySize = RC.ARENAS.slice().sort((a, b) => a.half - b.half).map(a => a.id); // small -> big for league progression
|
||||||
|
const arenaId = DEV.get('arena') ? DEV.get('arena')
|
||||||
|
: online ? ids[seed % ids.length]
|
||||||
|
: idx >= 0 ? bySize[Math.min(bySize.length - 1, Math.floor(idx * bySize.length / RC.LEAGUE.length))]
|
||||||
|
: settings.arena === 'random' || !settings.arena ? ids[(Math.random() * ids.length) | 0] : settings.arena;
|
||||||
|
const s = RC.Combat.create({ robots: [stA, stB], seed, names: [save.robotName, opp.name], arena: arenaId });
|
||||||
|
const skill = Kit.clamp(opp.skill + (save.season - 1) * 0.12 + D.skill, 0, 1);
|
||||||
|
F = { s, opp, training, exhibition: !!exhibition, online, brain: online ? null : RC.AI.create({ style: opp.style, skill, seed: seed + 5 }), count: 3.5, beat: 4,
|
||||||
acc: [0, 0], accT: 0, banner: null, ended: false };
|
acc: [0, 0], accT: 0, banner: null, ended: false };
|
||||||
|
if (online) {
|
||||||
|
F.nf = RC.NetFight({ net, id: online.id, host: online.host, oppStyle: 'brawler', oppSkill: 0.6, onPeerLost: () => banner(t('peer_lost'), '#ff4a3a', 2.5), onPeerBack: () => banner(t('peer_back'), '#6dff9e', 1.6) });
|
||||||
|
F.nf.start();
|
||||||
|
}
|
||||||
// dev: ?auto = AI drives the player too, ?ff=30 = fast-forward 30 s (screenshots, balancing)
|
// dev: ?auto = AI drives the player too, ?ff=30 = fast-forward 30 s (screenshots, balancing)
|
||||||
if (DEV.has('auto')) F.auto = RC.AI.create({ style: 'brawler', skill: 0.7, seed: seed + 11 });
|
if (DEV.has('auto')) F.auto = RC.AI.create({ style: 'brawler', skill: 0.7, seed: seed + 11 });
|
||||||
if (DEV.has('ff')) {
|
if (DEV.has('ff')) {
|
||||||
@@ -430,13 +680,18 @@
|
|||||||
s.events.length = 0;
|
s.events.length = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view.showArena(s, [save.build, opp.build], [paintObj(), opp.paint]);
|
view.showArena(s, [save.build, opp.build], [paintObj(), oppPaint(opp)]);
|
||||||
|
view.setCam(DEV.get('cam') || settings.cam); // dev: &cam=chase|fpv
|
||||||
$('fN0').textContent = save.robotName; $('fN1').textContent = opp.name;
|
$('fN0').textContent = save.robotName; $('fN1').textContent = opp.name;
|
||||||
$('fW0').textContent = weaponName(save.build); $('fW1').textContent = weaponName(opp.build);
|
$('fW0').textContent = weaponName(save.build); $('fW1').textContent = weaponName(opp.build);
|
||||||
$('fH0').style.background = hex(save.paint.body); $('fH1').style.background = hex(opp.paint.body);
|
$('fH0').style.background = barCol(save.paint); $('fH1').style.background = barCol(opp.paint);
|
||||||
fx.clear();
|
fx.clear();
|
||||||
setScreen('fight');
|
setScreen('fight');
|
||||||
audio.music('music_fight');
|
audio.music('music_fight');
|
||||||
|
banner('📍 ' + t('arena_' + s.arena.id), '#ff7a1a', 2.2);
|
||||||
|
const pg = $('padGadget'); if (pg) pg.style.display = s.robots[0].st.gadget ? '' : 'none';
|
||||||
|
buildCds();
|
||||||
|
buildDmg(0, save.build); buildDmg(1, opp.build);
|
||||||
fightHud();
|
fightHud();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,22 +702,97 @@
|
|||||||
const b = i => !!(gp.buttons[i] && gp.buttons[i].pressed);
|
const b = i => !!(gp.buttons[i] && gp.buttons[i].pressed);
|
||||||
if (b(9) && every('gpStart', 400)) togglePause();
|
if (b(9) && every('gpStart', 400)) togglePause();
|
||||||
return { throttle: -dz(gp.axes[1] || 0) + (b(12) ? 1 : 0) - (b(13) ? 1 : 0), turn: dz(gp.axes[0] || 0) + (b(15) ? 1 : 0) - (b(14) ? 1 : 0),
|
return { throttle: -dz(gp.axes[1] || 0) + (b(12) ? 1 : 0) - (b(13) ? 1 : 0), turn: dz(gp.axes[0] || 0) + (b(15) ? 1 : 0) - (b(14) ? 1 : 0),
|
||||||
fire: b(0) || b(7), fire2: b(1) || b(2) || b(6) };
|
fire: b(0) || b(7), fire2: b(1) || b(2) || b(6), fire3: b(3) || b(5) };
|
||||||
}
|
}
|
||||||
|
// up/down + left/right from keys, touch pad and gamepad
|
||||||
function playerInput() {
|
function playerInput() {
|
||||||
const k = {
|
let ky = (input.down('up') ? 1 : 0) - (input.down('down') ? 1 : 0);
|
||||||
throttle: (input.down('up') ? 1 : 0) - (input.down('down') ? 1 : 0),
|
let kx = (input.down('right') ? 1 : 0) - (input.down('left') ? 1 : 0);
|
||||||
turn: (input.down('right') ? 1 : 0) - (input.down('left') ? 1 : 0),
|
let fire = input.down('fire'), fire2 = input.down('fire2'), fire3 = input.down('fire3');
|
||||||
fire: input.down('fire'), fire2: input.down('fire2'),
|
|
||||||
};
|
|
||||||
const g = pad();
|
const g = pad();
|
||||||
if (g) {
|
if (g) { ky = Kit.clamp(ky + g.throttle, -1, 1); kx = Kit.clamp(kx + g.turn, -1, 1); fire = fire || g.fire; fire2 = fire2 || g.fire2; fire3 = fire3 || g.fire3; }
|
||||||
k.throttle = Kit.clamp(k.throttle + g.throttle, -1, 1); k.turn = Kit.clamp(k.turn + g.turn, -1, 1);
|
const s = F.s, me = s.robots[0], en = s.robots[1];
|
||||||
k.fire = k.fire || g.fire; k.fire2 = k.fire2 || g.fire2;
|
let k = { throttle: ky, turn: kx, fire, fire2, fire3 };
|
||||||
|
if (settings.steer === 'simple' && view.camMode === 'iso') {
|
||||||
|
// keys = direction on screen; the robot turns towards it and drives
|
||||||
|
// (iso camera: screen up = world (-1,-1), screen right = world (1,-1))
|
||||||
|
const dx = (kx - ky) / Math.SQRT2, dz = (-kx - ky) / Math.SQRT2;
|
||||||
|
const wrap = a => { while (a > Math.PI) a -= 2 * Math.PI; while (a < -Math.PI) a += 2 * Math.PI; return a; };
|
||||||
|
if (Math.hypot(dx, dz) < 0.2) k = { throttle: 0, turn: 0, fire, fire2, fire3 };
|
||||||
|
else {
|
||||||
|
let diff = wrap(Math.atan2(dz, dx) - me.a);
|
||||||
|
// target behind: drive backwards there instead of a slow 180° turn on the spot
|
||||||
|
// (with a little hysteresis so it does not flip between forward and reverse)
|
||||||
|
const back = F.revDir ? Math.abs(diff) > 1.2 : Math.abs(diff) > 2.1;
|
||||||
|
F.revDir = back;
|
||||||
|
if (back) diff = wrap(diff + Math.PI);
|
||||||
|
const ad = Math.abs(diff);
|
||||||
|
const thr = ad < 0.9 ? 1 : ad < 1.6 ? 0.6 : 0.2; // keep rolling while turning
|
||||||
|
k = { throttle: back ? -thr : thr, turn: Kit.clamp(diff * 3.5, -1, 1), fire, fire2, fire3 };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// weapon helper: fires the main weapon in reach, the tower when in range
|
||||||
|
if (settings.autofire) {
|
||||||
|
const w = me.st.weapon, tw = me.st.tower, dist = Math.hypot(en.x - me.x, en.z - me.z);
|
||||||
|
if (w && !k.fire) {
|
||||||
|
if (w.type === 'spinner' || w.type === 'vspinner') k.fire = dist < 5;
|
||||||
|
else if (w.type === 'saw') k.fire = dist < 2.4;
|
||||||
|
else if (w.type !== 'wedge') k.fire = RC.Combat.inZone(s, me, en);
|
||||||
|
}
|
||||||
|
if (tw && !k.fire2) {
|
||||||
|
// the turret fires forward now, so only help when the enemy is actually in front
|
||||||
|
const d = Math.atan2(en.z - me.z, en.x - me.x) - me.a;
|
||||||
|
const ahead = Math.abs(Math.atan2(Math.sin(d), Math.cos(d)));
|
||||||
|
const near = tw.type === 'flamer' || tw.type === 'zapper';
|
||||||
|
k.fire2 = dist < tw.range * 0.95 && ahead < (near ? 0.5 : 0.3);
|
||||||
|
}
|
||||||
|
if (me.st.gadget && !k.fire3) k.fire3 = RC.Combat.wantGadget(s, me, en);
|
||||||
}
|
}
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// health bar colour: paint, or the accent when the paint is too dark to read
|
||||||
|
const barCol = p => { const c = p.body >>> 0, l = ((c >> 16) & 255) * 0.3 + ((c >> 8) & 255) * 0.59 + (c & 255) * 0.11; return hex(l < 60 ? p.accent : p.body); };
|
||||||
|
const CAMS = ['iso', 'chase', 'fpv'];
|
||||||
|
function cycleCam() {
|
||||||
|
settings.cam = CAMS[(CAMS.indexOf(settings.cam) + 1) % CAMS.length];
|
||||||
|
saveSettings(); view.setCam(settings.cam); SFX.click();
|
||||||
|
banner(t('cam_' + settings.cam), '#ffffff', 1);
|
||||||
|
}
|
||||||
|
// minimap for chase / cockpit view: arena, traps, pit, both robots
|
||||||
|
function minimap() {
|
||||||
|
const touch = window.matchMedia && matchMedia('(pointer: coarse)').matches;
|
||||||
|
const s = F.s, A = s.arena, S = touch ? 104 : 128, X = W - S - 14, Y = touch ? 84 : H - S - 14, k = S / (A.half * 2);
|
||||||
|
// rotate 45° like the iso view, so "up" matches the arena camera
|
||||||
|
const P = (x, z) => [X + S / 2 + (x - z) * k * 0.7071, Y + S / 2 + (x + z) * k * 0.7071];
|
||||||
|
ctx.save();
|
||||||
|
ctx.fillStyle = 'rgba(10,12,16,.72)'; ctx.strokeStyle = 'rgba(255,255,255,.25)'; ctx.lineWidth = 1;
|
||||||
|
const poly = pts => { ctx.beginPath(); pts.forEach(([x, z], i) => { const [px, py] = P(x, z); if (i) ctx.lineTo(px, py); else ctx.moveTo(px, py); }); ctx.closePath(); };
|
||||||
|
const h = A.half;
|
||||||
|
if (A.shape === 'round') poly(Array.from({ length: 20 }, (_, i) => { const a = i / 20 * Math.PI * 2; return [Math.cos(a) * h, Math.sin(a) * h]; }));
|
||||||
|
else if (A.shape === 'octagon') { const d = h * 0.67; poly([[-d, -h], [d, -h], [h, -d], [h, d], [d, h], [-d, h], [-h, d], [-h, -d]]); }
|
||||||
|
else poly([[-h, -h], [h, -h], [h, h], [-h, h]]);
|
||||||
|
ctx.fill(); ctx.stroke();
|
||||||
|
const rect = (o, col) => { ctx.fillStyle = col; poly([[o.x - o.hw, o.z - o.hd], [o.x + o.hw, o.z - o.hd], [o.x + o.hw, o.z + o.hd], [o.x - o.hw, o.z + o.hd]]); ctx.fill(); };
|
||||||
|
rect(A.press, 'rgba(242,181,28,.35)'); rect(A.crane, 'rgba(242,181,28,.35)');
|
||||||
|
rect(A.pit, s.pitOpen >= 1 ? 'rgba(255,40,40,.85)' : 'rgba(255,255,255,.12)');
|
||||||
|
for (const f of A.flames) rect(f, RC.hazardOn(f, s.t) ? 'rgba(255,110,20,.85)' : 'rgba(255,110,20,.25)');
|
||||||
|
for (const sw of A.saws) { const [px, py] = P(sw.x, sw.z); ctx.fillStyle = RC.hazardOn(sw, s.t) ? 'rgba(255,60,60,.9)' : 'rgba(200,200,200,.3)'; ctx.beginPath(); ctx.arc(px, py, sw.r * k, 0, 7); ctx.fill(); }
|
||||||
|
for (const bl of A.belts) rect(bl, 'rgba(80,170,255,.35)');
|
||||||
|
for (const o of A.oil) { const [px, py] = P(o.x, o.z); ctx.fillStyle = 'rgba(12,12,20,.65)'; ctx.beginPath(); ctx.arc(px, py, o.r * k, 0, 7); ctx.fill(); }
|
||||||
|
for (const m of A.rams) rect(m, RC.hazardOn(m, s.t) ? 'rgba(255,60,60,.8)' : 'rgba(200,200,200,.25)');
|
||||||
|
for (const b of A.blocks) rect(b, 'rgba(150,160,175,.6)');
|
||||||
|
s.robots.forEach((r, i) => {
|
||||||
|
if (r.out) return;
|
||||||
|
const [px, py] = P(r.x, r.z), [qx, qy] = P(r.x + Math.cos(r.a), r.z + Math.sin(r.a)), ang = Math.atan2(qy - py, qx - px);
|
||||||
|
ctx.save(); ctx.translate(px, py); ctx.rotate(ang);
|
||||||
|
ctx.fillStyle = i === 0 ? hex(save.paint.body) : hex(F.opp.paint.body); ctx.strokeStyle = i === 0 ? '#fff' : '#000'; ctx.lineWidth = 1.5;
|
||||||
|
ctx.beginPath(); ctx.moveTo(7, 0); ctx.lineTo(-5, 5); ctx.lineTo(-5, -5); ctx.closePath(); ctx.fill(); ctx.stroke();
|
||||||
|
ctx.restore();
|
||||||
|
});
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
function banner(text, color, time = 1.4) { F.banner = { text, color: color || '#ff7a1a', t: time, max: time }; }
|
function banner(text, color, time = 1.4) { F.banner = { text, color: color || '#ff7a1a', t: time, max: time }; }
|
||||||
|
|
||||||
function update(dt) {
|
function update(dt) {
|
||||||
@@ -470,21 +800,29 @@
|
|||||||
introTick();
|
introTick();
|
||||||
if (mode !== 'fight' || !F) return;
|
if (mode !== 'fight' || !F) return;
|
||||||
if (F.count > 0) {
|
if (F.count > 0) {
|
||||||
|
if (F.nf) F.nf.idle(dt);
|
||||||
F.count -= dt;
|
F.count -= dt;
|
||||||
const n = Math.ceil(F.count);
|
const n = Math.ceil(F.count);
|
||||||
if (n < F.beat) { F.beat = n; if (n > 0) { SFX.beep(false); banner(String(n), '#fff', 0.9); } else { SFX.beep(true); banner(t('fight_go'), '#ff7a1a', 1.1); } }
|
if (n < F.beat) { F.beat = n; if (n > 0) { SFX.beep(false); banner(String(n), '#fff', 0.9); } else { SFX.beep(true); banner(t('fight_go'), '#ff7a1a', 1.1); } }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const s = F.s, [me, en] = s.robots;
|
const s = F.s, [me, en] = s.robots;
|
||||||
RC.Combat.step(s, dt, [F.auto ? F.auto.think(s, me, en, dt) : playerInput(), F.brain.think(s, en, me, dt)]);
|
let events;
|
||||||
for (const e of s.events) {
|
if (F.online) {
|
||||||
|
events = F.online.host ? F.nf.hostStep(s, playerInput(), dt) : F.nf.guestFrame(s, playerInput(), dt);
|
||||||
|
} else {
|
||||||
|
RC.Combat.step(s, dt, [F.auto ? F.auto.think(s, me, en, dt) : playerInput(), F.brain.think(s, en, me, dt)]);
|
||||||
|
events = s.events;
|
||||||
|
}
|
||||||
|
for (const e of events) {
|
||||||
SFX.event(e);
|
SFX.event(e);
|
||||||
if (e.type === 'dmg') F.acc[e.who] += e.amount;
|
if (e.type === 'dmg') { F.acc[e.who] += e.amount; if (e.amount >= 3) flashBox(e.who); }
|
||||||
else if (e.type === 'pit_open') banner(t('pit_open'), '#ff4a3a', 2);
|
else if (e.type === 'pit_open') banner(t('pit_open'), '#ff4a3a', 2);
|
||||||
else if (e.type === 'pit') banner(t('into_pit'), '#ff4a3a', 2.2);
|
else if (e.type === 'pit') banner(t('into_pit'), '#ff4a3a', 2.2);
|
||||||
else if (e.type === 'ko') banner(t('knockout'), '#ff7a1a', 2.2);
|
else if (e.type === 'ko') banner(t('knockout'), '#ff7a1a', 2.2);
|
||||||
|
else if (e.type === 'broke') banner(t(e.who === 0 ? 'broke_you' : 'broke_enemy', { p: t('slot_' + e.part) }), e.who === 0 ? '#ff5a4a' : '#ffc940', 1.8);
|
||||||
}
|
}
|
||||||
view.events(s.events);
|
view.events(events);
|
||||||
s.events.length = 0;
|
s.events.length = 0;
|
||||||
SFX.loops(s);
|
SFX.loops(s);
|
||||||
// damage numbers, grouped
|
// damage numbers, grouped
|
||||||
@@ -501,10 +839,59 @@
|
|||||||
if (s.result && s.endIn <= 0 && !F.ended) { F.ended = true; endFight(); }
|
if (s.result && s.endIn <= 0 && !F.ended) { F.ended = true; endFight(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cooldown chips for the parts actually fitted (built once, only --p changes per frame)
|
||||||
|
const CD_KEY = { weapon: '␣', tower: '⇧', gadget: 'G' };
|
||||||
|
function buildCds() {
|
||||||
|
const el = $('fCds');
|
||||||
|
el.innerHTML = RC.Combat.cooldowns(F.s.robots[0]).map(c =>
|
||||||
|
`<div class="cdchip" data-slot="${c.slot}" style="--p:0"><div class="in">${RC.pic('part_' + c.id, '🔧')}</div>` +
|
||||||
|
`<b class="k">${CD_KEY[c.slot]}</b>${c.n === undefined ? '' : `<b class="n">${c.n}</b>`}</div>`).join('');
|
||||||
|
}
|
||||||
|
// condition panel: every part that can be torn off, shown per robot and greyed out when it is gone
|
||||||
|
const BREAKABLE = ['armour', 'wheels', 'weapon', 'tower'];
|
||||||
|
function buildDmg(i, build) {
|
||||||
|
const icons = BREAKABLE.filter(k => build[k]).map(k =>
|
||||||
|
`<span class="pt" data-part="${k}" title="${t('slot_' + k)}">${RC.pic('part_' + build[k], GLYPH_SLOT[k])}</span>`).join('');
|
||||||
|
$('fD' + i).innerHTML = `<span class="hpn"></span><span class="pts">${icons}</span>`;
|
||||||
|
}
|
||||||
|
const GLYPH_SLOT = { armour: '🛡️', wheels: '🛞', weapon: '🪓', tower: '🔥' };
|
||||||
|
|
||||||
|
// short red flash on the box that just took a solid hit
|
||||||
|
let hitT = [0, 0];
|
||||||
|
function flashBox(who) {
|
||||||
|
const el = $(who === 0 ? 'fLeft' : 'fRight');
|
||||||
|
el.classList.add('hit');
|
||||||
|
clearTimeout(hitT[who]);
|
||||||
|
hitT[who] = setTimeout(() => el.classList.remove('hit'), 120);
|
||||||
|
}
|
||||||
|
|
||||||
function fightHud() {
|
function fightHud() {
|
||||||
if (!F) return;
|
if (!F) return;
|
||||||
const s = F.s;
|
const s = F.s;
|
||||||
for (let i = 0; i < 2; i++) $('fH' + i).style.width = (s.robots[i].hp / s.robots[i].maxHp * 100).toFixed(1) + '%';
|
for (let i = 0; i < 2; i++) {
|
||||||
|
const r = s.robots[i], pct = r.hp / r.maxHp;
|
||||||
|
$('fH' + i).style.width = (pct * 100).toFixed(1) + '%';
|
||||||
|
$('fG' + i).style.width = (pct * 100).toFixed(1) + '%'; // trails behind (CSS transition)
|
||||||
|
$(i === 0 ? 'fLeft' : 'fRight').classList.toggle('hurt', pct < 0.25 && !r.dead);
|
||||||
|
// readable damage: hit points left, and every torn-off part crossed out live
|
||||||
|
const el = $('fD' + i), hpn = el.querySelector('.hpn');
|
||||||
|
const txt = `${Math.ceil(r.hp)}/${Math.round(r.maxHp)}`;
|
||||||
|
if (hpn && hpn.textContent !== txt) hpn.textContent = txt;
|
||||||
|
for (const ps of el.querySelectorAll('.pt')) ps.classList.toggle('gone', !!(r.lost && r.lost[ps.dataset.part]));
|
||||||
|
}
|
||||||
|
const own = s.robots[0].hp / s.robots[0].maxHp;
|
||||||
|
$('dmgvig').style.opacity = own < 0.3 && !s.robots[0].out ? ((0.3 - own) / 0.3 * 0.6).toFixed(2) : 0;
|
||||||
|
const cds = RC.Combat.cooldowns(s.robots[0]), chips = $('fCds').children;
|
||||||
|
for (let i = 0; i < chips.length && i < cds.length; i++) {
|
||||||
|
const ch = chips[i], c = cds[i];
|
||||||
|
ch.style.setProperty('--p', c.p.toFixed(2));
|
||||||
|
ch.classList.toggle('on', !!c.on);
|
||||||
|
ch.classList.toggle('spent', c.n === 0);
|
||||||
|
ch.classList.toggle('broke', !!c.broke);
|
||||||
|
const n = ch.querySelector('.n');
|
||||||
|
if (n && n.textContent !== String(c.n)) n.textContent = c.n;
|
||||||
|
if (c.slot === 'gadget') { const pg = $('padGadget'); if (pg) pg.style.setProperty('--p', c.p.toFixed(2)); }
|
||||||
|
}
|
||||||
const sec = Math.ceil(s.left);
|
const sec = Math.ceil(s.left);
|
||||||
$('fTime').textContent = `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, '0')}`;
|
$('fTime').textContent = `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, '0')}`;
|
||||||
$('fTime').classList.toggle('low', sec <= 10);
|
$('fTime').classList.toggle('low', sec <= 10);
|
||||||
@@ -512,19 +899,24 @@
|
|||||||
let st = '';
|
let st = '';
|
||||||
if (me.lifted) st = t('st_lifted'); else if (me.grabbedBy !== null) st = t('st_grabbed');
|
if (me.lifted) st = t('st_lifted'); else if (me.grabbedBy !== null) st = t('st_grabbed');
|
||||||
else if (me.flipped > 0 && !me.st.invertible) st = t('st_flipped'); else if (me.stun > 0) st = t('st_stunned');
|
else if (me.flipped > 0 && !me.st.invertible) st = t('st_flipped'); else if (me.stun > 0) st = t('st_stunned');
|
||||||
else if (s.pitAlarm) st = t('pit_is_open'); else if (s.left - RC.ARENA.pitOpensAt < 10 && s.left > RC.ARENA.pitOpensAt) st = t('pit_soon');
|
else if (s.pitAlarm) st = t('pit_is_open'); else if (s.left - s.arena.pitOpensAt < 10 && s.left > s.arena.pitOpensAt) st = t('pit_soon');
|
||||||
$('fState').textContent = st;
|
$('fState').textContent = st;
|
||||||
}
|
}
|
||||||
|
|
||||||
function endFight() {
|
function endFight() {
|
||||||
const s = F.s, res = s.result, opp = F.opp, idx = RC.LEAGUE.indexOf(opp);
|
const s = F.s, res = s.result, opp = F.opp, idx = RC.LEAGUE.indexOf(opp);
|
||||||
const won = res.winner === 0, me = s.robots[0];
|
const won = res.winner === 0, me = s.robots[0];
|
||||||
|
if (F.online) { endOnlineFight(res, won, me); return; }
|
||||||
const lines = [];
|
const lines = [];
|
||||||
let money = 0, fame = 0, champion = false;
|
let money = 0, fame = 0, champion = false;
|
||||||
if (!F.training) {
|
if (!F.training) {
|
||||||
const prize = Math.round(opp.prize * seasonMul());
|
const prize = Math.round(opp.prize * seasonMul() * (F.exhibition ? 0.5 : 1));
|
||||||
save.games++;
|
save.games++;
|
||||||
if (won) {
|
if (won && F.exhibition) {
|
||||||
|
money += prize; lines.push([t('r_exhibition'), prize]);
|
||||||
|
fame = (idx + 1) * 10 * save.season;
|
||||||
|
save.wins++;
|
||||||
|
} else if (won) {
|
||||||
const bonus = res.reason === 'pit' ? 0.3 : res.reason === 'ko' ? 0.2 : 0;
|
const bonus = res.reason === 'pit' ? 0.3 : res.reason === 'ko' ? 0.2 : 0;
|
||||||
money += prize; lines.push([t('r_prize'), prize]);
|
money += prize; lines.push([t('r_prize'), prize]);
|
||||||
if (bonus) { const b = Math.round(prize * bonus); money += b; lines.push([t('r_bonus_' + res.reason), b]); }
|
if (bonus) { const b = Math.round(prize * bonus); money += b; lines.push([t('r_bonus_' + res.reason), b]); }
|
||||||
@@ -537,10 +929,13 @@
|
|||||||
save.season++; save.beaten = 0;
|
save.season++; save.beaten = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const ap = Math.round(prize * 0.2); money += ap; lines.push([t('r_appearance'), ap]);
|
const ap = Math.round(prize * 0.35); money += ap; lines.push([t('r_appearance'), ap]);
|
||||||
save.losses++;
|
save.losses++;
|
||||||
}
|
}
|
||||||
const repair = Math.round((1 - me.hp / me.maxHp) * me.st.value * 0.12 + (res.reason === 'pit' && !won ? me.st.value * 0.05 : 0));
|
// every hit pays: damage bonus win or lose
|
||||||
|
const db = Math.round(me.dealt * 0.6 * (F.exhibition ? 0.5 : 1));
|
||||||
|
if (db) { money += db; lines.push([t('r_dmg_bonus'), db]); }
|
||||||
|
const repair = Math.round((1 - me.hp / me.maxHp) * me.st.value * 0.06 + (res.reason === 'pit' && !won ? me.st.value * 0.03 : 0));
|
||||||
const paid = Math.min(repair, save.money + money);
|
const paid = Math.min(repair, save.money + money);
|
||||||
if (paid) lines.push([t('r_repair'), -paid]);
|
if (paid) lines.push([t('r_repair'), -paid]);
|
||||||
money -= paid;
|
money -= paid;
|
||||||
@@ -561,19 +956,62 @@
|
|||||||
<div class="row"><button class="primary" id="bGarage">${t('to_garage')}</button>${!F.training && !won ? `<button id="bRetry">${t('retry')}</button>` : ''}</div>${boardHtml()}`,
|
<div class="row"><button class="primary" id="bGarage">${t('to_garage')}</button>${!F.training && !won ? `<button id="bRetry">${t('retry')}</button>` : ''}</div>${boardHtml()}`,
|
||||||
{ bg: won ? 'bg_win.jpg' : 'bg_lose.jpg' });
|
{ bg: won ? 'bg_win.jpg' : 'bg_lose.jpg' });
|
||||||
$('bGarage').onclick = () => { SFX.click(); openGarage(); };
|
$('bGarage').onclick = () => { SFX.click(); openGarage(); };
|
||||||
if ($('bRetry')) $('bRetry').onclick = () => { SFX.click(); startFight(opp, false); };
|
if ($('bRetry')) $('bRetry').onclick = () => { SFX.click(); startFight(opp, false, F.exhibition); };
|
||||||
if (!F.training && save.fame > save.best) {
|
if (!F.training && save.fame > save.best) {
|
||||||
save.best = save.fame; persist();
|
save.best = save.fame; persist();
|
||||||
scores.submit({ name: playerName(), score: save.fame, level: save.season }).then(fillBoard);
|
scores.submit({ name: playerName(), score: save.fame, level: save.season }).then(fillBoard);
|
||||||
} else fillBoard();
|
} else fillBoard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function endOnlineFight(res, won, me) {
|
||||||
|
if (F.nf) F.nf.stop();
|
||||||
|
if (lobby) lobby.endMatch();
|
||||||
|
(won ? SFX.win : SFX.lose)();
|
||||||
|
const title = res.winner === -1 ? t('draw') : won ? t('victory') : t('defeat');
|
||||||
|
// online rewards: prize (win) / half (draw) / appearance fee (loss) + damage bonus - repairs; fame on a win
|
||||||
|
const PVP = 600, lines = [];
|
||||||
|
let money = 0, fame = 0;
|
||||||
|
const draw = res.winner === -1;
|
||||||
|
if (won) { money += PVP; lines.push([t('r_prize'), PVP]); fame = 150 + (res.reason === 'ko' ? 40 : res.reason === 'pit' ? 60 : 0); }
|
||||||
|
else if (draw) { money += PVP / 2; lines.push([t('r_draw_prize'), PVP / 2]); fame = 40; }
|
||||||
|
else { const ap = Math.round(PVP * 0.35); money += ap; lines.push([t('r_appearance'), ap]); }
|
||||||
|
if (won && res.reason !== 'time') { const b = Math.round(PVP * (res.reason === 'pit' ? 0.3 : 0.2)); money += b; lines.push([t('r_bonus_' + res.reason), b]); }
|
||||||
|
const db = Math.round(me.dealt * 0.6);
|
||||||
|
if (db) { money += db; lines.push([t('r_dmg_bonus'), db]); }
|
||||||
|
const repair = Math.round((1 - me.hp / me.maxHp) * me.st.value * 0.06);
|
||||||
|
const paid = Math.min(repair, save.money + money);
|
||||||
|
if (paid) { money -= paid; lines.push([t('r_repair'), -paid]); }
|
||||||
|
save.money += money; save.fame += fame; save.games++;
|
||||||
|
if (won) save.wins++; else if (!draw) save.losses++;
|
||||||
|
persist(); hud();
|
||||||
|
if (save.fame > save.best) { save.best = save.fame; persist(); scores.submit({ name: playerName(), score: save.fame, level: save.season }); }
|
||||||
|
const rows = lines.map(([k, v]) => `<span>${k}</span><span class="${v < 0 ? 'minus' : 'plus'}">${v < 0 ? '−' : '+'}${Kit.fmt(Math.abs(v))}</span>`).join('');
|
||||||
|
setScreen('result');
|
||||||
|
card(`<h1>${title}</h1><p>${esc(F.opp.name)} ${F.nf && !F.nf.peerAlive ? t('peer_left') : ''}</p>
|
||||||
|
<div class="res"><span>${t('r_dealt')}</span><span>${Math.round(me.dealt)}</span><span>${t('r_taken')}</span><span>${Math.round(me.taken)}</span>${rows}
|
||||||
|
${fame ? `<span>${t('hud_fame')}</span><span class="plus">+${Kit.fmt(fame)}</span>` : ''}</div>
|
||||||
|
<div class="row"><button class="primary" id="bLobby">${t('back_to_lobby')}</button><button id="bShopO">${t('to_garage')}</button></div>`,
|
||||||
|
{ bg: won ? 'bg_win.jpg' : 'bg_lose.jpg' });
|
||||||
|
$('bLobby').onclick = () => { SFX.click(); showLobby(); };
|
||||||
|
$('bShopO').onclick = () => { SFX.click(); openGarage(); };
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- loop
|
// ---------------------------------------------------------------- loop
|
||||||
let lastNow = 0;
|
let lastNow = 0, fpsN = 0, fpsT = 0, fpsVal = 0;
|
||||||
function render(alpha, now) {
|
function render(alpha, now) {
|
||||||
|
// cap rendering: ~60 fps during action, ~16 fps when a static menu covers the arena (saves CPU/GPU on
|
||||||
|
// high-refresh monitors and in menus). update() stays fixed 60 Hz via the loop, so physics is unaffected.
|
||||||
|
const active = mode === 'fight' || mode === 'pause' || mode === 'intro' || mode === 'garage';
|
||||||
|
const minGap = active ? 15.5 : 60;
|
||||||
|
if (lastNow && now - lastNow < minGap) return;
|
||||||
const dt = Math.min(0.05, lastNow ? (now - lastNow) / 1000 : 0.016); lastNow = now;
|
const dt = Math.min(0.05, lastNow ? (now - lastNow) / 1000 : 0.016); lastNow = now;
|
||||||
if (view) view.frame(mode === 'pause' ? 0 : dt, now);
|
if (view) view.frame(mode === 'pause' ? 0 : dt, now);
|
||||||
ctx.clearRect(0, 0, W, H);
|
ctx.clearRect(0, 0, W, H);
|
||||||
|
if (DEV.has('fps')) { // dev: ?fps shows the effective render rate
|
||||||
|
fpsN++; if (now - fpsT > 500) { fpsVal = Math.round(fpsN * 1000 / (now - fpsT)); fpsN = 0; fpsT = now; }
|
||||||
|
ctx.fillStyle = '#6dff9e'; ctx.font = '14px monospace'; ctx.textAlign = 'left'; ctx.textBaseline = 'top';
|
||||||
|
ctx.fillText(fpsVal + ' fps · ' + settings.gfx, 10, 10);
|
||||||
|
}
|
||||||
if (mode === 'intro' && view) {
|
if (mode === 'intro' && view) {
|
||||||
const it = view.introTime;
|
const it = view.introTime;
|
||||||
if (it > 5.6) {
|
if (it > 5.6) {
|
||||||
@@ -604,15 +1042,18 @@
|
|||||||
ctx.fillStyle = b.color; ctx.fillText(b.text, 0, 0);
|
ctx.fillStyle = b.color; ctx.fillText(b.text, 0, 0);
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
}
|
}
|
||||||
|
if (view.camMode !== 'iso') minimap();
|
||||||
if (mode === 'fight' && F.s.t < 7 && F.count <= 0) {
|
if (mode === 'fight' && F.s.t < 7 && F.count <= 0) {
|
||||||
ctx.font = '13px "Segoe UI", sans-serif'; ctx.textAlign = 'center'; ctx.fillStyle = 'rgba(232,235,242,.75)';
|
ctx.font = '13px "Segoe UI", sans-serif'; ctx.textAlign = 'center'; ctx.fillStyle = 'rgba(232,235,242,.75)';
|
||||||
ctx.fillText(t('fight_hint'), W / 2, H - 16);
|
ctx.fillText(t(settings.steer === 'simple' && view.camMode === 'iso' ? 'fight_hint_simple' : 'fight_hint'), W / 2, H - 16);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const loop = Kit.loop({ step: 1000 / 60, update, render }).start();
|
const loop = Kit.loop({ step: 1000 / 60, update, render }).start();
|
||||||
|
|
||||||
function togglePause() {
|
function togglePause() {
|
||||||
|
overlayEnter();
|
||||||
|
if (F && F.online && mode === 'fight') { banner(t('no_pause_online'), '#ffffff', 1.4); return; }
|
||||||
if (mode === 'fight') {
|
if (mode === 'fight') {
|
||||||
mode = 'pause'; loop.pause();
|
mode = 'pause'; loop.pause();
|
||||||
card(`<h2>${t('pause')}</h2><div class="row"><button id="bSet2">⚙ ${t('settings')}</button><button id="bQuit">${t('give_up')}</button><button class="primary" id="bGo">${t('continue')}</button></div>`);
|
card(`<h2>${t('pause')}</h2><div class="row"><button id="bSet2">⚙ ${t('settings')}</button><button id="bQuit">${t('give_up')}</button><button class="primary" id="bGo">${t('continue')}</button></div>`);
|
||||||
@@ -627,33 +1068,58 @@
|
|||||||
function toggleMute() { audio.toggleMute(); hud(); }
|
function toggleMute() { audio.toggleMute(); hud(); }
|
||||||
$('bMute').onclick = toggleMute;
|
$('bMute').onclick = toggleMute;
|
||||||
$('bPause').onclick = togglePause;
|
$('bPause').onclick = togglePause;
|
||||||
addEventListener('blur', () => { if (mode === 'fight') togglePause(); });
|
addEventListener('blur', () => { if (mode === 'fight' && !(F && F.online)) togglePause(); });
|
||||||
// language switch: static texts update themselves (data-i18n), dynamic screens are drawn again
|
// language switch: static texts update themselves (data-i18n), dynamic screens are drawn again
|
||||||
L.onChange(() => {
|
L.onChange(() => {
|
||||||
hud();
|
hud();
|
||||||
if (mode === 'title') showTitle();
|
if (mode === 'title') showTitle();
|
||||||
else if (mode === 'garage') shop.render();
|
else if (mode === 'garage') shop.render();
|
||||||
else if (mode === 'league') showLeague();
|
else if (mode === 'league') showLeague();
|
||||||
|
else if (mode === 'lobby') renderLobby();
|
||||||
if (F) { $('fW0').textContent = weaponName(save.build); $('fW1').textContent = weaponName(F.opp.build); }
|
if (F) { $('fW0').textContent = weaponName(save.build); $('fW1').textContent = weaponName(F.opp.build); }
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------- start
|
// ---------------------------------------------------------------- start
|
||||||
accounts.resume();
|
accounts.resume();
|
||||||
|
if (net && net.enabled) { net.auth.resume(); net.auth.onChange(() => { hud(); if (mode === 'title') showTitle(); }); }
|
||||||
hud();
|
hud();
|
||||||
if (!view) {
|
if (!view) {
|
||||||
card(`<h1>Robot Clash</h1><p>${t('no_webgl')}</p><p class="credits">${CREDITS}</p>`);
|
card(`<h1>Robot Clash</h1><p>${t('no_webgl')}</p><p class="credits">${CREDITS}</p>`);
|
||||||
} else if (DEV.has('fight') || DEV.has('play')) {
|
} else if (DEV.has('fight') || DEV.has('play')) {
|
||||||
// dev: ?play = straight into the shop, ?fight=N = training fight against league robot N
|
// dev: ?play = straight into the shop, ?fight=N = training fight against league robot N
|
||||||
if (!accounts.current) accounts.guest();
|
if (!accounts.current) accounts.guest();
|
||||||
slot = Kit.saveSlot(accounts.saveKey(), newSave); save = slot.load(); repairSave(); hud();
|
loadSave(); hud();
|
||||||
|
if (DEV.get('equip')) for (const id of DEV.get('equip').split(',')) { const p = RC.PARTS[id]; if (p) { if (!save.owned.includes(id)) save.owned.push(id); save.build[p.slot] = id; } }
|
||||||
|
if (DEV.get('arena')) settings.arena = DEV.get('arena');
|
||||||
RC.layerFromData(layer, save.paint.decal, () => { if (mode === 'garage') view.showGarage(save.build, paintObj()); });
|
RC.layerFromData(layer, save.paint.decal, () => { if (mode === 'garage') view.showGarage(save.build, paintObj()); });
|
||||||
|
if (DEV.get('hangar')) { const n = Math.min(MAX_ROBOTS, +DEV.get('hangar') || 3); while (save.robots.length < n) save.robots.push(newRobotDef(t('robot_n', { n: save.robots.length + 1 }))); }
|
||||||
if (DEV.has('fight')) startFight(RC.LEAGUE[Kit.clamp(+DEV.get('fight') || 0, 0, 7)], true); else openGarage();
|
if (DEV.has('fight')) startFight(RC.LEAGUE[Kit.clamp(+DEV.get('fight') || 0, 0, 7)], true); else openGarage();
|
||||||
|
if (DEV.get('shoptab') && mode === 'garage') shop.setTab(DEV.get('shoptab'));
|
||||||
|
if (DEV.get('sel') && mode === 'garage') { const id = DEV.get('sel'), p = RC.PARTS[id]; if (p) { const tb = document.querySelector(`.tab[data-slot="${p.slot}"]`); if (tb) tb.click(); const it = document.querySelector(`.item[data-id="${id}"]`); if (it) it.click(); } }
|
||||||
|
// dev: ?play&screen=league|vs|settings|help|lobby|pause opens that screen (layout screenshots)
|
||||||
|
const scr = DEV.get('screen');
|
||||||
|
if (scr === 'league') { save.beaten = Math.max(save.beaten, 3); showLeague(); }
|
||||||
|
else if (scr === 'vs') showVs(RC.LEAGUE[4]);
|
||||||
|
else if (scr === 'settings') showSettings(openGarage);
|
||||||
|
else if (scr === 'help') showHelp(openGarage);
|
||||||
|
else if (scr === 'lobby') {
|
||||||
|
lobbyRows = [{ uid: 'a', name: 'BlechBrecher', flag: 'DE', fame: 1250, state: 'idle' }, { uid: 'b', name: 'SawQueen', flag: 'DE', fame: 430, state: 'inmatch' }, { uid: 'c', name: 'Rostlaube77', flag: 'AT', fame: 90, state: 'idle' }, { uid: 'd', name: 'Flipmaster', flag: 'GB', fame: 600, state: 'idle' }];
|
||||||
|
lobbyRoom = DEV.get('room') || null;
|
||||||
|
showLobby();
|
||||||
|
}
|
||||||
|
if (DEV.get('tab')) { const tb = document.querySelector(`.tab[data-slot="${DEV.get('tab')}"]`); if (tb) tb.click(); }
|
||||||
|
// dev: &buy=<part id> buys it through the real shop buttons (header check)
|
||||||
|
if (DEV.get('buy')) { const it = document.querySelector(`.item[data-id="${DEV.get('buy')}"]`); if (it) { it.click(); const b = document.querySelector('#detail button[data-act="buy"]'); if (b) b.click(); } }
|
||||||
|
// dev: &equip=wedge,flamer forces parts onto the robot (ignores cost), then shows the garage
|
||||||
|
if (DEV.get('equip') && !DEV.has('fight')) { for (const id of DEV.get('equip').split(',')) { const p = RC.PARTS[id]; if (p) { if (!save.owned.includes(id)) save.owned.push(id); save.build[p.slot] = id; } } persist(); view.showGarage(save.build, paintObj()); shop.render(); }
|
||||||
if (DEV.has('paint')) { // dev: open the paint booth with a test drawing
|
if (DEV.has('paint')) { // dev: open the paint booth with a test drawing
|
||||||
const c = layer.getContext('2d');
|
const c = layer.getContext('2d');
|
||||||
c.fillStyle = '#15171b'; c.fillRect(0, 100, 256, 56); c.fillStyle = '#f2c230'; c.font = 'bold 70px sans-serif'; c.fillText('★ 7', 300, 170);
|
c.fillStyle = '#15171b'; c.fillRect(0, 100, 256, 56); c.fillStyle = '#f2c230'; c.font = 'bold 70px sans-serif'; c.fillText('★ 7', 300, 170);
|
||||||
c.strokeStyle = '#00e5ff'; c.lineWidth = 14; c.beginPath(); c.moveTo(270, 220); c.lineTo(500, 200); c.stroke();
|
c.strokeStyle = '#00e5ff'; c.lineWidth = 14; c.beginPath(); c.moveTo(270, 220); c.lineTo(500, 200); c.stroke();
|
||||||
painter.open(); view.showGarage(save.build, paintObj());
|
painter.open(); view.showGarage(save.build, paintObj());
|
||||||
}
|
}
|
||||||
} else if (DEV.has('title')) startIntroOrTitle();
|
} else if (DEV.has('online') && net.enabled) { startIntroOrTitle(); startOnline(); }
|
||||||
|
else if (DEV.has('title')) startIntroOrTitle();
|
||||||
else startIntro();
|
else startIntro();
|
||||||
|
if (DEV.has('uicheck') && RC.uiCheckRun) RC.uiCheckRun(); // dev: &uicheck prints layout faults as text
|
||||||
})();
|
})();
|
||||||
|
|||||||
416
game/index.html
@@ -6,26 +6,53 @@
|
|||||||
<title>Robot Clash</title>
|
<title>Robot Clash</title>
|
||||||
<link rel="icon" href="assets/Sprites/icon.png">
|
<link rel="icon" href="assets/Sprites/icon.png">
|
||||||
<style>
|
<style>
|
||||||
|
/* Headline font, shipped with the game so it also works offline / in the exe.
|
||||||
|
Russo One (c) 2011-2012 Jovanny Lemonad - SIL Open Font License 1.1 (assets/Fonts/OFL.txt).
|
||||||
|
build-web.mjs turns the url() into a data: URI for the single-file release. */
|
||||||
|
@font-face { font-family: "Russo One"; font-style: normal; font-weight: 400;
|
||||||
|
src: url('assets/Fonts/RussoOne-Regular.ttf') format('truetype'); font-display: swap; }
|
||||||
:root {
|
:root {
|
||||||
--bg: #090b10; --panel: #151920; --panel2: #1c212b; --line: #2d3442; --text: #e8ebf2; --dim: #8d95a8;
|
--bg: #090b10; --panel: #151920; --panel2: #1c212b; --line: #2d3442; --text: #e8ebf2; --dim: #8d95a8;
|
||||||
--accent: #ff7a1a; --good: #6dff9e; --warn: #ff5a4a; --blue: #4fa8ff; --gold: #ffc940;
|
--accent: #ff7a1a; --good: #6dff9e; --warn: #ff5a4a; --blue: #4fa8ff; --gold: #ffc940;
|
||||||
--head: "Russo One", "Segoe UI Black", "Arial Black", Impact, sans-serif;
|
--head: "Russo One", "Segoe UI Black", "Arial Black", Impact, sans-serif;
|
||||||
|
/* shared look: soft metal sheen, 1px top highlight, chamfered corners, hazard tape */
|
||||||
|
--r1: 4px; --r2: 8px; --r3: 12px;
|
||||||
|
--steel: linear-gradient(#242a35, #1a1f28);
|
||||||
|
--sheen: linear-gradient(rgba(255,255,255,.04), rgba(0,0,0,.07));
|
||||||
|
--hl: inset 0 1px 0 rgba(255,255,255,.07);
|
||||||
|
--chamfer: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
|
||||||
|
--hazard: repeating-linear-gradient(45deg, var(--accent) 0 6px, #1a1008 6px 12px);
|
||||||
}
|
}
|
||||||
* { box-sizing: border-box; }
|
* { box-sizing: border-box; }
|
||||||
|
/* never show a scrollbar - screens are built to fit; overflow stays reachable by wheel/touch */
|
||||||
|
* { scrollbar-width: none; -ms-overflow-style: none; }
|
||||||
|
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
|
||||||
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
|
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
|
||||||
font: 15px/1.35 "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
|
font: 15px/1.35 "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
|
||||||
body { display: flex; align-items: center; justify-content: center;
|
body { display: flex; align-items: center; justify-content: center; background: #05060a; }
|
||||||
background: radial-gradient(circle at 50% 25%, #1d1f26 0%, var(--bg) 70%); }
|
|
||||||
|
|
||||||
/* fixed design size, scaled to the window by Kit.fit */
|
/* fixed design size, scaled to the window by Kit.fit */
|
||||||
#app { position: relative; width: 960px; display: flex; flex-direction: column; gap: 8px; }
|
#app { position: relative; width: 1280px; display: flex; flex-direction: column; }
|
||||||
#hud { display: flex; gap: 8px; align-items: center; height: 38px; }
|
/* HUD lives INSIDE the stage (full-screen game look), above the overlay so menus keep it reachable */
|
||||||
|
#hud { position: absolute; left: 0; right: 0; top: 0; z-index: 7; display: flex; gap: 8px; align-items: center;
|
||||||
|
height: 44px; padding: 0 12px; pointer-events: none;
|
||||||
|
background: linear-gradient(rgba(6,8,12,.9) 35%, rgba(6,8,12,0)); }
|
||||||
|
#hud > * { pointer-events: auto; }
|
||||||
|
#hud button { min-height: 34px; padding: 4px 10px; }
|
||||||
|
#hud .icobtn { width: 36px; height: 34px; padding: 0; font-size: 15px; }
|
||||||
|
/* per screen: title has its own menu, the fight only keeps pause + sound under the health box */
|
||||||
|
body[data-mode="intro"] #hud, body[data-mode="title"] #hud, body[data-mode="account"] #hud { display: none; }
|
||||||
|
body[data-mode="fight"] #hud, body[data-mode="pause"] #hud { top: 92px; height: 36px; background: none; }
|
||||||
|
body[data-mode="fight"] #hud > *, body[data-mode="pause"] #hud > * { display: none; }
|
||||||
|
body[data-mode="fight"] #hud > .icobtn, body[data-mode="pause"] #hud > .icobtn { display: block; }
|
||||||
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; display: flex; align-items: center; gap: 6px; }
|
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; display: flex; align-items: center; gap: 6px; }
|
||||||
.chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
|
.chip b { color: var(--accent); font-variant-numeric: tabular-nums; }
|
||||||
.chip .pic { width: 22px; height: 22px; }
|
.chip .pic { width: 22px; height: 22px; }
|
||||||
.grow { flex: 1; }
|
.grow { flex: 1; }
|
||||||
.logo { font-family: var(--head); letter-spacing: .06em; color: var(--accent); font-size: 20px; padding: 0 6px; }
|
.logo { font-family: var(--head); letter-spacing: .06em; color: var(--accent); font-size: 20px; padding: 0 6px; }
|
||||||
#stage { position: relative; width: 960px; height: 540px; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: #000; }
|
#stage { position: relative; width: 1280px; height: 720px; overflow: hidden; background: #000; }
|
||||||
|
#stage::after { content: ''; position: absolute; inset: 0; z-index: 8; pointer-events: none;
|
||||||
|
background: radial-gradient(ellipse at 50% 50%, transparent 55%, rgba(0,0,0,.3) 100%); }
|
||||||
#stage > canvas { position: absolute; left: 0; top: 0; display: block; }
|
#stage > canvas { position: absolute; left: 0; top: 0; display: block; }
|
||||||
#cv { pointer-events: none; z-index: 2; }
|
#cv { pointer-events: none; z-index: 2; }
|
||||||
#gl { z-index: 1; }
|
#gl { z-index: 1; }
|
||||||
@@ -38,27 +65,52 @@
|
|||||||
.pic img { position: relative; width: 100%; height: 100%; object-fit: contain; }
|
.pic img { position: relative; width: 100%; height: 100%; object-fit: contain; }
|
||||||
.pic img.missing { visibility: hidden; }
|
.pic img.missing { visibility: hidden; }
|
||||||
|
|
||||||
button { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line);
|
button { font: inherit; color: var(--text); background: var(--steel); border: 1px solid var(--line);
|
||||||
border-radius: 8px; padding: 6px 12px; cursor: pointer; }
|
border-radius: var(--r2); padding: 6px 12px; min-height: 34px; cursor: pointer; box-shadow: var(--hl);
|
||||||
button:hover { border-color: var(--accent); }
|
transition: border-color .1s, filter .1s, transform .06s; }
|
||||||
button.primary { background: linear-gradient(#ff8f3a, #e8650a); color: #1a0c02; border-color: #ffa25a; font-weight: 700; padding: 10px 24px; font-family: var(--head); letter-spacing: .04em; box-shadow: 0 3px 0 #7a3000; }
|
button:active { transform: translateY(1px); }
|
||||||
button.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a3000; }
|
@media (hover: hover) { button:hover { border-color: var(--accent); filter: brightness(1.12); } }
|
||||||
button:disabled { opacity: .4; cursor: default; }
|
/* main action: chamfered, hazard-orange, with a solid edge instead of a blurred shadow (clip-path cuts shadows) */
|
||||||
button:disabled:hover { border-color: var(--line); }
|
button.primary { background: linear-gradient(#ff8f3a, #e8650a); color: #1a0c02; border: 1px solid #ffa25a;
|
||||||
button.link { background: none; border: none; color: var(--accent); padding: 2px 4px; text-decoration: underline; }
|
border-bottom: 3px solid #7a3000; font-weight: 700; padding: 8px 20px; min-height: 42px;
|
||||||
input[type=text], input[type=password] { font: inherit; width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
|
font-family: var(--head); letter-spacing: .05em; text-transform: uppercase; clip-path: var(--chamfer); box-shadow: none; }
|
||||||
|
button.primary:active { transform: translateY(2px); border-bottom-width: 1px; }
|
||||||
|
button:disabled { opacity: .4; cursor: default; filter: none; }
|
||||||
|
button:disabled:hover { border-color: var(--line); filter: none; }
|
||||||
|
button.link { background: none; border: none; color: var(--accent); padding: 2px 4px; min-height: 0;
|
||||||
|
text-decoration: underline; box-shadow: none; }
|
||||||
|
input[type=text], input[type=password], input[type=email] { font: inherit; width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line);
|
||||||
background: #0b0e14; color: var(--text); }
|
background: #0b0e14; color: var(--text); }
|
||||||
input:focus { outline: none; border-color: var(--accent); }
|
input:focus { outline: none; border-color: var(--accent); }
|
||||||
|
|
||||||
|
/* menus fade in once per screen (#overlay.enter is removed again, so live lists do not flicker) */
|
||||||
|
@keyframes cardIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
|
||||||
|
#overlay.enter > * { animation: cardIn .14s ease-out; }
|
||||||
|
.tab, .item, .fitted .frow, .rroom, .prow { transition: border-color .1s, background-color .1s, transform .1s; }
|
||||||
|
@media (hover: hover) { .item:hover { transform: translateY(-2px); } }
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*, *::before, *::after { animation: none !important; transition: none !important; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* every panel shares the same sheen + top highlight */
|
||||||
|
.card, .fbox, #detail, .item, .prow, .hmrow, .rroom, .opp, .stats, .chip, .tab, .fitted .frow {
|
||||||
|
background-image: var(--sheen); box-shadow: var(--hl); }
|
||||||
|
|
||||||
/* overlays (menus) */
|
/* overlays (menus) */
|
||||||
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
|
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding-top: 40px;
|
||||||
background: rgba(5, 6, 10, .62) center / cover no-repeat; z-index: 6; }
|
background: rgba(5, 6, 10, .62) center / cover no-repeat; z-index: 6; }
|
||||||
|
#overlay::before { content: ''; position: absolute; inset: 0; pointer-events: none;
|
||||||
|
background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(0,0,0,.55) 100%); }
|
||||||
|
body[data-mode="title"] #overlay, body[data-mode="intro"] #overlay { padding-top: 0; }
|
||||||
#overlay.hide { display: none; }
|
#overlay.hide { display: none; }
|
||||||
#overlay.clear { background-color: transparent; }
|
#overlay.clear { background-color: transparent; }
|
||||||
.card { background: rgba(21, 25, 32, .94); border: 1px solid var(--line); border-radius: 14px; padding: 22px 30px;
|
.card { background: rgba(21, 25, 32, .94); border: 1px solid var(--line); border-radius: 14px; padding: 22px 30px;
|
||||||
min-width: 380px; max-width: 760px; text-align: center; box-shadow: 0 20px 60px #000a; }
|
min-width: 380px; max-width: 760px; max-height: 600px; overflow-y: auto; text-align: center; box-shadow: 0 20px 60px #000a; }
|
||||||
.card h1 { margin: 0 0 6px; font: 44px var(--head); letter-spacing: .05em; color: var(--accent); text-shadow: 0 3px 0 #5a2600; }
|
.card h1 { margin: 0 0 6px; font: 44px var(--head); letter-spacing: .05em; color: var(--accent); text-shadow: 0 3px 0 #5a2600; }
|
||||||
.card h2 { margin: 0 0 8px; font: 26px var(--head); letter-spacing: .04em; color: var(--accent); }
|
.card h2 { margin: 0 0 10px; padding-bottom: 8px; font: 26px var(--head); letter-spacing: .04em; color: var(--accent);
|
||||||
|
position: relative; }
|
||||||
|
.card h2::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); bottom: 0;
|
||||||
|
width: 84px; height: 4px; border-radius: 2px; background: var(--hazard); opacity: .85; }
|
||||||
.card h3 { margin: 12px 0 6px; font: 14px var(--head); letter-spacing: .06em; color: var(--dim); text-align: left; }
|
.card h3 { margin: 12px 0 6px; font: 14px var(--head); letter-spacing: .06em; color: var(--dim); text-align: left; }
|
||||||
.card p { color: var(--dim); margin: 6px 0 14px; }
|
.card p { color: var(--dim); margin: 6px 0 14px; }
|
||||||
.board { list-style: none; padding: 0; margin: 14px 0 0; text-align: left; font-variant-numeric: tabular-nums; max-height: 150px; overflow: auto; }
|
.board { list-style: none; padding: 0; margin: 14px 0 0; text-align: left; font-variant-numeric: tabular-nums; max-height: 150px; overflow: auto; }
|
||||||
@@ -73,13 +125,22 @@
|
|||||||
.keys b { color: var(--text); }
|
.keys b { color: var(--text); }
|
||||||
.err { color: var(--warn); font-size: 13px; min-height: 18px; margin: 6px 0; }
|
.err { color: var(--warn); font-size: 13px; min-height: 18px; margin: 6px 0; }
|
||||||
|
|
||||||
/* title screen */
|
/* title screen: menu column on the left, the 3D camera ride stays visible on the right */
|
||||||
.title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 38px;
|
.title { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-start;
|
||||||
background: linear-gradient(180deg, rgba(4,5,8,0) 30%, rgba(4,5,8,.85) 100%); }
|
background: linear-gradient(90deg, rgba(4,5,8,.93) 0%, rgba(4,5,8,.8) 30%, rgba(4,5,8,0) 62%); }
|
||||||
.title .big { font: 76px var(--head); letter-spacing: .06em; color: var(--accent); text-shadow: 0 5px 0 #5a2600, 0 0 40px rgba(255,122,26,.5); line-height: 1; }
|
.tpanel { width: 420px; padding: 0 20px 0 44px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
|
||||||
.title .tag { color: #c9cfdc; margin: 6px 0 18px; text-shadow: 0 2px 4px #000; }
|
.tlogoimg { width: 100%; max-height: 170px; object-fit: contain; object-position: left center;
|
||||||
.title .row { margin-top: 8px; }
|
filter: drop-shadow(0 6px 18px #000); animation: logoglow 3.6s ease-in-out infinite; }
|
||||||
.title .credits { margin-top: 18px; }
|
@keyframes logoglow { 50% { filter: drop-shadow(0 6px 18px #000) drop-shadow(0 0 14px rgba(255,122,26,.45)); } }
|
||||||
|
.title .big { font: 62px var(--head); letter-spacing: .05em; color: var(--accent); line-height: .98;
|
||||||
|
text-shadow: 0 5px 0 #5a2600, 0 0 40px rgba(255,122,26,.5); }
|
||||||
|
.title .tag { color: #c9cfdc; margin: 0; text-shadow: 0 2px 4px #000; }
|
||||||
|
.hazbar { height: 5px; border-radius: 3px; background: var(--hazard); opacity: .9; }
|
||||||
|
.tmenu { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
|
||||||
|
.tmenu button { min-height: 48px; width: 100%; }
|
||||||
|
.trow2 { display: flex; gap: 6px; flex-wrap: wrap; }
|
||||||
|
.trow2 button { flex: 1 1 auto; font-size: 13px; min-height: 36px; padding: 4px 10px; }
|
||||||
|
.title .credits { margin-top: 10px; }
|
||||||
.skip { position: absolute; right: 16px; bottom: 12px; font-size: 12px; color: rgba(255,255,255,.55); }
|
.skip { position: absolute; right: 16px; bottom: 12px; font-size: 12px; color: rgba(255,255,255,.55); }
|
||||||
.form { width: 320px; margin: 0 auto; text-align: left; display: flex; flex-direction: column; gap: 8px; }
|
.form { width: 320px; margin: 0 auto; text-align: left; display: flex; flex-direction: column; gap: 8px; }
|
||||||
.form label { font-size: 13px; color: var(--dim); }
|
.form label { font-size: 13px; color: var(--dim); }
|
||||||
@@ -90,9 +151,17 @@
|
|||||||
/* settings */
|
/* settings */
|
||||||
.set { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; align-items: center; text-align: left; min-width: 460px; }
|
.set { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; align-items: center; text-align: left; min-width: 460px; }
|
||||||
.set input[type=range] { width: 100%; accent-color: var(--accent); }
|
.set input[type=range] { width: 100%; accent-color: var(--accent); }
|
||||||
.seg { display: flex; gap: 4px; }
|
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
|
||||||
.seg button { flex: 1; padding: 5px 8px; font-size: 13px; }
|
.seg button { flex: 1 1 56px; padding: 5px 8px; font-size: 13px; }
|
||||||
.seg button.on { background: var(--accent); color: #1a0c02; border-color: var(--accent); font-weight: 700; }
|
.seg button.on { background: var(--accent); color: #1a0c02; border-color: var(--accent); font-weight: 700; }
|
||||||
|
/* compact settings: two columns of label + control */
|
||||||
|
.set2 { display: grid; grid-template-columns: 96px 1fr 96px 1fr; gap: 7px 12px; align-items: center; text-align: left; min-width: 680px; }
|
||||||
|
.set2 .sl, .setacc .sl { font-size: 13px; color: var(--dim); }
|
||||||
|
.set2 .seg button { padding: 6px 4px; font-size: 12px; min-height: 34px; }
|
||||||
|
.set2 input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
|
||||||
|
.setacc { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; text-align: left; margin-top: 12px;
|
||||||
|
padding-top: 10px; border-top: 1px solid var(--line); }
|
||||||
|
.setacc .who { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||||
|
|
||||||
/* league */
|
/* league */
|
||||||
.opps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
|
.opps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
|
||||||
@@ -114,14 +183,24 @@
|
|||||||
.res .plus { color: var(--good); } .res .minus { color: var(--warn); }
|
.res .plus { color: var(--good); } .res .minus { color: var(--warn); }
|
||||||
|
|
||||||
/* shop */
|
/* shop */
|
||||||
#shop { position: absolute; inset: 0; display: grid; grid-template-columns: 340px 1fr; z-index: 3; pointer-events: none; }
|
#shop { position: absolute; inset: 44px 0 0; display: grid; grid-template-columns: 340px 1fr; z-index: 3; pointer-events: none; }
|
||||||
#shop.hide, #fightHud.hide { display: none; }
|
#shop.hide, #fightHud.hide { display: none; }
|
||||||
#shop > * { pointer-events: auto; }
|
#shop > * { pointer-events: auto; }
|
||||||
#sLeft { display: flex; flex-direction: column; padding: 12px; gap: 8px; pointer-events: none; }
|
#sLeft { display: flex; flex-direction: column; padding: 12px; gap: 8px; pointer-events: none; }
|
||||||
#sLeft > * { pointer-events: auto; }
|
#sLeft > * { pointer-events: auto; }
|
||||||
#rname { width: 100%; font: 24px var(--head); letter-spacing: .04em; background: transparent; border: 1px solid transparent;
|
/* hangar: robot slots at the top of the shop */
|
||||||
border-radius: 6px; color: var(--text); padding: 2px 6px; text-shadow: 0 2px 6px #000; }
|
.hangar { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 4px; }
|
||||||
#rname:hover, #rname:focus { border-color: var(--line); outline: none; background: rgba(11,14,20,.8); }
|
.hslot { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; font-size: 12px; max-width: 120px; }
|
||||||
|
.hslot .hn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
.hslot.on { background: var(--accent); color: #1a0c02; border-color: var(--accent); font-weight: 700; }
|
||||||
|
.hslot .hdel { font-size: 11px; opacity: .7; padding: 0 2px; border-radius: 4px; }
|
||||||
|
.hslot .hdel:hover { background: rgba(0,0,0,.25); opacity: 1; }
|
||||||
|
.hadd { padding: 4px 11px; font-size: 15px; font-weight: 700; color: var(--accent); }
|
||||||
|
/* name plate riveted to the robot, always readable (not only on hover) */
|
||||||
|
#rname { width: 100%; font: 24px var(--head); letter-spacing: .04em; background: rgba(11,14,20,.82);
|
||||||
|
border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r2);
|
||||||
|
color: var(--text); padding: 4px 10px; text-shadow: 0 2px 6px #000; box-shadow: var(--hl); }
|
||||||
|
#rname:hover, #rname:focus { border-color: var(--accent); outline: none; }
|
||||||
.mech { display: flex; gap: 8px; align-items: flex-end; }
|
.mech { display: flex; gap: 8px; align-items: flex-end; }
|
||||||
.mech .pic { width: 50px; height: 60px; font-size: 34px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
|
.mech .pic { width: 50px; height: 60px; font-size: 34px; border-radius: 8px; overflow: hidden; background: rgba(0,0,0,.35); border: 1px solid var(--line); }
|
||||||
.mech .bubble { background: rgba(250,246,238,.95); color: #1b1d22; border-radius: 10px 10px 10px 2px; padding: 5px 8px; font-size: 12px; max-width: 262px; box-shadow: 0 4px 14px #0008; }
|
.mech .bubble { background: rgba(250,246,238,.95); color: #1b1d22; border-radius: 10px 10px 10px 2px; padding: 5px 8px; font-size: 12px; max-width: 262px; box-shadow: 0 4px 14px #0008; }
|
||||||
@@ -140,37 +219,100 @@
|
|||||||
.paint span.sw.on { border-color: #fff; }
|
.paint span.sw.on { border-color: #fff; }
|
||||||
.paint .lb { width: 46px; }
|
.paint .lb { width: 46px; }
|
||||||
#sRight { background: rgba(14,16,22,.9); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 10px 12px; gap: 8px; min-height: 0; }
|
#sRight { background: rgba(14,16,22,.9); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 10px 12px; gap: 8px; min-height: 0; }
|
||||||
.tabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
|
#buildView { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
|
||||||
.tab { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 11px; cursor: pointer; }
|
#buildView.hide, #paintView.hide, #hangarView.hide { display: none; }
|
||||||
.tab .pic { width: 34px; height: 34px; font-size: 26px; }
|
#paintView, #hangarView { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
|
||||||
.tab:hover { border-color: var(--accent); }
|
/* top mode tabs (Parts / Paint / Hangar) */
|
||||||
.tab.on { background: linear-gradient(#3a2414, #241710); border-color: var(--accent); color: var(--accent); font-weight: 700; }
|
.shoptabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
|
||||||
|
.shoptabs button { padding: 6px 4px; font: 12.5px var(--head); letter-spacing: .03em; }
|
||||||
|
.shoptabs button.on { background: var(--accent); color: #1a0c02; border-color: var(--accent); }
|
||||||
|
/* zoom bar under the preview */
|
||||||
|
.zoombar { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 12px; color: var(--dim); margin-bottom: 2px; }
|
||||||
|
.zoombar button { width: 30px; height: 26px; padding: 0; font-size: 16px; font-weight: 700; }
|
||||||
|
/* fitted parts strip (bottom of the parts view): 7 compact chips, does not cover the robot preview */
|
||||||
|
.fittedwrap { border-top: 1px solid var(--line); padding-top: 5px; }
|
||||||
|
.flabel { font: 10.5px var(--head); letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
|
||||||
|
.fitted { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
|
||||||
|
.fitted .frow { display: flex; flex-direction: column; align-items: center; gap: 1px; background: rgba(8,10,14,.75);
|
||||||
|
border: 1px solid #262c36; border-radius: var(--r1); padding: 3px 3px 2px; font-size: 11.5px; cursor: pointer;
|
||||||
|
position: relative; min-width: 0; box-shadow: none; }
|
||||||
|
@media (hover: hover) { .fitted .frow:hover { border-color: var(--accent); } }
|
||||||
|
.fitted .frow .pic { width: 18px; height: 18px; font-size: 14px; }
|
||||||
|
.fitted .frow .fn { width: 100%; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
.fitted .frow .fn.empty { color: var(--dim); }
|
||||||
|
.fitted .frow .frm { position: absolute; top: -5px; right: -4px; font-size: 11px; color: #fff; background: var(--warn);
|
||||||
|
width: 15px; height: 15px; border-radius: 50%; display: flex; align-items: center; justify-content: center; line-height: 1; }
|
||||||
|
/* hangar management (top-tab Hangar) */
|
||||||
|
.hmgr { display: flex; flex-direction: column; gap: 6px; }
|
||||||
|
.hmrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; background: var(--panel2);
|
||||||
|
border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
|
||||||
|
.hmrow.on { border-color: var(--accent); background: #2a1c10; }
|
||||||
|
.hmrow .hmn { font: 15px var(--head); letter-spacing: .02em; }
|
||||||
|
.hmrow .hmw { font-size: 12px; color: var(--dim); }
|
||||||
|
/* category tabs: a strip of folder tabs sitting ON the card panel - clearly navigation, not parts */
|
||||||
|
.tabs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; border-bottom: 2px solid var(--line); }
|
||||||
|
.tab { background: #141922; border: 1px solid var(--line); border-bottom: none;
|
||||||
|
border-radius: var(--r2) var(--r2) 0 0; margin-bottom: -2px; padding: 3px 2px 5px;
|
||||||
|
display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
|
||||||
|
font-size: 11.5px; letter-spacing: .02em; color: var(--dim); }
|
||||||
|
.tab .pic { width: 24px; height: 24px; font-size: 19px; }
|
||||||
|
@media (hover: hover) { .tab:hover { border-color: var(--accent); } }
|
||||||
|
.tab.on { background: linear-gradient(#3a2414, #1d1410); border-color: var(--accent); color: var(--accent);
|
||||||
|
font-weight: 700; border-bottom: 2px solid #1d1410; } /* open tab merges into the panel below */
|
||||||
.tab.miss { border-color: var(--warn); }
|
.tab.miss { border-color: var(--warn); }
|
||||||
#cards { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; align-content: start; padding: 2px; }
|
#cards { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
|
||||||
.item { background: linear-gradient(#20252f, #181c24); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 5px; cursor: pointer; text-align: center; position: relative; }
|
align-content: start; padding: 9px; background: rgba(0,0,0,.26); border: 1px solid var(--line); border-top: none;
|
||||||
.item:hover { border-color: #5a6478; }
|
border-radius: 0 0 var(--r2) var(--r2); }
|
||||||
|
.item { background: linear-gradient(#252b37, #171b23); border: 1px solid #39414f; border-radius: var(--r2);
|
||||||
|
padding: 5px 5px 4px; cursor: pointer; text-align: center; position: relative;
|
||||||
|
box-shadow: var(--hl), 0 2px 0 rgba(0,0,0,.45); }
|
||||||
|
@media (hover: hover) { .item:hover { border-color: #5a6478; } }
|
||||||
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,122,26,.3); }
|
.item.sel { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,122,26,.3); }
|
||||||
.item > .pic { width: 100%; height: 62px; font-size: 42px; }
|
.item > .pic { width: 100%; height: 52px; font-size: 38px; }
|
||||||
.item .nm { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
.item .nm { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
.item .pr { font-size: 12px; color: var(--gold); display: flex; gap: 3px; justify-content: center; align-items: center; font-variant-numeric: tabular-nums; }
|
.item .pr { font-size: 12px; color: var(--gold); display: flex; gap: 3px; justify-content: center; align-items: center;
|
||||||
|
font-variant-numeric: tabular-nums; background: rgba(0,0,0,.3); border-radius: var(--r1); padding: 0 4px; margin: 2px auto 0; width: fit-content; }
|
||||||
.item .pr .pic { width: 14px; height: 14px; }
|
.item .pr .pic { width: 14px; height: 14px; }
|
||||||
.item .pr.no { color: var(--warn); }
|
.item .pr.no { color: var(--warn); }
|
||||||
.item .badge { position: absolute; top: 5px; left: 5px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--accent); color: #1a0c02; }
|
.item .badge { position: absolute; top: 5px; left: 5px; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--accent); color: #1a0c02; }
|
||||||
.item .badge.own { background: #3c4556; color: var(--text); }
|
.item .badge.own { background: #3c4556; color: var(--text); }
|
||||||
#detail { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; align-items: center; min-height: 110px; }
|
#detail { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 76px 1fr auto; gap: 10px; align-items: center; min-height: 86px; }
|
||||||
#detail > .pic { width: 92px; height: 92px; font-size: 60px; }
|
#detail > .pic { width: 76px; height: 76px; font-size: 52px; }
|
||||||
#detail .nm { font: 17px var(--head); letter-spacing: .03em; }
|
#detail .nm { font: 17px var(--head); letter-spacing: .03em; }
|
||||||
#detail .ds { font-size: 12.5px; color: var(--dim); margin: 2px 0 5px; }
|
#detail .ds { font-size: 12.5px; color: var(--dim); margin: 2px 0 5px; }
|
||||||
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
|
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||||
.chips span { background: #0f1218; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 11.5px; display: inline-flex; gap: 3px; align-items: center; font-variant-numeric: tabular-nums; }
|
.chips span { background: #0f1218; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: 11.5px; display: inline-flex; gap: 3px; align-items: center; font-variant-numeric: tabular-nums; }
|
||||||
.chips span .pic { width: 13px; height: 13px; font-size: 11px; }
|
.chips span .pic { width: 13px; height: 13px; font-size: 11px; }
|
||||||
.chips span.up { color: var(--good); border-color: #2e5a3e; } .chips span.down { color: var(--warn); border-color: #5a2e2e; }
|
.chips span.up { color: var(--good); border-color: #2e5a3e; } .chips span.down { color: var(--warn); border-color: #5a2e2e; }
|
||||||
|
.chips span.key { color: var(--accent); border-color: #5a3a18; background: #1d1409; font-weight: 700; }
|
||||||
#detail .act { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
|
#detail .act { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
|
||||||
#detail .act button { padding: 8px 10px; }
|
#detail .act button { padding: 8px 10px; min-height: 40px; }
|
||||||
|
#detail .act .primary { min-height: 44px; font-size: 15px; }
|
||||||
.gbar { display: flex; gap: 6px; align-items: center; }
|
.gbar { display: flex; gap: 6px; align-items: center; }
|
||||||
.gbar .err { flex: 1; margin: 0; font-size: 12px; text-align: left; }
|
.gbar .err { flex: 1; margin: 0; font-size: 12px; text-align: left; }
|
||||||
.gbar .primary { padding: 9px 26px; }
|
.gbar .primary { padding: 9px 26px; }
|
||||||
|
|
||||||
|
/* paint tab: proper colour chips instead of tiny dots */
|
||||||
|
#paintView { gap: 10px; }
|
||||||
|
.psec h4 { margin: 0 0 6px; font: 12px var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
|
||||||
|
.pgrid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 7px; }
|
||||||
|
.pgrid.wide { grid-template-columns: repeat(8, 1fr); }
|
||||||
|
.pgrid .sw { position: relative; height: 40px; border-radius: var(--r2); border: 2px solid #000a;
|
||||||
|
cursor: pointer; box-shadow: var(--hl), 0 2px 0 rgba(0,0,0,.4); transition: transform .1s; }
|
||||||
|
@media (hover: hover) { .pgrid .sw:hover { transform: translateY(-2px); } }
|
||||||
|
.pgrid .sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
|
||||||
|
.pgrid .sw.on::after { content: '✓'; position: absolute; inset: 0; display: flex; align-items: center;
|
||||||
|
justify-content: center; color: #fff; font-size: 19px; font-weight: 700; text-shadow: 0 1px 3px #000; }
|
||||||
|
.pgrid .duo { display: flex; overflow: hidden; }
|
||||||
|
.pgrid .duo i { flex: 1; }
|
||||||
|
.pcustom { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
|
||||||
|
background: var(--panel2); background-image: var(--sheen); border: 1px solid var(--line);
|
||||||
|
border-left: 3px solid var(--accent); border-radius: var(--r3); padding: 12px 14px; box-shadow: var(--hl); }
|
||||||
|
.pcustom .pct { display: flex; flex-direction: column; gap: 3px; text-align: left; }
|
||||||
|
.pcustom .pct b { font: 16px var(--head); letter-spacing: .03em; }
|
||||||
|
.pcustom .pct .muted { font-size: 12.5px; }
|
||||||
|
.pcustom .primary { font-size: 22px; padding: 10px 22px; }
|
||||||
|
|
||||||
/* paint booth (painter.js) */
|
/* paint booth (painter.js) */
|
||||||
#painter { grid-column: 2; grid-row: 1; background: rgba(14,16,22,.94); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 10px 12px; gap: 7px; }
|
#painter { grid-column: 2; grid-row: 1; background: rgba(14,16,22,.94); border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 10px 12px; gap: 7px; }
|
||||||
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
||||||
@@ -196,32 +338,141 @@
|
|||||||
.pt-colors input[type=color] { width: 34px; height: 26px; border: none; background: none; padding: 0; cursor: pointer; }
|
.pt-colors input[type=color] { width: 34px; height: 26px; border: none; background: none; padding: 0; cursor: pointer; }
|
||||||
#bPaint { align-self: flex-start; }
|
#bPaint { align-self: flex-start; }
|
||||||
|
|
||||||
|
/* lobby (touch-friendly: big rows + buttons) */
|
||||||
|
.lobbybar { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; flex-wrap: wrap; }
|
||||||
|
.flags { display: flex; gap: 4px; flex-wrap: wrap; }
|
||||||
|
.flag { padding: 5px 6px; line-height: 0; }
|
||||||
|
/* flags drawn with CSS (no flag emoji on Windows) */
|
||||||
|
.fl { display: inline-block; width: 30px; height: 20px; border-radius: 3px; vertical-align: middle; box-shadow: 0 0 0 1px rgba(255,255,255,.25); background: #555; }
|
||||||
|
.fl-DE { background: linear-gradient(#000 33.3%, #dd0000 33.3% 66.6%, #ffce00 66.6%); }
|
||||||
|
.fl-AT { background: linear-gradient(#c8102e 33.3%, #fff 33.3% 66.6%, #c8102e 66.6%); }
|
||||||
|
.fl-CH { background: linear-gradient(#fff, #fff) center / 56% 20% no-repeat, linear-gradient(#fff, #fff) center / 20% 56% no-repeat, #d52b1e; }
|
||||||
|
.fl-GB { background: linear-gradient(#c8102e, #c8102e) center / 100% 18% no-repeat, linear-gradient(#c8102e, #c8102e) center / 12% 100% no-repeat,
|
||||||
|
linear-gradient(#fff, #fff) center / 100% 34% no-repeat, linear-gradient(#fff, #fff) center / 22% 100% no-repeat, #012169; }
|
||||||
|
.fl-US { background: linear-gradient(#3c3b6e, #3c3b6e) left top / 42% 54% no-repeat, repeating-linear-gradient(#b22234 0 15.4%, #fff 15.4% 30.8%); }
|
||||||
|
.fl-FR { background: linear-gradient(90deg, #0055a4 33.3%, #fff 33.3% 66.6%, #ef4135 66.6%); }
|
||||||
|
.fl-ES { background: linear-gradient(#aa151b 25%, #f1bf00 25% 75%, #aa151b 75%); }
|
||||||
|
.fl-IT { background: linear-gradient(90deg, #009246 33.3%, #fff 33.3% 66.6%, #ce2b37 66.6%); }
|
||||||
|
.fl-NL { background: linear-gradient(#ae1c28 33.3%, #fff 33.3% 66.6%, #21468b 66.6%); }
|
||||||
|
.fl-PL { background: linear-gradient(#fff 50%, #dc143c 50%); }
|
||||||
|
.fl-TR { background: radial-gradient(circle at 42% 50%, #fff 0 20%, transparent 21%), #e30a17; }
|
||||||
|
.fl-RU { background: linear-gradient(#fff 33.3%, #0039a6 33.3% 66.6%, #d52b1e 66.6%); }
|
||||||
|
.fl-BR { background: radial-gradient(circle, #002776 0 22%, #fedf00 23% 46%, transparent 47%), #009b3a; }
|
||||||
|
.fl-JP { background: radial-gradient(circle, #bc002d 0 30%, transparent 31%), #fff; }
|
||||||
|
.fl-KR { background: radial-gradient(circle, #cd2e3a 0 14%, #0047a0 15% 28%, transparent 29%), #fff; }
|
||||||
|
.fl-XX { background: repeating-linear-gradient(45deg, #5a6272 0 5px, #454c5a 5px 10px); }
|
||||||
|
.flag.on { background: var(--accent); border-color: var(--accent); }
|
||||||
|
/* two-pane lobby: country rooms left, player list right (own style) */
|
||||||
|
.lobbyfull { display: grid; grid-template-columns: 318px 1fr; gap: 12px; width: 1040px; height: 560px;
|
||||||
|
background: rgba(21, 25, 32, .95); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 20px 60px #000a; }
|
||||||
|
.lobbyL, .lobbyR { display: flex; flex-direction: column; min-height: 0; }
|
||||||
|
.lobbyLh { font: 15px var(--head); letter-spacing: .05em; color: var(--accent); margin-bottom: 8px; }
|
||||||
|
.roomlist { flex: 1; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; align-content: start; padding-right: 2px; }
|
||||||
|
.roomlist .rroom:first-child { grid-column: 1 / -1; }
|
||||||
|
.rroom { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; padding: 5px 8px; text-align: left; font-size: 12.5px; background: var(--panel2); }
|
||||||
|
.rroom .rfl { line-height: 0; } .rroom .rfl .fl { width: 22px; height: 14px; }
|
||||||
|
.rroom .rn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
.rroom .cnt { font-variant-numeric: tabular-nums; color: var(--dim); font-size: 12px; min-width: 16px; text-align: right; }
|
||||||
|
.rroom .cnt.live { color: var(--good); font-weight: 700; }
|
||||||
|
.rroom.on { background: var(--accent); color: #1a0c02; border-color: var(--accent); font-weight: 700; }
|
||||||
|
.rroom.on .cnt { color: #1a0c02; }
|
||||||
|
.lobbyRh { display: flex; align-items: center; gap: 8px; font: 18px var(--head); letter-spacing: .03em; margin-bottom: 8px; }
|
||||||
|
.lobbyRh .grow { flex: 1; }
|
||||||
|
.lobbyRh .flagpick { font: 12px "Segoe UI", sans-serif; color: var(--dim); display: flex; gap: 6px; align-items: center; }
|
||||||
|
.lobbyRh select { font: inherit; font-size: 13px; color: var(--text); background: #0b0e14; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; cursor: pointer; }
|
||||||
|
.lobbyR .plist { flex: 1; max-height: none; }
|
||||||
|
.plist { max-height: 316px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin: 4px 0; min-width: 440px; }
|
||||||
|
.prow { display: grid; grid-template-columns: 28px 1fr auto auto; gap: 9px; align-items: center;
|
||||||
|
background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; }
|
||||||
|
.prow .pf { line-height: 0; } .prow .pn { font-size: 13px; font-weight: 700; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
|
.prow .pfame { color: var(--gold); font-size: 12.5px; font-variant-numeric: tabular-nums; }
|
||||||
|
.prow .chal { padding: 5px 14px; font-size: 13px; background: var(--accent); color: #1a0c02; border-color: var(--accent); font-weight: 700; }
|
||||||
|
.prow .pbusy { color: var(--dim); font-size: 12px; padding: 5px 8px; }
|
||||||
|
.prow.me { border-color: var(--accent); background: #2a1c10; }
|
||||||
|
.prow .pf .fl { width: 26px; height: 17px; }
|
||||||
|
|
||||||
/* fight HUD */
|
/* fight HUD */
|
||||||
#fightHud { position: absolute; left: 0; right: 0; top: 0; padding: 10px 14px; display: grid; grid-template-columns: 1fr 150px 1fr;
|
#fightHud { position: absolute; left: 0; right: 0; top: 0; padding: 10px 14px; display: grid; grid-template-columns: 1fr 150px 1fr;
|
||||||
gap: 12px; pointer-events: none; z-index: 4; }
|
gap: 12px; pointer-events: none; z-index: 4; }
|
||||||
.fbox { background: rgba(10, 12, 16, .78); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
|
.fbox { background: rgba(10, 12, 16, .78); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
|
||||||
.fbox .fn { font: 16px var(--head); letter-spacing: .04em; display: flex; justify-content: space-between; }
|
.fbox .fn { font: 16px var(--head); letter-spacing: .04em; display: flex; justify-content: space-between; }
|
||||||
.fbox .fn small { font: 12px "Segoe UI", sans-serif; color: var(--dim); }
|
.fbox .fn small { font: 12px "Segoe UI", sans-serif; color: var(--dim); }
|
||||||
.hp { height: 12px; background: #0b0e14; border-radius: 6px; overflow: hidden; margin-top: 4px; border: 1px solid #000; }
|
.fsub { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--dim);
|
||||||
.hp i { display: block; height: 100%; transition: width .15s; }
|
font-variant-numeric: tabular-nums; min-height: 15px; }
|
||||||
|
#fRight .fsub { flex-direction: row-reverse; }
|
||||||
|
.fsub .lost { color: var(--warn); font-weight: 700; }
|
||||||
|
.fsub .hpn { font-weight: 700; color: var(--text); }
|
||||||
|
.fsub .pts { display: flex; gap: 5px; }
|
||||||
|
.fsub .pt { position: relative; line-height: 0; }
|
||||||
|
.fsub .pt .pic { width: 17px; height: 17px; font-size: 13px; }
|
||||||
|
.fsub .pt.gone { opacity: .45; }
|
||||||
|
.fsub .pt.gone::after { content: '✕'; position: absolute; inset: 0; display: flex; align-items: center;
|
||||||
|
justify-content: center; color: var(--warn); font-size: 15px; font-weight: 700; line-height: 1; }
|
||||||
|
.hp { position: relative; height: 16px; background: #0b0e14; border-radius: 3px; overflow: hidden;
|
||||||
|
margin-top: 5px; border: 1px solid #000; transform: skewX(-12deg); }
|
||||||
|
.hp i { position: absolute; left: 0; top: 0; bottom: 0; transition: width .15s; }
|
||||||
|
.hp i.g { background: #8d2018; transition: width .55s ease .2s; } /* damage trail */
|
||||||
|
.hp::after { content: ''; position: absolute; inset: 0; pointer-events: none;
|
||||||
|
background: repeating-linear-gradient(90deg, transparent 0 17px, rgba(0,0,0,.55) 17px 19px); }
|
||||||
|
.fbox.hurt { border-color: var(--warn); animation: lowhp 1s infinite; }
|
||||||
|
@keyframes lowhp { 50% { border-color: var(--line); } }
|
||||||
|
.fbox.hit { background-color: rgba(255,90,74,.3); }
|
||||||
#fRight { text-align: right; } #fRight .fn { flex-direction: row-reverse; }
|
#fRight { text-align: right; } #fRight .fn { flex-direction: row-reverse; }
|
||||||
#fMid { text-align: center; }
|
#fMid { text-align: center; }
|
||||||
#fTime { font: 34px var(--head); line-height: 1; letter-spacing: .04em; }
|
#fTime { font: 34px var(--head); line-height: 1; letter-spacing: .04em; }
|
||||||
#fTime.low { color: var(--warn); }
|
#fTime.low { color: var(--warn); animation: tick 1s steps(2) infinite; }
|
||||||
|
@keyframes tick { 50% { opacity: .45; } }
|
||||||
#fState { font-size: 12px; color: var(--accent); min-height: 16px; font-weight: 700; letter-spacing: .05em; }
|
#fState { font-size: 12px; color: var(--accent); min-height: 16px; font-weight: 700; letter-spacing: .05em; }
|
||||||
|
|
||||||
|
/* cooldown chips: ring empties while the part recharges */
|
||||||
|
#fCds { position: absolute; left: 50%; transform: translateX(-50%); bottom: 58px; z-index: 4; display: none;
|
||||||
|
gap: 14px; pointer-events: none; }
|
||||||
|
body[data-mode="fight"] #fCds, body[data-mode="pause"] #fCds { display: flex; }
|
||||||
|
.cdchip { --p: 0; position: relative; width: 52px; height: 52px; border-radius: 50%; padding: 3px;
|
||||||
|
background: conic-gradient(#2b3240 calc(var(--p) * 360deg), var(--accent) 0); }
|
||||||
|
.cdchip .in { width: 100%; height: 100%; border-radius: 50%; background: #0d1016; border: 1px solid #000;
|
||||||
|
display: flex; align-items: center; justify-content: center; }
|
||||||
|
.cdchip .pic { width: 32px; height: 32px; font-size: 22px; }
|
||||||
|
.cdchip.on { box-shadow: 0 0 0 2px var(--accent); }
|
||||||
|
.cdchip.spent { opacity: .45; }
|
||||||
|
.cdchip.broke { background: #3a2020; opacity: .8; }
|
||||||
|
.cdchip.broke .in { border-color: var(--warn); }
|
||||||
|
.cdchip.broke::after { content: '✕'; position: absolute; inset: 0; display: flex; align-items: center;
|
||||||
|
justify-content: center; color: var(--warn); font-size: 30px; font-weight: 700; text-shadow: 0 2px 4px #000; }
|
||||||
|
.cdchip .k { position: absolute; left: 0; right: 0; bottom: -15px; text-align: center; font-size: 11px;
|
||||||
|
color: var(--dim); font-weight: 700; }
|
||||||
|
.cdchip .n { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; border-radius: 9px;
|
||||||
|
background: var(--accent); color: #1a0c02; font-size: 11px; font-weight: 700; line-height: 17px; text-align: center; }
|
||||||
|
/* on touch the pad owns the bottom edge, so the chips move above it */
|
||||||
|
@media (pointer: coarse) { .cdchip .k { display: none; } #fCds { bottom: 110px; } }
|
||||||
|
body.forcetouch #fCds { bottom: 110px; }
|
||||||
|
|
||||||
|
/* own damage: the screen edge glows red the closer you are to being wrecked */
|
||||||
|
#dmgvig { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .25s;
|
||||||
|
background: radial-gradient(ellipse at 50% 50%, transparent 45%, rgba(190,20,10,.75) 100%); }
|
||||||
|
|
||||||
/* touch pad: only on touch screens */
|
/* touch pad: only on touch screens */
|
||||||
#pad { position: absolute; left: 14px; right: 14px; bottom: 14px; display: none; justify-content: space-between; pointer-events: none; z-index: 5; }
|
#pad { position: absolute; left: 14px; right: 14px; bottom: 14px; display: none; justify-content: space-between; pointer-events: none; z-index: 5; }
|
||||||
#pad > div { display: grid; grid-template-columns: repeat(3, 60px); gap: 6px; pointer-events: auto; }
|
#pad > div { display: grid; grid-template-columns: repeat(3, 60px); gap: 6px; pointer-events: auto; }
|
||||||
#pad button { height: 60px; font-size: 20px; opacity: .7; padding: 0; }
|
#pad button { height: 60px; font-size: 20px; opacity: .75; padding: 0; border-radius: var(--r3);
|
||||||
#pad .fire { grid-template-columns: repeat(2, 74px); }
|
background: rgba(18,22,30,.72); }
|
||||||
#pad .fire button { height: 74px; font-size: 14px; font-weight: 700; }
|
#pad .fire { grid-template-columns: repeat(3, 74px); }
|
||||||
|
#pad .fire button { height: 74px; font-size: 13px; font-weight: 700; border-radius: 50%; }
|
||||||
|
#padGadget { --p: 0; background:
|
||||||
|
conic-gradient(rgba(18,22,30,.72) calc(var(--p) * 360deg), rgba(255,122,26,.5) 0); }
|
||||||
@media (pointer: coarse) { body.fighting #pad { display: flex; } }
|
@media (pointer: coarse) { body.fighting #pad { display: flex; } }
|
||||||
|
body.forcetouch.fighting #pad { display: flex; } /* dev: &touch */
|
||||||
|
|
||||||
|
/* tablets / phones held upright: ask to rotate (the stage is 16:9) */
|
||||||
|
#rotate { display: none; position: fixed; left: 0; right: 0; bottom: 12%; text-align: center; z-index: 20; font: 20px var(--head); color: var(--accent); padding: 0 20px; }
|
||||||
|
@media (pointer: coarse) and (orientation: portrait) { #rotate { display: block; } }
|
||||||
|
|
||||||
/* window buttons: only inside the exe (html.exe set by kit-host.js) */
|
/* window buttons: only inside the exe (html.exe set by kit-host.js) */
|
||||||
#winctl { position: fixed; top: 8px; right: 8px; display: none; gap: 6px; z-index: 10; }
|
#winctl { position: fixed; top: 8px; right: 8px; display: none; gap: 6px; z-index: 10; }
|
||||||
html.exe #winctl { display: flex; }
|
html.exe #winctl { display: flex; }
|
||||||
#winctl button { width: 34px; height: 30px; padding: 0; opacity: .75; }
|
#winctl button { width: 34px; height: 30px; min-height: 30px; padding: 0; opacity: .75; }
|
||||||
|
html.exe #hud { padding-right: 130px; }
|
||||||
|
html.exe #fightHud { padding: 10px 130px 0; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -231,18 +482,8 @@
|
|||||||
<button onclick="Kit.host.quit()" data-i18n-title="win_close">✕</button>
|
<button onclick="Kit.host.quit()" data-i18n-title="win_close">✕</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="rotate">↻ <span data-i18n="rotate_hint">Turn your device sideways</span></div>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div id="hud">
|
|
||||||
<div class="logo">ROBOT CLASH</div>
|
|
||||||
<div class="chip" data-i18n-title="hud_money"><span class="pic" data-f="🪙" id="icoMoney"></span><b id="hMoney">0</b></div>
|
|
||||||
<div class="chip" data-i18n-title="hud_fame"><span class="pic" data-f="⭐" id="icoFame"></span><b id="hFame">0</b></div>
|
|
||||||
<div class="chip"><span data-i18n="hud_league">League</span> <b id="hLeague">-</b></div>
|
|
||||||
<div class="grow"></div>
|
|
||||||
<div class="chip" id="hUser" data-i18n-title="account"></div>
|
|
||||||
<button id="bSettings" data-i18n-title="settings">⚙</button>
|
|
||||||
<button id="bMute" title="M">Sound</button>
|
|
||||||
<button id="bPause" title="P / Esc" data-i18n="pause">Pause</button>
|
|
||||||
</div>
|
|
||||||
<div id="stage">
|
<div id="stage">
|
||||||
<div id="bgimg"></div>
|
<div id="bgimg"></div>
|
||||||
<canvas id="gl"></canvas>
|
<canvas id="gl"></canvas>
|
||||||
@@ -251,20 +492,34 @@
|
|||||||
<div id="shop" class="hide">
|
<div id="shop" class="hide">
|
||||||
<div id="sLeft">
|
<div id="sLeft">
|
||||||
<input id="rname" maxlength="18" spellcheck="false">
|
<input id="rname" maxlength="18" spellcheck="false">
|
||||||
<div class="mech"><span class="pic" data-f="🧔" id="mechPic"></span><div class="bubble" id="mechTip"></div></div>
|
<div class="zoombar"><button id="zOut" title="Zoom -">-</button><span data-i18n="zoom">Zoom</span><button id="zIn" title="Zoom +">+</button></div>
|
||||||
<div class="spacer"></div>
|
<div class="spacer"></div>
|
||||||
<div class="stats" id="meters"></div>
|
<div class="stats" id="meters"></div>
|
||||||
<div class="paint" id="paintBody"></div>
|
<div class="mech"><span class="pic" data-f="🧔" id="mechPic"></span><div class="bubble" id="mechTip"></div></div>
|
||||||
<div class="paint" id="paintAccent"></div>
|
|
||||||
<button id="bPaint" data-i18n="pt_open">🎨 Paint it yourself</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div id="sRight">
|
<div id="sRight">
|
||||||
<div class="tabs" id="tabs"></div>
|
<div class="shoptabs" id="shopTabs"></div>
|
||||||
<div id="cards"></div>
|
<div id="buildView">
|
||||||
<div id="detail"></div>
|
<div class="tabs" id="tabs"></div>
|
||||||
|
<div id="cards"></div>
|
||||||
|
<div id="detail"></div>
|
||||||
|
<div class="fittedwrap"><div class="flabel" data-i18n="fitted_parts">Fitted</div><div id="fitted" class="fitted"></div></div>
|
||||||
|
</div>
|
||||||
|
<div id="paintView" class="hide">
|
||||||
|
<div class="psec"><h4 data-i18n="paint_body">Body</h4><div class="pgrid" id="paintBody"></div></div>
|
||||||
|
<div class="psec"><h4 data-i18n="paint_accent">Accent</h4><div class="pgrid" id="paintAccent"></div></div>
|
||||||
|
<div class="psec"><h4 data-i18n="paint_schemes">Schemes</h4><div class="pgrid wide" id="paintSchemes"></div></div>
|
||||||
|
<div class="spacer"></div>
|
||||||
|
<div class="pcustom">
|
||||||
|
<div class="pct"><b data-i18n="pt_open">Paint it yourself</b><span class="muted" data-i18n="paint_hint">Pick quick colours above, or paint your own design.</span></div>
|
||||||
|
<button id="bPaint" class="primary">🎨</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="hangarView" class="hide"></div>
|
||||||
<div class="gbar">
|
<div class="gbar">
|
||||||
<div class="err" id="gErr"></div>
|
<div class="err" id="gErr"></div>
|
||||||
<button id="bGMenu" data-i18n="menu">Menu</button>
|
<button id="bGMenu" data-i18n="menu">Menu</button>
|
||||||
|
<button id="bGOnline" data-i18n="online_short">Online</button>
|
||||||
<button id="bTrain" data-i18n="training">Training</button>
|
<button id="bTrain" data-i18n="training">Training</button>
|
||||||
<button class="primary" id="bLeague" data-i18n="to_league">League</button>
|
<button class="primary" id="bLeague" data-i18n="to_league">League</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -272,20 +527,34 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="fightHud" class="hide">
|
<div id="fightHud" class="hide">
|
||||||
<div class="fbox" id="fLeft"><div class="fn"><span id="fN0"></span><small id="fW0"></small></div><div class="hp"><i id="fH0"></i></div></div>
|
<div class="fbox" id="fLeft"><div class="fn"><span id="fN0"></span><small id="fW0"></small></div><div class="hp"><i class="g" id="fG0"></i><i id="fH0"></i></div><div class="fsub" id="fD0"></div></div>
|
||||||
<div class="fbox" id="fMid"><div id="fTime">2:00</div><div id="fState"></div></div>
|
<div class="fbox" id="fMid"><div id="fTime">2:00</div><div id="fState"></div></div>
|
||||||
<div class="fbox" id="fRight"><div class="fn"><span id="fN1"></span><small id="fW1"></small></div><div class="hp"><i id="fH1"></i></div></div>
|
<div class="fbox" id="fRight"><div class="fn"><span id="fN1"></span><small id="fW1"></small></div><div class="hp"><i class="g" id="fG1"></i><i id="fH1"></i></div><div class="fsub" id="fD1"></div></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="dmgvig"></div>
|
||||||
|
<div id="fCds"></div>
|
||||||
|
|
||||||
<div id="pad">
|
<div id="pad">
|
||||||
<div>
|
<div>
|
||||||
<span></span><button data-action="up">▲</button><span></span>
|
<span></span><button data-action="up">▲</button><span></span>
|
||||||
<button data-action="left">◀</button><button data-action="down">▼</button><button data-action="right">▶</button>
|
<button data-action="left">◀</button><button data-action="down">▼</button><button data-action="right">▶</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="fire">
|
<div class="fire">
|
||||||
<button data-action="fire2" data-i18n="pad_tower">Tower</button><button data-action="fire" data-i18n="pad_weapon">Weapon</button>
|
<button data-action="fire3" data-i18n="pad_gadget" id="padGadget">Gadget</button><button data-action="fire2" data-i18n="pad_tower">Tower</button><button data-action="fire" data-i18n="pad_weapon">Weapon</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="hud">
|
||||||
|
<div class="logo">ROBOT CLASH</div>
|
||||||
|
<div class="chip" data-i18n-title="hud_money"><span class="pic" data-f="🪙" id="icoMoney"></span><b id="hMoney">0</b></div>
|
||||||
|
<div class="chip" data-i18n-title="hud_fame"><span class="pic" data-f="⭐" id="icoFame"></span><b id="hFame">0</b></div>
|
||||||
|
<div class="chip"><span data-i18n="hud_league">League</span> <b id="hLeague">-</b></div>
|
||||||
|
<div class="grow"></div>
|
||||||
|
<div class="chip" id="hUser" data-i18n-title="account"></div>
|
||||||
|
<button id="bSettings" class="icobtn" data-i18n-title="settings">⚙</button>
|
||||||
|
<button id="bMute" class="icobtn" title="M">🔊</button>
|
||||||
|
<button id="bPause" class="icobtn" title="P / Esc" data-i18n-title="pause">⏸</button>
|
||||||
|
</div>
|
||||||
<div id="overlay" class="hide"></div>
|
<div id="overlay" class="hide"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -305,9 +574,14 @@
|
|||||||
<script src="combat.js"></script>
|
<script src="combat.js"></script>
|
||||||
<script src="ai.js"></script>
|
<script src="ai.js"></script>
|
||||||
<script src="profiles.js"></script>
|
<script src="profiles.js"></script>
|
||||||
|
<script src="net.js"></script>
|
||||||
|
<script src="lobby.js"></script>
|
||||||
|
<script src="looks.js"></script>
|
||||||
<script src="render3d.js"></script>
|
<script src="render3d.js"></script>
|
||||||
|
<script src="netfight.js"></script>
|
||||||
<script src="shop.js"></script>
|
<script src="shop.js"></script>
|
||||||
<script src="painter.js"></script>
|
<script src="painter.js"></script>
|
||||||
|
<script src="uicheck.js"></script>
|
||||||
<script src="game.js"></script>
|
<script src="game.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
const scores = Kit.scores({ url: 'https://<project>-default-rtdb.europe-west1.firebasedatabase.app' });
|
const scores = Kit.scores({ url: 'https://<project>-default-rtdb.europe-west1.firebasedatabase.app' });
|
||||||
if (scores.enabled) {
|
if (scores.enabled) {
|
||||||
const rows = await scores.top(10); // [{ key, name, score, level, time }] best first
|
const rows = await scores.top(10); // [{ key, name, score, level, time }] best first,
|
||||||
|
// one row per player (their best run)
|
||||||
const key = await scores.submit({ name, score, level }); // key of the new entry or null
|
const key = await scores.submit({ name, score, level }); // key of the new entry or null
|
||||||
}
|
}
|
||||||
Kit.cleanName(s) -> trimmed, max 20 chars, no control chars / angle brackets
|
Kit.cleanName(s) -> trimmed, max 20 chars, no control chars / angle brackets
|
||||||
@@ -36,16 +37,22 @@
|
|||||||
enabled,
|
enabled,
|
||||||
async top(n = 10) {
|
async top(n = 10) {
|
||||||
if (!enabled) return [];
|
if (!enabled) return [];
|
||||||
// fetch spare rows: filtered names must not leave the list short
|
// fetch spare rows: filtered names and repeat entries by the same player must not leave the list short
|
||||||
const q = new URLSearchParams({ orderBy: '"score"', limitToLast: String(n + 15) });
|
const q = new URLSearchParams({ orderBy: '"score"', limitToLast: String(n * 4 + 25) });
|
||||||
const res = await fetch(`${url}/${path}.json?${q}`, { cache: 'no-store' });
|
const res = await fetch(`${url}/${path}.json?${q}`, { cache: 'no-store' });
|
||||||
if (!res.ok) throw new Error('scores ' + res.status);
|
if (!res.ok) throw new Error('scores ' + res.status);
|
||||||
const data = (await res.json()) || {};
|
const data = (await res.json()) || {};
|
||||||
return Object.entries(data)
|
const rows = Object.entries(data)
|
||||||
.map(([key, v]) => Object.assign({ key }, v))
|
.map(([key, v]) => Object.assign({ key }, v))
|
||||||
.filter(v => typeof v.name === 'string' && typeof v.score === 'number' && !Kit.badName(v.name))
|
.filter(v => typeof v.name === 'string' && typeof v.score === 'number' && !Kit.badName(v.name))
|
||||||
.sort((a, b) => b.score - a.score || (a.time || 0) - (b.time || 0))
|
.sort((a, b) => b.score - a.score || (a.time || 0) - (b.time || 0));
|
||||||
.slice(0, n);
|
// every player appears once, with their best run (each submit writes its own row)
|
||||||
|
const best = new Map();
|
||||||
|
for (const r of rows) {
|
||||||
|
const who = r.name.trim().toLowerCase();
|
||||||
|
if (!best.has(who)) best.set(who, r);
|
||||||
|
}
|
||||||
|
return Array.from(best.values()).slice(0, n);
|
||||||
},
|
},
|
||||||
async submit({ name, score, level = 1 }) {
|
async submit({ name, score, level = 1 }) {
|
||||||
name = Kit.cleanName(name);
|
name = Kit.cleanName(name);
|
||||||
|
|||||||
200
game/lang.js
@@ -17,7 +17,7 @@ window.LANG = {
|
|||||||
reset_text: 'Delete your robot, credits and league progress and start again?',
|
reset_text: 'Delete your robot, credits and league progress and start again?',
|
||||||
reset_yes: 'Yes, start over', cancel: 'Cancel', ok: 'OK', back: 'Back', menu: 'Menu',
|
reset_yes: 'Yes, start over', cancel: 'Cancel', ok: 'OK', back: 'Back', menu: 'Menu',
|
||||||
help_text: 'In the <b>workshop</b> you fit one chassis, motor, wheels and battery, plus armour, a weapon and a tower. Keep under <b>100 kg</b>, and the battery must supply enough power. Win fights for credits and buy better parts.',
|
help_text: 'In the <b>workshop</b> you fit one chassis, motor, wheels and battery, plus armour, a weapon and a tower. Keep under <b>100 kg</b>, and the battery must supply enough power. Win fights for credits and buy better parts.',
|
||||||
key_drive: 'drive (tank steering)', key_space: 'Space', key_weapon: 'main weapon', key_tower: 'tower weapon',
|
key_drive: 'drive (simple: screen direction, tank: turn + throttle)', key_space: 'Space', key_weapon: 'main weapon', key_tower: 'tower weapon',
|
||||||
key_pad: 'Gamepad', key_pad_text: 'stick, A = weapon, B = tower',
|
key_pad: 'Gamepad', key_pad_text: 'stick, A = weapon, B = tower',
|
||||||
help_arena: 'You win by <b>knockout</b>, by pushing the enemy into the <b>pit</b> (it opens at half time) or on damage when the time runs out. Watch the floor saws, flame grilles, spike walls, the <b>forge press</b> and the <b>magnet crane</b> in the corners!',
|
help_arena: 'You win by <b>knockout</b>, by pushing the enemy into the <b>pit</b> (it opens at half time) or on damage when the time runs out. Watch the floor saws, flame grilles, spike walls, the <b>forge press</b> and the <b>magnet crane</b> in the corners!',
|
||||||
loading: 'loading…', ranking: 'Fame ranking',
|
loading: 'loading…', ranking: 'Fame ranking',
|
||||||
@@ -25,8 +25,8 @@ window.LANG = {
|
|||||||
// workshop
|
// workshop
|
||||||
to_league: 'League', training: 'Training', unarmed: 'unarmed',
|
to_league: 'League', training: 'Training', unarmed: 'unarmed',
|
||||||
slot_chassis: 'Chassis', slot_motor: 'Motor', slot_wheels: 'Wheels', slot_battery: 'Battery',
|
slot_chassis: 'Chassis', slot_motor: 'Motor', slot_wheels: 'Wheels', slot_battery: 'Battery',
|
||||||
slot_armour: 'Armour', slot_weapon: 'Weapon', slot_tower: 'Tower',
|
slot_armour: 'Armour', slot_weapon: 'Weapon', slot_tower: 'Tower', slot_gadget: 'Gadget',
|
||||||
none: 'None', none_armour: 'Bare chassis - light but fragile.', none_weapon: 'No weapon - only ramming.', none_tower: 'No tower weapon.',
|
none: 'None', none_armour: 'Bare chassis - light but fragile.', none_weapon: 'No weapon - only ramming.', none_tower: 'No tower weapon.', none_gadget: 'No gadget.',
|
||||||
equipped: 'fitted', equip: 'Fit', sell: 'Sell {n}', buy: 'Buy {n}',
|
equipped: 'fitted', equip: 'Fit', sell: 'Sell {n}', buy: 'Buy {n}',
|
||||||
st_hp: '{n} HP', st_speed: '{n} m/s', st_force: '{n} N', st_grip: 'grip {n}', st_turn: 'turn {n}', st_invert: 'drives upside down',
|
st_hp: '{n} HP', st_speed: '{n} m/s', st_force: '{n} N', st_grip: 'grip {n}', st_turn: 'turn {n}', st_invert: 'drives upside down',
|
||||||
st_reduce: '-{n}% damage', st_dmg: '{n} dmg', st_dps: '{n} dmg/s', st_range: 'range {n} m', st_weight: '{n} kg',
|
st_reduce: '-{n}% damage', st_dmg: '{n} dmg', st_dps: '{n} dmg/s', st_range: 'range {n} m', st_weight: '{n} kg',
|
||||||
@@ -43,11 +43,25 @@ window.LANG = {
|
|||||||
pd_bulldog: 'Huge torque for pushing.',
|
pd_bulldog: 'Huge torque for pushing.',
|
||||||
pd_comet: 'Top speed for hit and run.',
|
pd_comet: 'Top speed for hit and run.',
|
||||||
pd_rubber: 'Four small wheels, nimble.',
|
pd_rubber: 'Four small wheels, nimble.',
|
||||||
|
pd_cage: 'Open scrap frame: dirt cheap and light, but it dents fast.',
|
||||||
|
pd_hexpod: 'Six-sided shell, angled all round so hits glance off.',
|
||||||
|
pd_boiler: 'Rolled steel drum, tough and tall.',
|
||||||
|
pd_fang: 'Long pointed prow, low and quick - hard to flip.',
|
||||||
|
pd_plough: 'Heavy plough blade bolted to the nose, shrugs off front hits.',
|
||||||
|
pd_discus: 'Wide flat disc, sits low and takes a beating.',
|
||||||
|
pd_omni: 'Caster wheels: spins on the spot, great steering.',
|
||||||
pd_bigtyre: 'Taller than the robot: keeps driving when flipped.',
|
pd_bigtyre: 'Taller than the robot: keeps driving when flipped.',
|
||||||
|
pd_studs: 'Studded grip, drives upside down, strong shove.',
|
||||||
|
pd_drumwh: 'Single roller drum: fast and heavy-pushing.',
|
||||||
pd_tracks: 'Massive grip, wins every shoving match.',
|
pd_tracks: 'Massive grip, wins every shoving match.',
|
||||||
|
pd_hover: 'Air skirt: very fast but slippery, draws power.',
|
||||||
pd_lead: 'Heavy, but it works.',
|
pd_lead: 'Heavy, but it works.',
|
||||||
pd_nicd: 'More power, less weight.',
|
pd_nicd: 'More power, less weight.',
|
||||||
pd_lipo: 'Light and powerful.',
|
pd_lipo: 'Light and powerful.',
|
||||||
|
pd_mesh: 'Thin wire grille - barely any weight, barely any protection.',
|
||||||
|
pd_buffer: 'Fat rubber buffers that soak up rams.',
|
||||||
|
pd_spiked: 'Plates with spikes, and they look the part.',
|
||||||
|
pd_ceramic: 'Ceramic tiles, light and very tough.',
|
||||||
pd_steel: 'Basic plates, absorb some damage.',
|
pd_steel: 'Basic plates, absorb some damage.',
|
||||||
pd_titan: 'Light and tough.',
|
pd_titan: 'Light and tough.',
|
||||||
pd_hardox: 'Wear plate - the toughest skin money can buy.',
|
pd_hardox: 'Wear plate - the toughest skin money can buy.',
|
||||||
@@ -57,9 +71,24 @@ window.LANG = {
|
|||||||
pd_saw: 'Hold Space to cut through anything in front.',
|
pd_saw: 'Hold Space to cut through anything in front.',
|
||||||
pd_crusher: 'Grabs and crushes - drag them into the hazards!',
|
pd_crusher: 'Grabs and crushes - drag them into the hazards!',
|
||||||
pd_spinner: 'Hold Space to spin up, release the energy on contact.',
|
pd_spinner: 'Hold Space to spin up, release the energy on contact.',
|
||||||
|
pd_lance: 'Long spike: big ramming damage, cheap and light.',
|
||||||
|
pd_drill: 'Grinding auger, chews through armour up close.',
|
||||||
|
pd_mace: 'Heavy spiked ball on an arm, slow but brutal.',
|
||||||
|
pd_launcher: 'Big scoop that launches the enemy high into the air.',
|
||||||
|
pd_drum: 'Drum spinner: fast spin-up, reliable hits.',
|
||||||
|
pd_lifter: 'Scoop that tips them up over and over - shove them into the pit.',
|
||||||
|
pd_vdisc: 'Vertical disc: throws the enemy straight up into the air.',
|
||||||
pd_flamer: 'Short-range fire, burns through armour.',
|
pd_flamer: 'Short-range fire, burns through armour.',
|
||||||
pd_minigun: 'Steady rivet fire from range.',
|
pd_minigun: 'Steady rivet fire from range.',
|
||||||
pd_rockets: 'Homing rockets every few seconds.',
|
pd_rockets: 'Homing rockets every few seconds.',
|
||||||
|
pd_zapper: 'Electric arc up close, eats through armour and jolts them.',
|
||||||
|
pd_mortar: 'Lobs a shell in an arc that bursts where it lands.',
|
||||||
|
pd_swarm: 'Three small rockets that chase them right across the arena.',
|
||||||
|
pd_righter: 'Flips you back upright when on your roof (G).',
|
||||||
|
pd_turbo: 'Short burst of speed and push (G).',
|
||||||
|
pd_shield: 'Field that cuts damage for a few seconds (G).',
|
||||||
|
pd_repair: 'Patches hull - two charges (G).',
|
||||||
|
pd_emp: 'Stuns a nearby enemy for a moment (G).',
|
||||||
// league
|
// league
|
||||||
league_title: 'League - season {s}',
|
league_title: 'League - season {s}',
|
||||||
league_text: 'Beat the opponents one after another. Each season they get tougher and pay more.',
|
league_text: 'Beat the opponents one after another. Each season they get tougher and pay more.',
|
||||||
@@ -67,9 +96,12 @@ window.LANG = {
|
|||||||
style_brawler: 'Brawler - straight at you', style_flanker: 'Flanker - goes for your back', style_pusher: 'Pusher - loves the pit',
|
style_brawler: 'Brawler - straight at you', style_flanker: 'Flanker - goes for your back', style_pusher: 'Pusher - loves the pit',
|
||||||
style_gunner: 'Gunner - keeps its distance', style_dummy: 'Training dummy',
|
style_gunner: 'Gunner - keeps its distance', style_dummy: 'Training dummy',
|
||||||
// fight
|
// fight
|
||||||
pad_weapon: 'Weapon', pad_tower: 'Tower',
|
pad_weapon: 'Weapon', pad_tower: 'Tower', pad_gadget: 'Gadget', fitted_parts: 'Fitted',
|
||||||
|
paint_schemes: 'Schemes',
|
||||||
|
hk_weapon: 'Space', hk_tower: 'Shift / E', hk_gadget: 'G',
|
||||||
|
broke_you: 'Your {p} broke off!', broke_enemy: "Enemy's {p} broke off!",
|
||||||
fight_go: 'ACTIVATE!', pit_open: 'PIT OPEN!', into_pit: 'INTO THE PIT!', knockout: 'KNOCKOUT!',
|
fight_go: 'ACTIVATE!', pit_open: 'PIT OPEN!', into_pit: 'INTO THE PIT!', knockout: 'KNOCKOUT!',
|
||||||
fight_hint: 'W A S D drive · Space weapon · Shift / E tower · P pause',
|
fight_hint: 'W/S drive · A/D turn · Space weapon · Shift / E tower · C camera · P pause',
|
||||||
st_lifted: 'MAGNET!', st_grabbed: 'GRABBED!', st_flipped: 'UPSIDE DOWN!', st_stunned: 'STUNNED', pit_is_open: 'PIT IS OPEN', pit_soon: 'pit opens soon',
|
st_lifted: 'MAGNET!', st_grabbed: 'GRABBED!', st_flipped: 'UPSIDE DOWN!', st_stunned: 'STUNNED', pit_is_open: 'PIT IS OPEN', pit_soon: 'pit opens soon',
|
||||||
continue: 'Continue', give_up: 'Give up',
|
continue: 'Continue', give_up: 'Give up',
|
||||||
// result
|
// result
|
||||||
@@ -102,16 +134,67 @@ window.LANG = {
|
|||||||
s_screen: 'Display', s_controls: 'Controls', s_career: 'Career', on: 'On', off: 'Off',
|
s_screen: 'Display', s_controls: 'Controls', s_career: 'Career', on: 'On', off: 'Off',
|
||||||
gfx_low: 'Low', gfx_medium: 'Medium', gfx_high: 'High',
|
gfx_low: 'Low', gfx_medium: 'Medium', gfx_high: 'High',
|
||||||
// paint booth
|
// paint booth
|
||||||
|
// online lobby + live PvP
|
||||||
|
rotate_hint: 'Turn your device sideways for a bigger picture',
|
||||||
|
s_account: 'Account',
|
||||||
|
tab_build: 'Parts', tab_paint: 'Paint', tab_hangar: 'Hangar', zoom: 'Zoom',
|
||||||
|
active_robot: 'active', use: 'Use', delete: 'Delete', hangar_full: 'Hangar full (max 6).', paint_hint: 'Pick quick colours above, or paint your own design.',
|
||||||
|
robot_n: 'Robot {n}', new_robot: 'New robot',
|
||||||
|
all_countries: 'All countries', filter_country: 'Show:',
|
||||||
|
s_arena: 'Arena', arena_random: 'Random', arena_workshop: 'Workshop Pit', arena_foundry: 'The Foundry', arena_arena64: 'Mega Dome',
|
||||||
|
arena_scrapyard: 'Scrapyard', arena_crucible: 'The Crucible', arena_colosseum: 'Grand Colosseum',
|
||||||
|
peer_back: 'Opponent is back', no_pause_online: 'No pause in live fights',
|
||||||
|
r_draw_prize: 'Draw prize',
|
||||||
|
online_guest: 'Join as guest (no e-mail)', online_short: '🌍 Online',
|
||||||
|
room_title: '{room} lobby', room_count: '{n} in this room', other_rooms: 'Other countries', you: 'you',
|
||||||
|
pick_room: 'Pick your country - then you see who is sitting in that lobby.',
|
||||||
|
cc_DE: 'Germany',
|
||||||
|
cc_AT: 'Austria',
|
||||||
|
cc_CH: 'Switzerland',
|
||||||
|
cc_GB: 'United Kingdom',
|
||||||
|
cc_US: 'USA',
|
||||||
|
cc_FR: 'France',
|
||||||
|
cc_ES: 'Spain',
|
||||||
|
cc_IT: 'Italy',
|
||||||
|
cc_NL: 'Netherlands',
|
||||||
|
cc_PL: 'Poland',
|
||||||
|
cc_TR: 'Turkey',
|
||||||
|
cc_RU: 'Russia',
|
||||||
|
cc_BR: 'Brazil',
|
||||||
|
cc_JP: 'Japan',
|
||||||
|
cc_KR: 'Korea',
|
||||||
|
cc_XX: 'International',
|
||||||
|
online_play: 'Play online', online_login_text: 'One account for your career and the online lobby - your robot and progress go with it.',
|
||||||
|
f_email: 'E-mail',
|
||||||
|
lobby: 'Global lobby', lobby_empty: 'Nobody else online right now. Keep this open - players show up here.',
|
||||||
|
your_flag: 'Your flag:', challenge: 'Challenge', busy: 'in a fight', quick_match: 'Quick match',
|
||||||
|
waiting_accept: 'Waiting for the other player...', challenge_in: 'Challenge!', wants_fight: 'wants to fight you!',
|
||||||
|
accept: 'Accept', decline: 'Decline', back_to_lobby: 'Back to lobby',
|
||||||
|
peer_lost: 'Connection to opponent lost - AI takes over', peer_left: '(left the fight)',
|
||||||
|
e_EMAIL_EXISTS: 'That e-mail is already registered.', e_EMAIL_NOT_FOUND: 'No account with that e-mail.',
|
||||||
|
e_INVALID_PASSWORD: 'Wrong password.', e_INVALID_LOGIN_CREDENTIALS: 'Wrong e-mail or password.',
|
||||||
|
e_WEAK_PASSWORD: 'Password needs at least 6 characters.', e_INVALID_EMAIL: 'That is not a valid e-mail.',
|
||||||
|
e_MISSING_PASSWORD: 'Please enter a password.', e_OPERATION_NOT_ALLOWED: 'Guest login is off - use e-mail.',
|
||||||
|
e_OFFLINE: 'Online is not set up yet.', e_ERROR: 'Something went wrong. Try again.',
|
||||||
pt_open: '🎨 Paint it yourself', pt_title: 'Paint booth', pt_top: 'TOP VIEW · front', pt_side: 'SIDE · front',
|
pt_open: '🎨 Paint it yourself', pt_title: 'Paint booth', pt_top: 'TOP VIEW · front', pt_side: 'SIDE · front',
|
||||||
pt_view_top: 'Top', pt_view_right: 'Right', pt_view_left: 'Left', pt_view_front: 'Front', pt_view_free: 'Turn',
|
pt_view_top: 'Top', pt_view_right: 'Right', pt_view_left: 'Left', pt_view_front: 'Front', pt_view_free: 'Turn',
|
||||||
pt_brush: 'Brush', pt_spray: 'Spray', pt_erase: 'Eraser', pt_stamp: 'Stamp', pt_text: 'Text', pt_fill: 'Fill',
|
pt_brush: 'Brush', pt_spray: 'Spray', pt_erase: 'Eraser', pt_stamp: 'Stamp', pt_text: 'Text', pt_fill: 'Fill',
|
||||||
pt_mirror: 'Mirror both sides', pt_size: 'Size', pt_undo: 'Undo', pt_clear: 'Clear all', pt_done: 'Done', pt_text_ph: 'Text or number',
|
pt_mirror: 'Mirror both sides', pt_size: 'Size', pt_undo: 'Undo', pt_clear: 'Clear all', pt_done: 'Done', pt_text_ph: 'Text or number',
|
||||||
|
s_cam: 'Camera', cam_iso: 'Arena', cam_chase: 'Chase', cam_fpv: 'Cockpit', key_cam: 'switch camera',
|
||||||
|
// easier play + income
|
||||||
|
s_diff: 'Difficulty', diff_easy: 'Easy', diff_normal: 'Normal', diff_hard: 'Hard',
|
||||||
|
s_steer: 'Steering', steer_simple: 'Simple', steer_tank: 'Tank',
|
||||||
|
s_autofire: 'Weapon helper',
|
||||||
|
fight_hint_simple: 'W A S D: drive in that direction · Space weapon · Shift / E tower · C camera · P pause',
|
||||||
|
exhibition_hint: 'Tip: click a beaten opponent for an exhibition fight - half the prize, as often as you like.',
|
||||||
|
exhibition_note: 'Exhibition fight: half prize money, no league progress.',
|
||||||
|
exhibition_btn: 'Exhibition fight!', r_exhibition: 'Exhibition prize', r_dmg_bonus: 'Damage bonus',
|
||||||
// shop
|
// shop
|
||||||
owned: 'owned', need_money: '{n} credits missing', fight_go_btn: 'Into the arena!',
|
owned: 'owned', need_money: '{n} credits missing', fight_go_btn: 'Into the arena!',
|
||||||
tip_bought: '{name}? Good choice. Let me bolt that on.',
|
tip_bought: '{name}? Good choice. Let me bolt that on.',
|
||||||
tip_overweight: 'Too heavy! The judges weigh every robot - drop a part or pick lighter armour.',
|
tip_overweight: 'Too heavy! The judges weigh every robot - drop a part or pick lighter armour.',
|
||||||
tip_power: 'Your battery can\'t feed all that. Buy a stronger battery or a weapon that needs less power.',
|
tip_power: 'Your battery can\'t feed all that. Buy a stronger battery or a weapon that needs less power.',
|
||||||
tip_0: 'Welcome to the workshop! Pick a category on top and click a part to see what it does.',
|
tip_0: 'Welcome to the workshop! Pick a category on top and click a part to see what it does. Tip: a flipper is a great first buy.',
|
||||||
tip_1: 'The white bar in the stats shows how your robot changes with the selected part.',
|
tip_1: 'The white bar in the stats shows how your robot changes with the selected part.',
|
||||||
tip_2: 'A wedge plus a strong motor is cheap and nasty - shove them into the saws!',
|
tip_2: 'A wedge plus a strong motor is cheap and nasty - shove them into the saws!',
|
||||||
tip_3: 'Big tyres keep you driving when a flipper turns you over.',
|
tip_3: 'Big tyres keep you driving when a flipper turns you over.',
|
||||||
@@ -119,7 +202,10 @@ window.LANG = {
|
|||||||
tip_5: 'Stay out of the corners: the forge press and the magnet crane don\'t care whose robot it is.',
|
tip_5: 'Stay out of the corners: the forge press and the magnet crane don\'t care whose robot it is.',
|
||||||
tip_6: 'Tracks win every shoving match, but they are slow.',
|
tip_6: 'Tracks win every shoving match, but they are slow.',
|
||||||
tip_7: 'Hammers ignore half of the armour. Great against heavy plates.',
|
tip_7: 'Hammers ignore half of the armour. Great against heavy plates.',
|
||||||
tip_8: 'Lost a fight? You still get an appearance fee - repairs come off your winnings.',
|
tip_8: 'Lost a fight? You still get an appearance fee and a bonus for every hit.',
|
||||||
|
tip_9: 'Short on credits? Beat an old opponent again in an exhibition fight.',
|
||||||
|
tip_10: 'Too hard? Settings: difficulty Easy, weapon helper on.',
|
||||||
|
tip_11: 'Your 800 starting credits buy a flipper right away - it beats saw robots easily.',
|
||||||
},
|
},
|
||||||
de: {
|
de: {
|
||||||
lang_self: 'Deutsch',
|
lang_self: 'Deutsch',
|
||||||
@@ -135,7 +221,7 @@ window.LANG = {
|
|||||||
reset_text: 'Roboter, Credits und Liga-Fortschritt löschen und neu anfangen?',
|
reset_text: 'Roboter, Credits und Liga-Fortschritt löschen und neu anfangen?',
|
||||||
reset_yes: 'Ja, neu anfangen', cancel: 'Abbrechen', ok: 'OK', back: 'Zurück', menu: 'Menü',
|
reset_yes: 'Ja, neu anfangen', cancel: 'Abbrechen', ok: 'OK', back: 'Zurück', menu: 'Menü',
|
||||||
help_text: 'In der <b>Werkstatt</b> baust du je ein Chassis, einen Motor, Räder und eine Batterie ein, dazu Panzerung, Waffe und Turm. Bleib unter <b>100 kg</b>, und die Batterie muss genug Strom liefern. Siege bringen Credits für bessere Teile.',
|
help_text: 'In der <b>Werkstatt</b> baust du je ein Chassis, einen Motor, Räder und eine Batterie ein, dazu Panzerung, Waffe und Turm. Bleib unter <b>100 kg</b>, und die Batterie muss genug Strom liefern. Siege bringen Credits für bessere Teile.',
|
||||||
key_drive: 'fahren (Panzersteuerung)', key_space: 'Leertaste', key_weapon: 'Hauptwaffe', key_tower: 'Turmwaffe',
|
key_drive: 'fahren (einfach: Bildschirmrichtung, Panzer: drehen + Gas)', key_space: 'Leertaste', key_weapon: 'Hauptwaffe', key_tower: 'Turmwaffe',
|
||||||
key_pad: 'Gamepad', key_pad_text: 'Stick, A = Waffe, B = Turm',
|
key_pad: 'Gamepad', key_pad_text: 'Stick, A = Waffe, B = Turm',
|
||||||
help_arena: 'Du gewinnst durch <b>K.o.</b>, indem du den Gegner in die <b>Grube</b> schiebst (öffnet zur Halbzeit) oder nach Schaden, wenn die Zeit abläuft. Achtung vor Bodensägen, Flammengittern, Stachelwänden, der <b>Schmiedepresse</b> und dem <b>Magnetkran</b> in den Ecken!',
|
help_arena: 'Du gewinnst durch <b>K.o.</b>, indem du den Gegner in die <b>Grube</b> schiebst (öffnet zur Halbzeit) oder nach Schaden, wenn die Zeit abläuft. Achtung vor Bodensägen, Flammengittern, Stachelwänden, der <b>Schmiedepresse</b> und dem <b>Magnetkran</b> in den Ecken!',
|
||||||
loading: 'lädt…', ranking: 'Ruhmesliste',
|
loading: 'lädt…', ranking: 'Ruhmesliste',
|
||||||
@@ -143,8 +229,8 @@ window.LANG = {
|
|||||||
// workshop
|
// workshop
|
||||||
to_league: 'Liga', training: 'Training', unarmed: 'unbewaffnet',
|
to_league: 'Liga', training: 'Training', unarmed: 'unbewaffnet',
|
||||||
slot_chassis: 'Chassis', slot_motor: 'Motor', slot_wheels: 'Räder', slot_battery: 'Batterie',
|
slot_chassis: 'Chassis', slot_motor: 'Motor', slot_wheels: 'Räder', slot_battery: 'Batterie',
|
||||||
slot_armour: 'Panzer', slot_weapon: 'Waffe', slot_tower: 'Turm',
|
slot_armour: 'Panzer', slot_weapon: 'Waffe', slot_tower: 'Turm', slot_gadget: 'Gadget',
|
||||||
none: 'Keine', none_armour: 'Nacktes Chassis – leicht, aber empfindlich.', none_weapon: 'Keine Waffe – nur rammen.', none_tower: 'Keine Turmwaffe.',
|
none: 'Keine', none_armour: 'Nacktes Chassis – leicht, aber empfindlich.', none_weapon: 'Keine Waffe – nur rammen.', none_tower: 'Keine Turmwaffe.', none_gadget: 'Kein Gadget.',
|
||||||
equipped: 'eingebaut', equip: 'Einbauen', sell: 'Verkaufen {n}', buy: 'Kaufen {n}',
|
equipped: 'eingebaut', equip: 'Einbauen', sell: 'Verkaufen {n}', buy: 'Kaufen {n}',
|
||||||
st_hp: '{n} LP', st_speed: '{n} m/s', st_force: '{n} N', st_grip: 'Grip {n}', st_turn: 'Wendig {n}', st_invert: 'fährt auch auf dem Kopf',
|
st_hp: '{n} LP', st_speed: '{n} m/s', st_force: '{n} N', st_grip: 'Grip {n}', st_turn: 'Wendig {n}', st_invert: 'fährt auch auf dem Kopf',
|
||||||
st_reduce: '-{n}% Schaden', st_dmg: '{n} Schaden', st_dps: '{n} Schaden/s', st_range: 'Reichweite {n} m', st_weight: '{n} kg',
|
st_reduce: '-{n}% Schaden', st_dmg: '{n} Schaden', st_dps: '{n} Schaden/s', st_range: 'Reichweite {n} m', st_weight: '{n} kg',
|
||||||
@@ -161,11 +247,25 @@ window.LANG = {
|
|||||||
pd_bulldog: 'Riesiges Drehmoment zum Schieben.',
|
pd_bulldog: 'Riesiges Drehmoment zum Schieben.',
|
||||||
pd_comet: 'Höchsttempo für Angriff und Rückzug.',
|
pd_comet: 'Höchsttempo für Angriff und Rückzug.',
|
||||||
pd_rubber: 'Vier kleine Räder, wendig.',
|
pd_rubber: 'Vier kleine Räder, wendig.',
|
||||||
|
pd_cage: 'Offener Schrottrahmen: spottbillig und leicht, aber schnell verbeult.',
|
||||||
|
pd_hexpod: 'Sechseckige Schale, rundum abgeschrägt – Treffer rutschen ab.',
|
||||||
|
pd_boiler: 'Gewalzte Stahltonne, zäh und hoch.',
|
||||||
|
pd_fang: 'Lange Spitze vorn, flach und flink – schwer umzuwerfen.',
|
||||||
|
pd_plough: 'Schweres Räumschild an der Nase, steckt Fronttreffer weg.',
|
||||||
|
pd_discus: 'Breite flache Scheibe, liegt tief und hält viel aus.',
|
||||||
|
pd_omni: 'Lenkrollen: dreht auf der Stelle, top Lenkung.',
|
||||||
pd_bigtyre: 'Höher als der Roboter: fährt auch umgedreht weiter.',
|
pd_bigtyre: 'Höher als der Roboter: fährt auch umgedreht weiter.',
|
||||||
|
pd_studs: 'Spike-Grip, fährt auch umgedreht, starkes Schieben.',
|
||||||
|
pd_drumwh: 'Eine Walze: schnell und schiebt schwer.',
|
||||||
pd_tracks: 'Enormer Grip, gewinnt jedes Schiebeduell.',
|
pd_tracks: 'Enormer Grip, gewinnt jedes Schiebeduell.',
|
||||||
|
pd_hover: 'Luftkissen: sehr schnell, aber rutschig, braucht Strom.',
|
||||||
pd_lead: 'Schwer, aber sie tut es.',
|
pd_lead: 'Schwer, aber sie tut es.',
|
||||||
pd_nicd: 'Mehr Strom, weniger Gewicht.',
|
pd_nicd: 'Mehr Strom, weniger Gewicht.',
|
||||||
pd_lipo: 'Leicht und stark.',
|
pd_lipo: 'Leicht und stark.',
|
||||||
|
pd_mesh: 'Dünnes Drahtgitter – kaum Gewicht, kaum Schutz.',
|
||||||
|
pd_buffer: 'Dicke Gummipuffer, die Rammstöße schlucken.',
|
||||||
|
pd_spiked: 'Platten mit Stacheln, sehen auch so aus.',
|
||||||
|
pd_ceramic: 'Keramikkacheln, leicht und sehr zäh.',
|
||||||
pd_steel: 'Einfache Platten, schlucken etwas Schaden.',
|
pd_steel: 'Einfache Platten, schlucken etwas Schaden.',
|
||||||
pd_titan: 'Leicht und zäh.',
|
pd_titan: 'Leicht und zäh.',
|
||||||
pd_hardox: 'Verschleißblech – die härteste Haut, die es zu kaufen gibt.',
|
pd_hardox: 'Verschleißblech – die härteste Haut, die es zu kaufen gibt.',
|
||||||
@@ -175,9 +275,24 @@ window.LANG = {
|
|||||||
pd_saw: 'Leertaste halten und alles vor dir zersägen.',
|
pd_saw: 'Leertaste halten und alles vor dir zersägen.',
|
||||||
pd_crusher: 'Packt zu und quetscht – zieh sie in die Fallen!',
|
pd_crusher: 'Packt zu und quetscht – zieh sie in die Fallen!',
|
||||||
pd_spinner: 'Leertaste halten zum Hochdrehen, die Energie entlädt sich beim Treffer.',
|
pd_spinner: 'Leertaste halten zum Hochdrehen, die Energie entlädt sich beim Treffer.',
|
||||||
|
pd_lance: 'Lange Spitze: viel Rammschaden, billig und leicht.',
|
||||||
|
pd_drill: 'Mahlende Bohrschnecke, frisst sich nah durch Panzerung.',
|
||||||
|
pd_mace: 'Schwere Stachelkugel am Arm, langsam aber brutal.',
|
||||||
|
pd_launcher: 'Große Schaufel, die den Gegner hoch in die Luft wirft.',
|
||||||
|
pd_drum: 'Walzen-Spinner: schnelles Hochdrehen, sichere Treffer.',
|
||||||
|
pd_lifter: 'Schaufel, die den Gegner immer wieder anhebt – ab in die Grube.',
|
||||||
|
pd_vdisc: 'Vertikale Scheibe: wirft den Gegner senkrecht in die Luft.',
|
||||||
pd_flamer: 'Feuer auf kurze Distanz, brennt durch Panzerung.',
|
pd_flamer: 'Feuer auf kurze Distanz, brennt durch Panzerung.',
|
||||||
pd_minigun: 'Stetiges Nietenfeuer aus der Ferne.',
|
pd_minigun: 'Stetiges Nietenfeuer aus der Ferne.',
|
||||||
pd_rockets: 'Zielsuchende Raketen alle paar Sekunden.',
|
pd_rockets: 'Zielsuchende Raketen alle paar Sekunden.',
|
||||||
|
pd_zapper: 'Lichtbogen auf kurze Distanz, frisst Panzerung und lähmt kurz.',
|
||||||
|
pd_mortar: 'Wirft eine Granate im Bogen, die beim Aufschlag explodiert.',
|
||||||
|
pd_swarm: 'Drei kleine Raketen, die quer durch die Arena hinterherjagen.',
|
||||||
|
pd_righter: 'Dreht dich wieder auf die Räder, wenn du auf dem Rücken liegst (G).',
|
||||||
|
pd_turbo: 'Kurzer Schub aus Tempo und Wucht (G).',
|
||||||
|
pd_shield: 'Feld, das ein paar Sekunden Schaden abfängt (G).',
|
||||||
|
pd_repair: 'Flickt die Hülle – zwei Ladungen (G).',
|
||||||
|
pd_emp: 'Legt einen nahen Gegner kurz lahm (G).',
|
||||||
// league
|
// league
|
||||||
league_title: 'Liga – Saison {s}',
|
league_title: 'Liga – Saison {s}',
|
||||||
league_text: 'Besiege die Gegner nacheinander. Jede Saison werden sie härter und zahlen mehr.',
|
league_text: 'Besiege die Gegner nacheinander. Jede Saison werden sie härter und zahlen mehr.',
|
||||||
@@ -185,9 +300,12 @@ window.LANG = {
|
|||||||
style_brawler: 'Raufbold – kommt direkt auf dich zu', style_flanker: 'Flankierer – will an dein Heck', style_pusher: 'Schieber – liebt die Grube',
|
style_brawler: 'Raufbold – kommt direkt auf dich zu', style_flanker: 'Flankierer – will an dein Heck', style_pusher: 'Schieber – liebt die Grube',
|
||||||
style_gunner: 'Schütze – hält Abstand', style_dummy: 'Trainingsroboter',
|
style_gunner: 'Schütze – hält Abstand', style_dummy: 'Trainingsroboter',
|
||||||
// fight
|
// fight
|
||||||
pad_weapon: 'Waffe', pad_tower: 'Turm',
|
pad_weapon: 'Waffe', pad_tower: 'Turm', pad_gadget: 'Gadget', fitted_parts: 'Verbaut',
|
||||||
|
paint_schemes: 'Vorlagen',
|
||||||
|
hk_weapon: 'Leertaste', hk_tower: 'Shift / E', hk_gadget: 'G',
|
||||||
|
broke_you: '{p} abgerissen!', broke_enemy: '{p} des Gegners abgerissen!',
|
||||||
fight_go: 'AKTIVIEREN!', pit_open: 'GRUBE OFFEN!', into_pit: 'IN DIE GRUBE!', knockout: 'K.O.!',
|
fight_go: 'AKTIVIEREN!', pit_open: 'GRUBE OFFEN!', into_pit: 'IN DIE GRUBE!', knockout: 'K.O.!',
|
||||||
fight_hint: 'W A S D fahren · Leertaste Waffe · Shift / E Turm · P Pause',
|
fight_hint: 'W/S fahren · A/D drehen · Leertaste Waffe · Shift / E Turm · C Kamera · P Pause',
|
||||||
st_lifted: 'MAGNET!', st_grabbed: 'GEPACKT!', st_flipped: 'AUF DEM KOPF!', st_stunned: 'BETÄUBT', pit_is_open: 'GRUBE IST OFFEN', pit_soon: 'Grube öffnet gleich',
|
st_lifted: 'MAGNET!', st_grabbed: 'GEPACKT!', st_flipped: 'AUF DEM KOPF!', st_stunned: 'BETÄUBT', pit_is_open: 'GRUBE IST OFFEN', pit_soon: 'Grube öffnet gleich',
|
||||||
continue: 'Weiter', give_up: 'Aufgeben',
|
continue: 'Weiter', give_up: 'Aufgeben',
|
||||||
// result
|
// result
|
||||||
@@ -220,16 +338,67 @@ window.LANG = {
|
|||||||
s_screen: 'Anzeige', s_controls: 'Steuerung', s_career: 'Karriere', on: 'An', off: 'Aus',
|
s_screen: 'Anzeige', s_controls: 'Steuerung', s_career: 'Karriere', on: 'An', off: 'Aus',
|
||||||
gfx_low: 'Niedrig', gfx_medium: 'Mittel', gfx_high: 'Hoch',
|
gfx_low: 'Niedrig', gfx_medium: 'Mittel', gfx_high: 'Hoch',
|
||||||
// paint booth
|
// paint booth
|
||||||
|
// online lobby + live PvP
|
||||||
|
rotate_hint: 'Dreh dein Gerät quer für ein größeres Bild',
|
||||||
|
s_account: 'Konto',
|
||||||
|
tab_build: 'Teile', tab_paint: 'Lackieren', tab_hangar: 'Hangar', zoom: 'Zoom',
|
||||||
|
active_robot: 'aktiv', use: 'Nutzen', delete: 'Löschen', hangar_full: 'Hangar voll (max. 6).', paint_hint: 'Oben schnelle Farben, oder male dein eigenes Design.',
|
||||||
|
robot_n: 'Roboter {n}', new_robot: 'Neuer Roboter',
|
||||||
|
all_countries: 'Alle Länder', filter_country: 'Zeigen:',
|
||||||
|
s_arena: 'Arena', arena_random: 'Zufällig', arena_workshop: 'Werkstatt-Grube', arena_foundry: 'Die Gießerei', arena_arena64: 'Mega-Dome',
|
||||||
|
arena_scrapyard: 'Schrottplatz', arena_crucible: 'Der Schmelztiegel', arena_colosseum: 'Große Arena',
|
||||||
|
peer_back: 'Gegner ist wieder da', no_pause_online: 'Keine Pause im Live-Kampf',
|
||||||
|
r_draw_prize: 'Unentschieden-Preis',
|
||||||
|
online_guest: 'Als Gast beitreten (ohne E-Mail)', online_short: '🌍 Online',
|
||||||
|
room_title: 'Lobby {room}', room_count: '{n} in diesem Raum', other_rooms: 'Andere Länder', you: 'du',
|
||||||
|
pick_room: 'Wähl dein Land - dann siehst du, wer in dieser Lobby sitzt.',
|
||||||
|
cc_DE: 'Deutschland',
|
||||||
|
cc_AT: 'Österreich',
|
||||||
|
cc_CH: 'Schweiz',
|
||||||
|
cc_GB: 'Großbritannien',
|
||||||
|
cc_US: 'USA',
|
||||||
|
cc_FR: 'Frankreich',
|
||||||
|
cc_ES: 'Spanien',
|
||||||
|
cc_IT: 'Italien',
|
||||||
|
cc_NL: 'Niederlande',
|
||||||
|
cc_PL: 'Polen',
|
||||||
|
cc_TR: 'Türkei',
|
||||||
|
cc_RU: 'Russland',
|
||||||
|
cc_BR: 'Brasilien',
|
||||||
|
cc_JP: 'Japan',
|
||||||
|
cc_KR: 'Korea',
|
||||||
|
cc_XX: 'International',
|
||||||
|
online_play: 'Online spielen', online_login_text: 'Ein Konto für Karriere und Online-Lobby - dein Roboter und Fortschritt gehören dazu.',
|
||||||
|
f_email: 'E-Mail',
|
||||||
|
lobby: 'Globale Lobby', lobby_empty: 'Gerade ist niemand sonst online. Lass das Fenster offen - Spieler erscheinen hier.',
|
||||||
|
your_flag: 'Deine Flagge:', challenge: 'Herausfordern', busy: 'im Kampf', quick_match: 'Schnelles Match',
|
||||||
|
waiting_accept: 'Warte auf den anderen Spieler...', challenge_in: 'Herausforderung!', wants_fight: 'will gegen dich kämpfen!',
|
||||||
|
accept: 'Annehmen', decline: 'Ablehnen', back_to_lobby: 'Zurück zur Lobby',
|
||||||
|
peer_lost: 'Verbindung zum Gegner weg - KI übernimmt', peer_left: '(hat den Kampf verlassen)',
|
||||||
|
e_EMAIL_EXISTS: 'Diese E-Mail ist schon registriert.', e_EMAIL_NOT_FOUND: 'Kein Konto mit dieser E-Mail.',
|
||||||
|
e_INVALID_PASSWORD: 'Falsches Passwort.', e_INVALID_LOGIN_CREDENTIALS: 'E-Mail oder Passwort falsch.',
|
||||||
|
e_WEAK_PASSWORD: 'Passwort braucht mindestens 6 Zeichen.', e_INVALID_EMAIL: 'Das ist keine gültige E-Mail.',
|
||||||
|
e_MISSING_PASSWORD: 'Bitte ein Passwort eingeben.', e_OPERATION_NOT_ALLOWED: 'Gast-Login ist aus - nimm E-Mail.',
|
||||||
|
e_OFFLINE: 'Online ist noch nicht eingerichtet.', e_ERROR: 'Etwas ist schiefgelaufen. Nochmal versuchen.',
|
||||||
pt_open: '🎨 Selbst bemalen', pt_title: 'Lackiererei', pt_top: 'OBEN · vorne', pt_side: 'SEITE · vorne',
|
pt_open: '🎨 Selbst bemalen', pt_title: 'Lackiererei', pt_top: 'OBEN · vorne', pt_side: 'SEITE · vorne',
|
||||||
pt_view_top: 'Oben', pt_view_right: 'Rechts', pt_view_left: 'Links', pt_view_front: 'Vorne', pt_view_free: 'Drehen',
|
pt_view_top: 'Oben', pt_view_right: 'Rechts', pt_view_left: 'Links', pt_view_front: 'Vorne', pt_view_free: 'Drehen',
|
||||||
pt_brush: 'Pinsel', pt_spray: 'Spray', pt_erase: 'Radierer', pt_stamp: 'Stempel', pt_text: 'Text', pt_fill: 'Füllen',
|
pt_brush: 'Pinsel', pt_spray: 'Spray', pt_erase: 'Radierer', pt_stamp: 'Stempel', pt_text: 'Text', pt_fill: 'Füllen',
|
||||||
pt_mirror: 'Beide Seiten spiegeln', pt_size: 'Größe', pt_undo: 'Zurück', pt_clear: 'Alles löschen', pt_done: 'Fertig', pt_text_ph: 'Text oder Nummer',
|
pt_mirror: 'Beide Seiten spiegeln', pt_size: 'Größe', pt_undo: 'Zurück', pt_clear: 'Alles löschen', pt_done: 'Fertig', pt_text_ph: 'Text oder Nummer',
|
||||||
|
s_cam: 'Kamera', cam_iso: 'Arena', cam_chase: 'Verfolger', cam_fpv: 'Cockpit', key_cam: 'Kamera wechseln',
|
||||||
|
// easier play + income
|
||||||
|
s_diff: 'Schwierigkeit', diff_easy: 'Leicht', diff_normal: 'Normal', diff_hard: 'Schwer',
|
||||||
|
s_steer: 'Steuerung', steer_simple: 'Einfach', steer_tank: 'Panzer',
|
||||||
|
s_autofire: 'Waffen-Hilfe',
|
||||||
|
fight_hint_simple: 'W A S D: in diese Richtung fahren · Leertaste Waffe · Shift / E Turm · C Kamera · P Pause',
|
||||||
|
exhibition_hint: 'Tipp: Klick einen besiegten Gegner für einen Schaukampf – halbes Preisgeld, so oft du willst.',
|
||||||
|
exhibition_note: 'Schaukampf: halbes Preisgeld, kein Liga-Fortschritt.',
|
||||||
|
exhibition_btn: 'Schaukampf!', r_exhibition: 'Schaukampf-Preis', r_dmg_bonus: 'Schadensbonus',
|
||||||
// shop
|
// shop
|
||||||
owned: 'im Besitz', need_money: 'Es fehlen {n} Credits', fight_go_btn: 'Ab in die Arena!',
|
owned: 'im Besitz', need_money: 'Es fehlen {n} Credits', fight_go_btn: 'Ab in die Arena!',
|
||||||
tip_bought: '{name}? Gute Wahl. Ich schraub das gleich dran.',
|
tip_bought: '{name}? Gute Wahl. Ich schraub das gleich dran.',
|
||||||
tip_overweight: 'Zu schwer! Jeder Roboter wird gewogen – lass ein Teil weg oder nimm leichtere Panzerung.',
|
tip_overweight: 'Zu schwer! Jeder Roboter wird gewogen – lass ein Teil weg oder nimm leichtere Panzerung.',
|
||||||
tip_power: 'Deine Batterie schafft das nicht. Kauf eine stärkere oder nimm eine Waffe mit weniger Strombedarf.',
|
tip_power: 'Deine Batterie schafft das nicht. Kauf eine stärkere oder nimm eine Waffe mit weniger Strombedarf.',
|
||||||
tip_0: 'Willkommen in der Werkstatt! Wähl oben eine Kategorie und klick ein Teil an, um zu sehen, was es kann.',
|
tip_0: 'Willkommen in der Werkstatt! Wähl oben eine Kategorie und klick ein Teil an, um zu sehen, was es kann. Tipp: Ein Flipper ist ein super erster Kauf.',
|
||||||
tip_1: 'Der weiße Balken bei den Werten zeigt, wie sich dein Roboter mit dem gewählten Teil ändert.',
|
tip_1: 'Der weiße Balken bei den Werten zeigt, wie sich dein Roboter mit dem gewählten Teil ändert.',
|
||||||
tip_2: 'Keil plus starker Motor: billig und gemein – schieb sie in die Sägen!',
|
tip_2: 'Keil plus starker Motor: billig und gemein – schieb sie in die Sägen!',
|
||||||
tip_3: 'Große Reifen fahren weiter, wenn dich ein Flipper umdreht.',
|
tip_3: 'Große Reifen fahren weiter, wenn dich ein Flipper umdreht.',
|
||||||
@@ -237,6 +406,9 @@ window.LANG = {
|
|||||||
tip_5: 'Bleib aus den Ecken: Schmiedepresse und Magnetkran ist egal, wessen Roboter da steht.',
|
tip_5: 'Bleib aus den Ecken: Schmiedepresse und Magnetkran ist egal, wessen Roboter da steht.',
|
||||||
tip_6: 'Ketten gewinnen jedes Schiebeduell, sind aber langsam.',
|
tip_6: 'Ketten gewinnen jedes Schiebeduell, sind aber langsam.',
|
||||||
tip_7: 'Hämmer ignorieren die halbe Panzerung. Ideal gegen dicke Platten.',
|
tip_7: 'Hämmer ignorieren die halbe Panzerung. Ideal gegen dicke Platten.',
|
||||||
tip_8: 'Kampf verloren? Antrittsgeld gibt es trotzdem – die Reparatur geht davon ab.',
|
tip_8: 'Kampf verloren? Antrittsgeld gibt es trotzdem, dazu einen Bonus für jeden Treffer.',
|
||||||
|
tip_9: 'Knapp bei Kasse? Besieg einen alten Gegner nochmal im Schaukampf.',
|
||||||
|
tip_10: 'Zu schwer? Einstellungen: Schwierigkeit Leicht, Waffen-Hilfe an.',
|
||||||
|
tip_11: 'Mit deinen 800 Start-Credits kannst du sofort einen Flipper kaufen – der schlägt Säge-Roboter locker.',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
132
game/lobby.js
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
/* Robot Clash - online lobby: presence, player list, challenges, match creation. No DOM.
|
||||||
|
Needs net.js (RC.Net). Transport is Firebase RTDB (net.db). All cosmetic/casual, see docs/firebase.
|
||||||
|
|
||||||
|
const lobby = RC.Lobby({ net, getProfile: () => ({ name, flag, build, paint, fame }) });
|
||||||
|
lobby.enter() announce presence, start heartbeat, watch list + incoming challenges
|
||||||
|
lobby.leave() remove presence, stop everything
|
||||||
|
lobby.onList(fn) fn([{ uid, name, flag, state, fame }]) - online players except me, newest first
|
||||||
|
lobby.onIncoming(fn) fn({ from, fromName, fromFlag, build, paint, seed }) - someone challenges me
|
||||||
|
lobby.onMatch(fn) fn({ id, host (bool), opp: { uid, name, flag, build, paint }, seed }) - fight on
|
||||||
|
lobby.onCancel(fn) fn() - a pending challenge I sent/got fell through
|
||||||
|
await lobby.challenge(uid) invite a player (writes to their inbox, waits for accept)
|
||||||
|
await lobby.accept(from) accept an incoming challenge -> creates the match
|
||||||
|
lobby.decline(from) reject an incoming challenge
|
||||||
|
lobby.cancel() withdraw the challenge I sent
|
||||||
|
|
||||||
|
Presence TTL: entries older than STALE ms count as offline (no SDK onDisconnect). */
|
||||||
|
(function (root) {
|
||||||
|
'use strict';
|
||||||
|
const RC = (root.RC = root.RC || {});
|
||||||
|
const HEARTBEAT = 4000, STALE = 12000;
|
||||||
|
const now = () => Date.now();
|
||||||
|
// match id = both uids sorted + join -> same id on both sides; lower uid hosts (authority)
|
||||||
|
const matchId = (a, b) => [a, b].sort().join('_');
|
||||||
|
const isHost = (a, b) => a < b;
|
||||||
|
|
||||||
|
RC.Lobby = (opt) => {
|
||||||
|
const net = opt.net, db = net.db;
|
||||||
|
const cbs = { list: [], incoming: [], match: [], cancel: [] };
|
||||||
|
const emit = (k, v) => cbs[k].forEach(fn => { try { fn(v); } catch (e) { /* ignore */ } });
|
||||||
|
let hb = null, subList = null, subIn = null, subMatch = null;
|
||||||
|
let outgoing = null; // uid I challenged
|
||||||
|
let inMatch = null; // active match id
|
||||||
|
|
||||||
|
const me = () => net.uid;
|
||||||
|
const prof = () => opt.getProfile();
|
||||||
|
|
||||||
|
async function beat(state) {
|
||||||
|
const p = prof();
|
||||||
|
await db.put(`lobby/${me()}`, { name: p.name, flag: p.flag || 'XX', fame: p.fame | 0, ver: 2, state: state || 'idle', ts: { '.sv': 'timestamp' } });
|
||||||
|
}
|
||||||
|
|
||||||
|
function watchList() {
|
||||||
|
subList = db.stream('lobby', data => {
|
||||||
|
const t = now(), mine = me();
|
||||||
|
const rows = Object.entries(data || {})
|
||||||
|
.map(([uid, v]) => Object.assign({ uid }, v))
|
||||||
|
.filter(v => v.uid !== mine && v.name && (t - (v.ts || 0)) < STALE)
|
||||||
|
.sort((a, b) => (b.ts || 0) - (a.ts || 0));
|
||||||
|
emit('list', rows);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// incoming challenges land under challenges/<me>/<fromUid>
|
||||||
|
function watchIncoming() {
|
||||||
|
subIn = db.stream(`challenges/${me()}`, data => {
|
||||||
|
const entries = Object.entries(data || {}).filter(([, v]) => v && v.from && (now() - (v.ts || 0)) < STALE);
|
||||||
|
if (!entries.length) return;
|
||||||
|
const [, c] = entries[0];
|
||||||
|
emit('incoming', { from: c.from, fromName: c.fromName, fromFlag: c.fromFlag, build: c.build, paint: c.paint, seed: c.seed });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// the match node appears for both players once created (host writes it on accept)
|
||||||
|
function watchMatch(id, oppUid, host) {
|
||||||
|
cleanupMatch();
|
||||||
|
inMatch = id;
|
||||||
|
subMatch = db.stream(`matches/${id}/meta`, meta => {
|
||||||
|
// wait until BOTH players have written their robot (each side patches its own entry)
|
||||||
|
if (!meta || inMatch !== id || meta.seed == null || !meta[oppUid] || !meta[me()]) return;
|
||||||
|
emit('match', { id, host, opp: { uid: oppUid, name: meta[oppUid] && meta[oppUid].name, flag: meta[oppUid] && meta[oppUid].flag, build: meta[oppUid] && meta[oppUid].build, paint: meta[oppUid] && meta[oppUid].paint }, seed: meta.seed });
|
||||||
|
if (subMatch) { subMatch.close(); subMatch = null; } // meta is fixed; stop watching
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function cleanupMatch() { if (subMatch) { subMatch.close(); subMatch = null; } }
|
||||||
|
|
||||||
|
async function challenge(uid) {
|
||||||
|
if (outgoing) return;
|
||||||
|
outgoing = uid;
|
||||||
|
const p = prof();
|
||||||
|
await beat('searching');
|
||||||
|
await db.put(`challenges/${uid}/${me()}`, { from: me(), fromName: p.name, fromFlag: p.flag || 'XX', build: p.build, paint: p.paint, seed: (Math.random() * 1e9) | 0, ts: { '.sv': 'timestamp' } });
|
||||||
|
// wait for the other side to create the match (they host if their uid < mine)
|
||||||
|
const id = matchId(me(), uid), host = isHost(me(), uid);
|
||||||
|
const give = setTimeout(() => { if (outgoing === uid) { emit('cancel'); cancel(); } }, STALE);
|
||||||
|
const watch = db.stream(`matches/${id}/meta/seed`, seed => {
|
||||||
|
if (seed == null) return;
|
||||||
|
clearTimeout(give); watch.close(); outgoing = null;
|
||||||
|
createMatch(uid); // add my own robot to the match meta
|
||||||
|
watchMatch(id, uid, host);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function accept(from) {
|
||||||
|
const id = matchId(me(), from), host = isHost(me(), from);
|
||||||
|
await db.del(`challenges/${me()}/${from}`);
|
||||||
|
await createMatch(from);
|
||||||
|
watchMatch(id, from, host);
|
||||||
|
}
|
||||||
|
function decline(from) { db.del(`challenges/${me()}/${from}`); }
|
||||||
|
function cancel() { if (outgoing) { db.del(`challenges/${outgoing}/${me()}`); outgoing = null; beat('idle'); } }
|
||||||
|
|
||||||
|
async function createMatch(oppUid) {
|
||||||
|
const id = matchId(me(), oppUid), p = prof();
|
||||||
|
const seed = (parseInt(id.slice(-6), 36) % 1e9) || 1; // same on both sides
|
||||||
|
// meta holds both players' robots; written once, guarded so the first writer wins
|
||||||
|
await db.patch(`matches/${id}/meta`, { seed, [me()]: { name: p.name, flag: p.flag || 'XX', build: p.build, paint: p.paint } });
|
||||||
|
await beat('inmatch');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
onList: fn => cbs.list.push(fn),
|
||||||
|
onIncoming: fn => cbs.incoming.push(fn),
|
||||||
|
onMatch: fn => cbs.match.push(fn),
|
||||||
|
onCancel: fn => cbs.cancel.push(fn),
|
||||||
|
challenge, accept, decline, cancel,
|
||||||
|
async enter() {
|
||||||
|
if (!net.enabled || !me()) return;
|
||||||
|
await beat('idle');
|
||||||
|
hb = setInterval(() => db.patch(`lobby/${me()}`, { ts: { '.sv': 'timestamp' }, state: outgoing ? 'searching' : inMatch ? 'inmatch' : 'idle' }), HEARTBEAT);
|
||||||
|
watchList(); watchIncoming();
|
||||||
|
},
|
||||||
|
refresh() { if (me()) beat(outgoing ? 'searching' : inMatch ? 'inmatch' : 'idle'); },
|
||||||
|
endMatch() { const id = inMatch; inMatch = null; cleanupMatch(); if (id) db.del(`matches/${id}`); if (me()) beat('idle'); },
|
||||||
|
leave() {
|
||||||
|
clearInterval(hb); hb = null;
|
||||||
|
if (subList) subList.close(); if (subIn) subIn.close(); cleanupMatch();
|
||||||
|
if (me()) db.del(`lobby/${me()}`);
|
||||||
|
},
|
||||||
|
matchId, isHost,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})(typeof window !== 'undefined' ? window : globalThis);
|
||||||
101
game/looks.js
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
/* Robot Clash - opponent looks: makes the 3D league robots resemble their ComfyGen portraits
|
||||||
|
(assets/Sprites/opp_<id>.png). A look = a painted skin layer (same 512x256 layout as the player's
|
||||||
|
own drawing: left half top view, right half side view, front to the right) + a few extra model
|
||||||
|
parts that render3d.js adds (eyes, cab, bumps, track covers).
|
||||||
|
|
||||||
|
RC.LOOKS[id] = { pattern, accent2, eyes, cab, bumps, tracksLook, wheelScale }
|
||||||
|
RC.lookLayer(look, paint) -> canvas (cached per id), used as paint.layer with paint.drawn = true */
|
||||||
|
(function (root) {
|
||||||
|
'use strict';
|
||||||
|
const RC = root.RC;
|
||||||
|
const LW = 512, LH = 256;
|
||||||
|
const css = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
||||||
|
|
||||||
|
RC.LOOKS = {
|
||||||
|
rustbucket: { pattern: 'rust', cab: true, wheelScale: 1.35, eyes: 0xffb040 },
|
||||||
|
tintoad: { pattern: 'rivets', bumps: true, eyes: 0xd8ff60 },
|
||||||
|
buzzkill: { pattern: 'hazard', tracksLook: true, eyes: 0xff3a20 },
|
||||||
|
flapjack: { pattern: 'twotone', accent2: 0xf2f2f2, eyes: 0x9fd8ff },
|
||||||
|
pincer: { pattern: 'twotone', accent2: 0xe0b030, eyes: 0xffd040 },
|
||||||
|
thunderclap: { pattern: 'scratches', eyes: 0xffa020 },
|
||||||
|
gravedigger: { pattern: 'dark', eyes: 0x50ff80 },
|
||||||
|
overlord: { pattern: 'redstripe', accent2: 0xd02020, eyes: 0xff2020 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const cache = {};
|
||||||
|
RC.lookLayer = (id, paint) => {
|
||||||
|
if (cache[id]) return cache[id];
|
||||||
|
const look = RC.LOOKS[id];
|
||||||
|
if (!look || typeof document === 'undefined') return null;
|
||||||
|
const cv = document.createElement('canvas'); cv.width = LW; cv.height = LH;
|
||||||
|
const c = cv.getContext('2d');
|
||||||
|
let seed = 1; for (const ch of id) seed = (seed * 31 + ch.charCodeAt(0)) >>> 0;
|
||||||
|
const r = () => { seed = (seed * 1664525 + 1013904223) >>> 0; return seed / 4294967296; };
|
||||||
|
const halves = fn => { for (const h of [0, 1]) { c.save(); c.beginPath(); c.rect(h * 256, 0, 256, 256); c.clip(); c.translate(h * 256, 0); fn(h); c.restore(); } };
|
||||||
|
const scratches = (n, a) => {
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
c.strokeStyle = `rgba(${r() < 0.6 ? '255,255,255' : '0,0,0'},${a * (0.5 + r())})`; c.lineWidth = 0.6 + r() * 1.6;
|
||||||
|
const x = r() * LW, y = r() * LH, ang = r() * 6.3, l = 6 + r() * 34;
|
||||||
|
c.beginPath(); c.moveTo(x, y); c.lineTo(x + Math.cos(ang) * l, y + Math.sin(ang) * l); c.stroke();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const rivets = (step, col) => halves(() => {
|
||||||
|
c.fillStyle = col;
|
||||||
|
for (let x = 12; x < 256; x += step) for (const y of [12, 244]) { c.beginPath(); c.arc(x, y, 3.2, 0, 7); c.fill(); }
|
||||||
|
for (let y = 12; y < 256; y += step) for (const x of [12, 244]) { c.beginPath(); c.arc(x, y, 3.2, 0, 7); c.fill(); }
|
||||||
|
});
|
||||||
|
|
||||||
|
switch (look.pattern) {
|
||||||
|
case 'rust': // brown base with orange rust blotches and dark holes
|
||||||
|
for (let i = 0; i < 90; i++) {
|
||||||
|
c.fillStyle = `rgba(${150 + r() * 70 | 0},${60 + r() * 40 | 0},${20 + r() * 20 | 0},${0.25 + r() * 0.4})`;
|
||||||
|
c.beginPath(); c.ellipse(r() * LW, r() * LH, 6 + r() * 28, 4 + r() * 18, r() * 3, 0, 7); c.fill();
|
||||||
|
}
|
||||||
|
for (let i = 0; i < 40; i++) { c.fillStyle = `rgba(30,18,10,${0.3 + r() * 0.4})`; c.beginPath(); c.arc(r() * LW, r() * LH, 1 + r() * 4, 0, 7); c.fill(); }
|
||||||
|
rivets(40, 'rgba(40,25,15,.8)'); scratches(120, 0.12);
|
||||||
|
break;
|
||||||
|
case 'rivets': // panel lines + rivet rows
|
||||||
|
halves(() => {
|
||||||
|
c.strokeStyle = 'rgba(0,0,0,.35)'; c.lineWidth = 3;
|
||||||
|
for (const x of [86, 170]) { c.beginPath(); c.moveTo(x, 0); c.lineTo(x, 256); c.stroke(); }
|
||||||
|
c.beginPath(); c.moveTo(0, 128); c.lineTo(256, 128); c.stroke();
|
||||||
|
});
|
||||||
|
rivets(22, 'rgba(20,30,10,.85)'); scratches(80, 0.1);
|
||||||
|
break;
|
||||||
|
case 'hazard': // yellow/black stripes, darker band in the middle of the top
|
||||||
|
halves(h => {
|
||||||
|
c.fillStyle = '#16181c';
|
||||||
|
for (let k = -256; k < 512; k += 64) { c.beginPath(); c.moveTo(k, 0); c.lineTo(k + 32, 0); c.lineTo(k + 32 - 256, 256); c.lineTo(k - 256, 256); c.fill(); }
|
||||||
|
if (h === 0) { c.fillStyle = 'rgba(20,22,26,.9)'; c.fillRect(0, 96, 256, 64); }
|
||||||
|
});
|
||||||
|
scratches(140, 0.12);
|
||||||
|
break;
|
||||||
|
case 'twotone': // second colour on the top and as a band on the sides
|
||||||
|
c.fillStyle = css(look.accent2); c.fillRect(20, 30, 216, 196);
|
||||||
|
c.fillRect(256, 0, 256, 92);
|
||||||
|
c.fillStyle = 'rgba(0,0,0,.25)'; c.fillRect(256, 90, 256, 6);
|
||||||
|
rivets(32, 'rgba(0,0,0,.45)'); scratches(90, 0.1);
|
||||||
|
break;
|
||||||
|
case 'scratches':
|
||||||
|
scratches(260, 0.16); rivets(36, 'rgba(0,0,0,.5)');
|
||||||
|
break;
|
||||||
|
case 'dark': // dark hex plates with faint green seams
|
||||||
|
halves(() => {
|
||||||
|
c.strokeStyle = 'rgba(80,255,128,.18)'; c.lineWidth = 2;
|
||||||
|
for (let y = 0; y < 280; y += 36) for (let x = (y / 36) % 2 ? 0 : 21; x < 280; x += 42) {
|
||||||
|
c.beginPath(); for (let k = 0; k < 6; k++) { const a = k * Math.PI / 3; c.lineTo(x + Math.cos(a) * 20, y + Math.sin(a) * 20); } c.closePath(); c.stroke();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
scratches(70, 0.1);
|
||||||
|
break;
|
||||||
|
case 'redstripe': // racing stripe along the top, red band on the sides
|
||||||
|
c.fillStyle = css(look.accent2); c.fillRect(0, 100, 256, 56);
|
||||||
|
c.fillStyle = 'rgba(255,255,255,.8)'; c.fillRect(0, 96, 256, 4); c.fillRect(0, 156, 256, 4);
|
||||||
|
c.fillStyle = css(look.accent2); c.fillRect(256, 120, 256, 36);
|
||||||
|
scratches(110, 0.12);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cache[id] = cv;
|
||||||
|
return cv;
|
||||||
|
};
|
||||||
|
})(window);
|
||||||
175
game/net.js
Normal file
@@ -0,0 +1,175 @@
|
|||||||
|
/* Robot Clash - Firebase over plain REST (no SDK, classic script, runs from file://).
|
||||||
|
Auth = Identity Toolkit REST, database = Realtime Database REST + Server-Sent-Events for push.
|
||||||
|
|
||||||
|
const net = RC.Net({ apiKey: '...', dbUrl: 'https://<proj>-default-rtdb.firebaseio.com' });
|
||||||
|
net.enabled false without a full config -> game stays offline
|
||||||
|
await net.auth.register(email, pass, name) -> { ok, error } (error: 'EMAIL_EXISTS' | 'WEAK_PASSWORD' | ...)
|
||||||
|
await net.auth.login(email, pass) -> { ok, error } ('EMAIL_NOT_FOUND' | 'INVALID_PASSWORD' | ...)
|
||||||
|
await net.auth.guest(name) -> { ok, error } (anonymous sign-in, must be enabled in Firebase)
|
||||||
|
net.auth.resume() -> true if a saved session was restored (async refresh follows)
|
||||||
|
net.auth.logout() / net.auth.current -> { uid, name, email, guest } | null
|
||||||
|
net.auth.onChange(fn) called after login/logout/refresh
|
||||||
|
|
||||||
|
await net.db.get(path) -> value | null
|
||||||
|
await net.db.put(path, value) -> ok (PUT, replaces)
|
||||||
|
await net.db.patch(path, obj) -> ok (PATCH, merges)
|
||||||
|
await net.db.push(path, value) -> key | null (POST, new child)
|
||||||
|
await net.db.del(path) -> ok
|
||||||
|
const sub = net.db.stream(path, onValue) -> { close() } push updates via EventSource
|
||||||
|
onValue(value) fires with the whole subtree on connect and on every change.
|
||||||
|
|
||||||
|
All DB calls carry the id token (?auth=). Token auto-refreshes before it expires.
|
||||||
|
Every call is best effort: on error db.get -> null, writes -> false, never throws. */
|
||||||
|
(function (root) {
|
||||||
|
'use strict';
|
||||||
|
const RC = (root.RC = root.RC || {});
|
||||||
|
const AUTH = 'https://identitytoolkit.googleapis.com/v1/accounts:';
|
||||||
|
const TOKEN = 'https://securetoken.googleapis.com/v1/token';
|
||||||
|
|
||||||
|
RC.Net = (cfg = {}) => {
|
||||||
|
const apiKey = cfg.apiKey || '';
|
||||||
|
const dbUrl = (cfg.dbUrl || '').replace(/\/+$/, '');
|
||||||
|
const enabled = /^AIza[\w-]+$/.test(apiKey) && /^https:\/\/.+firebase(io|database)\.(com|app)$/.test(dbUrl);
|
||||||
|
const store = Kit.store('robotclash.net');
|
||||||
|
|
||||||
|
let session = null; // { idToken, refreshToken, uid, name, email, guest, exp }
|
||||||
|
const listeners = [];
|
||||||
|
const fire = () => listeners.forEach(fn => { try { fn(cur()); } catch (e) { /* ignore */ } });
|
||||||
|
function cur() { return session ? { uid: session.uid, name: session.name, email: session.email, guest: session.guest } : null; }
|
||||||
|
|
||||||
|
async function postJson(url, body) {
|
||||||
|
const res = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) });
|
||||||
|
const data = await res.json().catch(() => ({}));
|
||||||
|
if (!res.ok) { const msg = (data.error && data.error.message) || ('HTTP_' + res.status); const e = new Error(msg); e.code = msg.split(/[ :]/)[0]; throw e; }
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function save() { store.set('session', session ? { refreshToken: session.refreshToken, uid: session.uid, name: session.name, email: session.email, guest: session.guest } : null); }
|
||||||
|
|
||||||
|
function setAuth(d, name, guest) {
|
||||||
|
session = {
|
||||||
|
idToken: d.idToken || d.id_token, refreshToken: d.refreshToken || d.refresh_token,
|
||||||
|
uid: d.localId || d.user_id, name: name || (session && session.name) || '', email: d.email || (session && session.email) || '', guest: !!guest,
|
||||||
|
exp: Date.now() + (+(d.expiresIn || d.expires_in || 3600) - 60) * 1000,
|
||||||
|
};
|
||||||
|
save(); fire();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refresh() {
|
||||||
|
if (!session || !session.refreshToken) return false;
|
||||||
|
try {
|
||||||
|
const d = await postJson(`${TOKEN}?key=${apiKey}`, { grant_type: 'refresh_token', refresh_token: session.refreshToken });
|
||||||
|
session.idToken = d.id_token; session.refreshToken = d.refresh_token; session.uid = d.user_id;
|
||||||
|
session.exp = Date.now() + (+d.expires_in - 60) * 1000; save(); return true;
|
||||||
|
} catch (e) { session = null; save(); fire(); return false; }
|
||||||
|
}
|
||||||
|
async function token() {
|
||||||
|
if (!session) return null;
|
||||||
|
if (Date.now() >= session.exp) { if (!await refresh()) return null; }
|
||||||
|
return session.idToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auth = {
|
||||||
|
get current() { return cur(); },
|
||||||
|
onChange(fn) { listeners.push(fn); },
|
||||||
|
async register(email, pass, name) {
|
||||||
|
if (!enabled) return { ok: false, error: 'OFFLINE' };
|
||||||
|
email = String(email || '').trim().toLowerCase();
|
||||||
|
try {
|
||||||
|
const d = await postJson(`${AUTH}signUp?key=${apiKey}`, { email, password: pass, returnSecureToken: true });
|
||||||
|
setAuth(d, Kit.cleanName(name) || email.split('@')[0], false);
|
||||||
|
await dbWrite('PUT', `users/${session.uid}/name`, session.name); // name for later logins
|
||||||
|
return { ok: true };
|
||||||
|
} catch (e) { return { ok: false, error: e.code || 'ERROR' }; }
|
||||||
|
},
|
||||||
|
async login(email, pass) {
|
||||||
|
if (!enabled) return { ok: false, error: 'OFFLINE' };
|
||||||
|
email = String(email || '').trim().toLowerCase();
|
||||||
|
try {
|
||||||
|
const d = await postJson(`${AUTH}signInWithPassword?key=${apiKey}`, { email, password: pass, returnSecureToken: true });
|
||||||
|
setAuth(d, email.split('@')[0], false);
|
||||||
|
const name = await dbGet(`users/${session.uid}/name`); // needs the token -> after setAuth
|
||||||
|
if (typeof name === 'string' && name) { session.name = name; save(); fire(); }
|
||||||
|
return { ok: true };
|
||||||
|
} catch (e) { return { ok: false, error: e.code || 'ERROR' }; }
|
||||||
|
},
|
||||||
|
async guest(name) {
|
||||||
|
if (!enabled) return { ok: false, error: 'OFFLINE' };
|
||||||
|
try {
|
||||||
|
const d = await postJson(`${AUTH}signUp?key=${apiKey}`, { returnSecureToken: true });
|
||||||
|
setAuth(d, Kit.cleanName(name) || 'Guest', true);
|
||||||
|
return { ok: true };
|
||||||
|
} catch (e) { return { ok: false, error: e.code || 'ERROR' }; }
|
||||||
|
},
|
||||||
|
resume() {
|
||||||
|
const s = store.get('session', null);
|
||||||
|
if (!s || !s.refreshToken) return false;
|
||||||
|
session = Object.assign({ idToken: '', exp: 0 }, s);
|
||||||
|
refresh().then(ok => { if (ok) fire(); });
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
logout() { session = null; save(); fire(); },
|
||||||
|
};
|
||||||
|
|
||||||
|
async function dbGet(path) {
|
||||||
|
if (!enabled) return null;
|
||||||
|
const t = await token();
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${dbUrl}/${path}.json${t ? '?auth=' + t : ''}`, { cache: 'no-store' });
|
||||||
|
return res.ok ? await res.json() : null;
|
||||||
|
} catch (e) { return null; }
|
||||||
|
}
|
||||||
|
async function dbWrite(method, path, value) {
|
||||||
|
if (!enabled) return false;
|
||||||
|
const t = await token();
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${dbUrl}/${path}.json${t ? '?auth=' + t : ''}`, {
|
||||||
|
method, headers: { 'Content-Type': 'application/json' }, body: value === undefined ? undefined : JSON.stringify(value),
|
||||||
|
});
|
||||||
|
return res.ok ? (method === 'POST' ? (await res.json()).name : true) : false;
|
||||||
|
} catch (e) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = {
|
||||||
|
get: dbGet,
|
||||||
|
put: (p, v) => dbWrite('PUT', p, v),
|
||||||
|
patch: (p, v) => dbWrite('PATCH', p, v),
|
||||||
|
push: (p, v) => dbWrite('POST', p, v),
|
||||||
|
del: p => dbWrite('DELETE', p),
|
||||||
|
// EventSource push stream. RTDB sends 'put' (whole subtree at /) and 'patch' (partial) events.
|
||||||
|
stream(path, onValue) {
|
||||||
|
if (!enabled || typeof EventSource === 'undefined') return { close() {} };
|
||||||
|
let es = null, closed = false, value = null, retry = null;
|
||||||
|
const open = async () => {
|
||||||
|
if (closed) return;
|
||||||
|
const t = await token();
|
||||||
|
es = new EventSource(`${dbUrl}/${path}.json${t ? '?auth=' + t : ''}`);
|
||||||
|
// 'put' = replace the value at d.path; 'patch' = merge d.data's children into d.path
|
||||||
|
const setAt = (keys, data) => {
|
||||||
|
if (!keys.length) { value = data; return; }
|
||||||
|
if (value == null || typeof value !== 'object') value = {};
|
||||||
|
let o = value;
|
||||||
|
for (let i = 0; i < keys.length - 1; i++) { if (o[keys[i]] == null || typeof o[keys[i]] !== 'object') o[keys[i]] = {}; o = o[keys[i]]; }
|
||||||
|
if (data == null) delete o[keys[keys.length - 1]]; else o[keys[keys.length - 1]] = data;
|
||||||
|
};
|
||||||
|
const apply = ev => {
|
||||||
|
let d; try { d = JSON.parse(ev.data); } catch (e) { return; }
|
||||||
|
if (!d || typeof d.path !== 'string') return;
|
||||||
|
const keys = d.path.split('/').filter(Boolean);
|
||||||
|
if (ev.type === 'patch' && d.data && typeof d.data === 'object') {
|
||||||
|
for (const [k, v] of Object.entries(d.data)) setAt(keys.concat(k.split('/').filter(Boolean)), v);
|
||||||
|
} else setAt(keys, d.data);
|
||||||
|
try { onValue(value); } catch (e) { /* ignore */ }
|
||||||
|
};
|
||||||
|
es.addEventListener('put', apply);
|
||||||
|
es.addEventListener('patch', apply);
|
||||||
|
es.onerror = () => { if (closed) return; es.close(); retry = setTimeout(open, 1500); };
|
||||||
|
};
|
||||||
|
open();
|
||||||
|
return { close() { closed = true; clearTimeout(retry); if (es) es.close(); } };
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return { enabled, auth, db, get uid() { return session ? session.uid : null; }, token };
|
||||||
|
};
|
||||||
|
})(typeof window !== 'undefined' ? window : globalThis);
|
||||||
154
game/netfight.js
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
/* Robot Clash - live PvP sync over an existing deterministic fight. Needs net.js, combat.js, ai.js.
|
||||||
|
Robot 0 is always the local player, robot 1 the opponent (both clients see it that way, so the host
|
||||||
|
mirrors indices when it publishes). The lower-uid player is the host (authority): it runs the real
|
||||||
|
RC.Combat.step and publishes snapshots; the guest renders them and only sends its input.
|
||||||
|
|
||||||
|
const nf = RC.NetFight({ net, id, host, mySeat, oppStyle, oppSkill, onPeerLost(wasHost) });
|
||||||
|
nf.start()
|
||||||
|
HOST each tick, instead of the normal step:
|
||||||
|
nf.hostStep(s, localInput, dt) runs step with [local, remote|AI], publishes ~15 Hz, returns events
|
||||||
|
GUEST each frame, instead of step:
|
||||||
|
nf.guestFrame(s, localInput, dt) eases robots toward the last snapshot, returns events to play
|
||||||
|
nf.peerAlive false once the peer went silent > GRACE (AI takes over)
|
||||||
|
nf.stop()
|
||||||
|
|
||||||
|
mySeat: 0 if I am meta[myUid] rendered as robot 0 (always true locally). The host publishes with robots
|
||||||
|
ordered [host, guest]; each side maps so that *its* robot is index 0. */
|
||||||
|
(function (root) {
|
||||||
|
'use strict';
|
||||||
|
const RC = (root.RC = root.RC || {});
|
||||||
|
const PUB = 1 / 15, GRACE = 4000; // ms without news before the AI covers for the peer
|
||||||
|
// robot fields the view / HUD / sound read - kept small for the wire
|
||||||
|
const RF = ['x', 'z', 'a', 'y', 'hp', 'maxHp', 'flipped', 'stun', 'lifted', 'grabbedBy', 'grab', 'turretA', 'spin', 'sawOn', 'flameOn', 'gunOn', 'swing', 'cd', 'cd2', 'boost', 'gcd', 'gUses', 'shield', 'lost', 'dead', 'out'];
|
||||||
|
const rnd = v => (typeof v === 'number' ? Math.round(v * 1000) / 1000 : v);
|
||||||
|
const packRobot = r => { const o = {}; for (const k of RF) o[k] = rnd(r[k]); return o; };
|
||||||
|
const wrap = a => { while (a > Math.PI) a -= 2 * Math.PI; while (a < -Math.PI) a += 2 * Math.PI; return a; };
|
||||||
|
|
||||||
|
RC.NetFight = (opt) => {
|
||||||
|
const net = opt.net, db = net.db, id = opt.id, host = opt.host;
|
||||||
|
const base = `matches/${id}`;
|
||||||
|
let pubT = 0, seq = 0, sendT = 0, beatT = 0, lastInSeq = -1, evBuf = [];
|
||||||
|
let sending = false, slow = 0; // one write at a time; back off while the line is slow
|
||||||
|
let remoteInput = { throttle: 0, turn: 0, fire: false, fire2: false, fire3: false };
|
||||||
|
let started = false, lastPeer = Date.now(), peerAlive = true, ai = null, subIn = null, subState = null, subPing = null, lastState = null, stateApplied = -1;
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
if (host) {
|
||||||
|
// host reads the guest's input stream
|
||||||
|
subIn = db.stream(`${base}/in`, v => { if (v && typeof v.seq === 'number') { remoteInput = v; lastPeer = Date.now(); } });
|
||||||
|
} else {
|
||||||
|
// guest reads the host's state stream
|
||||||
|
subState = db.stream(`${base}/state`, v => { if (v && typeof v.seq === 'number') { lastState = v; lastPeer = Date.now(); } });
|
||||||
|
subPing = db.stream(`${base}/ping`, v => { if (v) lastPeer = Date.now(); }); // host alive during the countdown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkPeer() {
|
||||||
|
if (!started) { started = true; lastPeer = Math.max(lastPeer, Date.now()); } // countdown is over: start the clock
|
||||||
|
if (!peerAlive && Date.now() - lastPeer < GRACE) { peerAlive = true; if (opt.onPeerBack) opt.onPeerBack(host); }
|
||||||
|
if (peerAlive && Date.now() - lastPeer > GRACE) {
|
||||||
|
peerAlive = false;
|
||||||
|
if (host && !ai) ai = RC.AI.create({ style: opt.oppStyle || 'brawler', skill: opt.oppSkill != null ? opt.oppSkill : 0.5, seed: 7 });
|
||||||
|
if (opt.onPeerLost) opt.onPeerLost(host);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// HOST: step with [local, guest-or-AI], publish robots as [host, guest] but return a state where
|
||||||
|
// index 0 is the LOCAL player (so game.js renders identically on both sides).
|
||||||
|
function hostStep(s, localInput, dt) {
|
||||||
|
checkPeer();
|
||||||
|
const guestInput = peerAlive ? remoteInput : ai.think(s, s.robots[1], s.robots[0], dt);
|
||||||
|
RC.Combat.step(s, dt, [localInput, guestInput]);
|
||||||
|
if (s.events.length) evBuf.push.apply(evBuf, s.events); // batch events between publishes for the guest
|
||||||
|
pubT -= dt;
|
||||||
|
// publish only when the previous write came back - otherwise slow uploads queue up and the host stutters
|
||||||
|
if (pubT <= 0 && !sending) {
|
||||||
|
pubT = PUB + slow;
|
||||||
|
sending = true;
|
||||||
|
const t0 = Date.now();
|
||||||
|
const payload = {
|
||||||
|
seq: ++seq, t: rnd(s.t), left: rnd(s.left), pitOpen: rnd(s.pitOpen), pitAlarm: s.pitAlarm,
|
||||||
|
press: { st: s.press.st, y: rnd(s.press.y) }, crane: { st: s.crane.st, x: rnd(s.crane.x), z: rnd(s.crane.z), who: s.crane.who },
|
||||||
|
rockets: s.rockets.map(k => ({ x: rnd(k.x), z: rnd(k.z), y: rnd(k.y), a: rnd(k.a) })),
|
||||||
|
r: [packRobot(s.robots[0]), packRobot(s.robots[1])],
|
||||||
|
ev: evBuf.slice(-24), result: s.result, endIn: rnd(s.endIn),
|
||||||
|
};
|
||||||
|
evBuf.length = 0;
|
||||||
|
const done = () => {
|
||||||
|
sending = false;
|
||||||
|
const ms = Date.now() - t0; // slow line: send less often instead of piling up
|
||||||
|
slow = ms > 400 ? 0.2 : ms > 180 ? 0.08 : 0;
|
||||||
|
};
|
||||||
|
try { Promise.resolve(db.put(`${base}/state`, payload)).then(done, done); } catch (e) { done(); }
|
||||||
|
}
|
||||||
|
return s.events;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GUEST: no simulation. Ease local robots toward the latest snapshot; snap flags/hp; play its events once.
|
||||||
|
function guestFrame(s, localInput, dt) {
|
||||||
|
checkPeer();
|
||||||
|
// send my input (I am robot 0 locally = guest = snapshot index 1)
|
||||||
|
sendT -= dt;
|
||||||
|
beatT -= dt;
|
||||||
|
// send on change, and at least every 0.5 s as a heartbeat (otherwise the host thinks I am gone)
|
||||||
|
if (sendT <= 0 && !sending && (changed(localInput) || beatT <= 0)) {
|
||||||
|
sendT = PUB; beatT = 0.5; lastInSeq++;
|
||||||
|
sending = true;
|
||||||
|
const fin = () => { sending = false; };
|
||||||
|
try {
|
||||||
|
Promise.resolve(db.put(`${base}/in`, { seq: lastInSeq, throttle: rnd(localInput.throttle || 0), turn: rnd(localInput.turn || 0),
|
||||||
|
fire: !!localInput.fire, fire2: !!localInput.fire2, fire3: !!localInput.fire3 })).then(fin, fin);
|
||||||
|
} catch (e) { fin(); }
|
||||||
|
prevInput = localInput;
|
||||||
|
}
|
||||||
|
const ev = [];
|
||||||
|
if (lastState) {
|
||||||
|
const snap = lastState;
|
||||||
|
s.t = snap.t; s.left = snap.left; s.pitOpen = snap.pitOpen; s.pitAlarm = snap.pitAlarm;
|
||||||
|
s.press.st = snap.press.st; s.press.y = snap.press.y;
|
||||||
|
s.crane.st = snap.crane.st; s.crane.x = snap.crane.x; s.crane.z = snap.crane.z; s.crane.who = snap.crane.who;
|
||||||
|
syncRockets(s, snap.rockets);
|
||||||
|
s.result = snap.result; s.endIn = snap.endIn;
|
||||||
|
// snapshot order [host, guest]; locally guest must be index 0 -> swap
|
||||||
|
applyRobot(s.robots[0], snap.r[1], dt); // me (guest)
|
||||||
|
applyRobot(s.robots[1], snap.r[0], dt); // host
|
||||||
|
if (snap.seq !== stateApplied) {
|
||||||
|
stateApplied = snap.seq;
|
||||||
|
for (const e of snap.ev || []) { const c = Object.assign({}, e); if (c.who === 0) c.who = 1; else if (c.who === 1) c.who = 0; ev.push(c); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ev;
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyRobot(r, d, dt) {
|
||||||
|
if (!d) return;
|
||||||
|
const k = Math.min(1, dt * 14); // ease position/angle, snap the rest
|
||||||
|
r.x += (d.x - r.x) * k; r.z += (d.z - r.z) * k; r.y += (d.y - r.y) * k;
|
||||||
|
r.a += wrap(d.a - r.a) * k;
|
||||||
|
r.turretA += wrap(d.turretA - r.turretA) * k;
|
||||||
|
for (const f of ['hp', 'maxHp', 'flipped', 'stun', 'lifted', 'grabbedBy', 'grab', 'spin', 'sawOn', 'flameOn', 'gunOn', 'swing', 'cd', 'cd2', 'boost', 'gcd', 'gUses', 'shield', 'lost', 'dead', 'out']) if (d[f] !== undefined) r[f] = d[f];
|
||||||
|
}
|
||||||
|
function syncRockets(s, list) {
|
||||||
|
list = list || [];
|
||||||
|
s.rockets.length = list.length;
|
||||||
|
for (let i = 0; i < list.length; i++) s.rockets[i] = Object.assign(s.rockets[i] || { owner: 1, sp: 6, t: 3 }, list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
let prevInput = null;
|
||||||
|
function changed(inp) { return !prevInput || inp.throttle !== prevInput.throttle || inp.turn !== prevInput.turn || inp.fire !== prevInput.fire || inp.fire2 !== prevInput.fire2 || inp.fire3 !== prevInput.fire3; }
|
||||||
|
|
||||||
|
return {
|
||||||
|
start, hostStep, guestFrame,
|
||||||
|
// during the countdown: keep the line alive (guest sends a neutral input, host an empty state ping)
|
||||||
|
idle(dt) {
|
||||||
|
sendT -= dt;
|
||||||
|
if (sendT > 0) return;
|
||||||
|
sendT = 0.5;
|
||||||
|
if (host) db.patch(`${base}/ping`, { h: Date.now() });
|
||||||
|
else { lastInSeq++; db.put(`${base}/in`, { seq: lastInSeq, throttle: 0, turn: 0, fire: false, fire2: false, fire3: false }); }
|
||||||
|
},
|
||||||
|
get peerAlive() { return peerAlive; },
|
||||||
|
stop() { if (subIn) subIn.close(); if (subState) subState.close(); if (subPing) subPing.close(); },
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})(typeof window !== 'undefined' ? window : globalThis);
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
const RC = (root.RC = root.RC || {});
|
const RC = (root.RC = root.RC || {});
|
||||||
|
|
||||||
RC.WEIGHT_LIMIT = 100; // kg, single weight class in v1
|
RC.WEIGHT_LIMIT = 100; // kg, single weight class in v1
|
||||||
RC.SLOTS = ['chassis', 'motor', 'wheels', 'battery', 'armour', 'weapon', 'tower'];
|
RC.SLOTS = ['chassis', 'motor', 'wheels', 'battery', 'armour', 'weapon', 'tower', 'gadget'];
|
||||||
RC.REQUIRED = { chassis: true, motor: true, wheels: true, battery: true };
|
RC.REQUIRED = { chassis: true, motor: true, wheels: true, battery: true };
|
||||||
|
|
||||||
const P = [
|
const P = [
|
||||||
@@ -18,6 +18,12 @@
|
|||||||
{ id: 'doorstop', slot: 'chassis', name: 'Doorstop', cost: 380, weight: 25, hp: 105, len: 1.45, wid: 1.05, h: 0.34, shape: 'wedge', lowProfile: true },
|
{ id: 'doorstop', slot: 'chassis', name: 'Doorstop', cost: 380, weight: 25, hp: 105, len: 1.45, wid: 1.05, h: 0.34, shape: 'wedge', lowProfile: true },
|
||||||
{ id: 'bulwark', slot: 'chassis', name: 'Bulwark', cost: 720, weight: 34, hp: 150, len: 1.5, wid: 1.2, h: 0.5, shape: 'box' },
|
{ id: 'bulwark', slot: 'chassis', name: 'Bulwark', cost: 720, weight: 34, hp: 150, len: 1.5, wid: 1.2, h: 0.5, shape: 'box' },
|
||||||
{ id: 'scarab', slot: 'chassis', name: 'Scarab', cost: 1150, weight: 30, hp: 135, len: 1.4, wid: 1.15, h: 0.46, shape: 'dome', frontArmour: 0.15 },
|
{ id: 'scarab', slot: 'chassis', name: 'Scarab', cost: 1150, weight: 30, hp: 135, len: 1.4, wid: 1.15, h: 0.46, shape: 'dome', frontArmour: 0.15 },
|
||||||
|
{ id: 'cage', slot: 'chassis', name: 'Scrap Cage', cost: 260, weight: 17, hp: 85, len: 1.35, wid: 1.1, h: 0.46, shape: 'frame' },
|
||||||
|
{ id: 'hexpod', slot: 'chassis', name: 'Hexpod', cost: 520, weight: 24, hp: 115, len: 1.35, wid: 1.15, h: 0.44, shape: 'hex' },
|
||||||
|
{ id: 'boiler', slot: 'chassis', name: 'Boiler', cost: 640, weight: 29, hp: 130, len: 1.3, wid: 1.1, h: 0.52, shape: 'barrel' },
|
||||||
|
{ id: 'fang', slot: 'chassis', name: 'Fang', cost: 860, weight: 26, hp: 120, len: 1.55, wid: 1.0, h: 0.36, shape: 'arrow', lowProfile: true, frontArmour: 0.12 },
|
||||||
|
{ id: 'plough', slot: 'chassis', name: 'Snowplough', cost: 980, weight: 36, hp: 150, len: 1.45, wid: 1.2, h: 0.42, shape: 'plow', frontArmour: 0.22 },
|
||||||
|
{ id: 'discus', slot: 'chassis', name: 'Discus', cost: 1350, weight: 32, hp: 155, len: 1.5, wid: 1.35, h: 0.3, shape: 'saucer', lowProfile: true },
|
||||||
|
|
||||||
// motor: force (N), top speed (m/s)
|
// motor: force (N), top speed (m/s)
|
||||||
{ id: 'sparky', slot: 'motor', name: 'Sparky 2kW', cost: 100, weight: 8, power: 3, force: 650, speed: 4.0 },
|
{ id: 'sparky', slot: 'motor', name: 'Sparky 2kW', cost: 100, weight: 8, power: 3, force: 650, speed: 4.0 },
|
||||||
@@ -27,8 +33,12 @@
|
|||||||
|
|
||||||
// wheels: speed factor, lateral grip, turn rate (rad/s), push factor; invertible = drives upside down
|
// wheels: speed factor, lateral grip, turn rate (rad/s), push factor; invertible = drives upside down
|
||||||
{ id: 'rubber', slot: 'wheels', name: 'Rubber 4x', cost: 60, weight: 4, speedMul: 1.0, grip: 7, turn: 2.8, push: 1.0, kind: 'small' },
|
{ id: 'rubber', slot: 'wheels', name: 'Rubber 4x', cost: 60, weight: 4, speedMul: 1.0, grip: 7, turn: 2.8, push: 1.0, kind: 'small' },
|
||||||
|
{ id: 'omni', slot: 'wheels', name: 'Omni Casters', cost: 360, weight: 6, speedMul: 1.05, grip: 9, turn: 3.4, push: 0.95, kind: 'omni' },
|
||||||
{ id: 'bigtyre', slot: 'wheels', name: 'Big Tyres', cost: 280, weight: 7, speedMul: 1.1, grip: 7.5, turn: 2.5, push: 1.05, kind: 'big', invertible: true },
|
{ id: 'bigtyre', slot: 'wheels', name: 'Big Tyres', cost: 280, weight: 7, speedMul: 1.1, grip: 7.5, turn: 2.5, push: 1.05, kind: 'big', invertible: true },
|
||||||
|
{ id: 'studs', slot: 'wheels', name: 'Studded Tyres', cost: 460, weight: 9, speedMul: 1.0, grip: 10, turn: 2.6, push: 1.2, kind: 'stud', invertible: true },
|
||||||
|
{ id: 'drumwh', slot: 'wheels', name: 'Roller Drum', cost: 600, weight: 10, speedMul: 1.15, grip: 8, turn: 2.0, push: 1.3, kind: 'drum' },
|
||||||
{ id: 'tracks', slot: 'wheels', name: 'Crawler Tracks', cost: 540, weight: 11, speedMul: 0.86, grip: 12, turn: 2.2, push: 1.45, kind: 'tracks' },
|
{ id: 'tracks', slot: 'wheels', name: 'Crawler Tracks', cost: 540, weight: 11, speedMul: 0.86, grip: 12, turn: 2.2, push: 1.45, kind: 'tracks' },
|
||||||
|
{ id: 'hover', slot: 'wheels', name: 'Hover Skirt', cost: 900, weight: 8, power: 4, speedMul: 1.25, grip: 5, turn: 3.0, push: 0.8, kind: 'hover', invertible: true },
|
||||||
|
|
||||||
// battery: power = supply
|
// battery: power = supply
|
||||||
{ id: 'lead', slot: 'battery', name: 'Lead 12V', cost: 80, weight: 10, power: 9 },
|
{ id: 'lead', slot: 'battery', name: 'Lead 12V', cost: 80, weight: 10, power: 9 },
|
||||||
@@ -36,9 +46,13 @@
|
|||||||
{ id: 'lipo', slot: 'battery', name: 'LiPo Stack', cost: 760, weight: 5, power: 19 },
|
{ id: 'lipo', slot: 'battery', name: 'LiPo Stack', cost: 760, weight: 5, power: 19 },
|
||||||
|
|
||||||
// armour: reduce = share of damage absorbed, hp bonus
|
// armour: reduce = share of damage absorbed, hp bonus
|
||||||
{ id: 'steel', slot: 'armour', name: 'Steel Plates', cost: 220, weight: 12, reduce: 0.15, hp: 10, tint: 0x8a9099 },
|
{ id: 'mesh', slot: 'armour', name: 'Wire Mesh', cost: 120, weight: 5, reduce: 0.08, hp: 4, tint: 0x9aa3ad, style: 'mesh' },
|
||||||
{ id: 'titan', slot: 'armour', name: 'Titanium Skin', cost: 680, weight: 9, reduce: 0.25, hp: 15, tint: 0xa9b8c9 },
|
{ id: 'steel', slot: 'armour', name: 'Steel Plates', cost: 220, weight: 12, reduce: 0.15, hp: 10, tint: 0x8a9099, style: 'plates' },
|
||||||
{ id: 'hardox', slot: 'armour', name: 'Hardox Shell', cost: 1150, weight: 18, reduce: 0.38, hp: 25, tint: 0xc9a845 },
|
{ id: 'buffer', slot: 'armour', name: 'Rubber Buffers', cost: 300, weight: 8, reduce: 0.18, hp: 8, tint: 0x33343a, style: 'bumper' },
|
||||||
|
{ id: 'spiked', slot: 'armour', name: 'Spiked Plates', cost: 520, weight: 14, reduce: 0.22, hp: 12, tint: 0x7d868f, style: 'spike' },
|
||||||
|
{ id: 'titan', slot: 'armour', name: 'Titanium Skin', cost: 680, weight: 9, reduce: 0.25, hp: 15, tint: 0xa9b8c9, style: 'plates' },
|
||||||
|
{ id: 'ceramic', slot: 'armour', name: 'Ceramic Tiles', cost: 900, weight: 11, reduce: 0.32, hp: 14, tint: 0xd8d2c4, style: 'tiles' },
|
||||||
|
{ id: 'hardox', slot: 'armour', name: 'Hardox Shell', cost: 1150, weight: 18, reduce: 0.38, hp: 25, tint: 0xc9a845, style: 'plates' },
|
||||||
|
|
||||||
// weapons (Space): type decides the behaviour in combat.js
|
// weapons (Space): type decides the behaviour in combat.js
|
||||||
{ id: 'wedge', slot: 'weapon', name: 'Steel Wedge', cost: 80, weight: 6, power: 0, type: 'wedge', reach: 0.35, ram: 1.7, cd: 4 },
|
{ id: 'wedge', slot: 'weapon', name: 'Steel Wedge', cost: 80, weight: 6, power: 0, type: 'wedge', reach: 0.35, ram: 1.7, cd: 4 },
|
||||||
@@ -47,11 +61,28 @@
|
|||||||
{ id: 'saw', slot: 'weapon', name: 'Circular Saw', cost: 420, weight: 9, power: 5, type: 'saw', reach: 0.4, dps: 24 },
|
{ id: 'saw', slot: 'weapon', name: 'Circular Saw', cost: 420, weight: 9, power: 5, type: 'saw', reach: 0.4, dps: 24 },
|
||||||
{ id: 'crusher', slot: 'weapon', name: 'Hydraulic Jaws', cost: 780, weight: 15, power: 7, type: 'crusher', reach: 0.5, dps: 20, hold: 2.2, cd: 3.5 },
|
{ id: 'crusher', slot: 'weapon', name: 'Hydraulic Jaws', cost: 780, weight: 15, power: 7, type: 'crusher', reach: 0.5, dps: 20, hold: 2.2, cd: 3.5 },
|
||||||
{ id: 'spinner', slot: 'weapon', name: 'Bar Spinner', cost: 950, weight: 18, power: 9, type: 'spinner', reach: 0.6, dmg: 34, spinup: 1.4 },
|
{ id: 'spinner', slot: 'weapon', name: 'Bar Spinner', cost: 950, weight: 18, power: 9, type: 'spinner', reach: 0.6, dmg: 34, spinup: 1.4 },
|
||||||
|
{ id: 'lance', slot: 'weapon', name: 'Ram Lance', cost: 300, weight: 8, power: 0, type: 'wedge', reach: 0.5, ram: 2.3, cd: 4 },
|
||||||
|
{ id: 'drill', slot: 'weapon', name: 'Auger Drill', cost: 560, weight: 11, power: 6, type: 'saw', reach: 0.45, dps: 28 },
|
||||||
|
{ id: 'mace', slot: 'weapon', name: 'Spiked Mace', cost: 640, weight: 13, power: 5, type: 'hammer', reach: 0.9, dmg: 26, cd: 1.7 },
|
||||||
|
{ id: 'launcher', slot: 'weapon', name: 'Scoop Launcher', cost: 700, weight: 15, power: 7, type: 'flipper', reach: 0.6, dmg: 6, launch: 9.5, cd: 2.6 },
|
||||||
|
{ id: 'drum', slot: 'weapon', name: 'Drum Spinner', cost: 820, weight: 16, power: 8, type: 'spinner', reach: 0.5, dmg: 26, spinup: 1.0 },
|
||||||
|
{ id: 'lifter', slot: 'weapon', name: 'Scoop Lifter', cost: 340, weight: 10, power: 4, type: 'lifter', reach: 0.5, dmg: 4, launch: 3.2, cd: 1.2 },
|
||||||
|
{ id: 'vdisc', slot: 'weapon', name: 'Vertical Disc', cost: 1100, weight: 17, power: 9, type: 'vspinner', reach: 0.5, dmg: 30, spinup: 1.5 },
|
||||||
|
|
||||||
// towers (Shift / E): auto-aiming turret on top
|
// towers (Shift / E): auto-aiming turret on top
|
||||||
{ id: 'flamer', slot: 'tower', name: 'Flame Nozzle', cost: 360, weight: 6, power: 3, type: 'flamer', range: 2.8, dps: 10, cone: 0.4 },
|
{ id: 'flamer', slot: 'tower', name: 'Flame Nozzle', cost: 360, weight: 6, power: 3, type: 'flamer', range: 2.8, dps: 10, cone: 0.4 },
|
||||||
{ id: 'minigun', slot: 'tower', name: 'Rivet Minigun', cost: 520, weight: 7, power: 4, type: 'minigun', range: 9, dps: 8 },
|
{ id: 'minigun', slot: 'tower', name: 'Rivet Minigun', cost: 520, weight: 7, power: 4, type: 'minigun', range: 9, dps: 8 },
|
||||||
{ id: 'rockets', slot: 'tower', name: 'Seeker Pod', cost: 840, weight: 10, power: 5, type: 'rockets', range: 14, dmg: 17, cd: 2.4 },
|
{ id: 'rockets', slot: 'tower', name: 'Seeker Pod', cost: 840, weight: 10, power: 5, type: 'rockets', range: 14, dmg: 17, cd: 2.4 },
|
||||||
|
{ id: 'zapper', slot: 'tower', name: 'Arc Zapper', cost: 600, weight: 8, power: 6, type: 'zapper', range: 3.4, dps: 15 },
|
||||||
|
{ id: 'mortar', slot: 'tower', name: 'Mortar Tube', cost: 760, weight: 11, power: 5, type: 'mortar', range: 11, dmg: 26, cd: 3.0, splash: 1.7 },
|
||||||
|
{ id: 'swarm', slot: 'tower', name: 'Swarm Pod', cost: 1150, weight: 12, power: 6, type: 'swarm', range: 22, dmg: 9, cd: 3.6, shots: 3 },
|
||||||
|
|
||||||
|
// gadgets (G): one-shot abilities on a cooldown; optional slot
|
||||||
|
{ id: 'righter', slot: 'gadget', name: 'Self-Righter', cost: 180, weight: 5, power: 2, type: 'righter', cd: 4 },
|
||||||
|
{ id: 'turbo', slot: 'gadget', name: 'Nitro Boost', cost: 300, weight: 6, power: 3, type: 'turbo', cd: 7, dur: 1.2 },
|
||||||
|
{ id: 'shield', slot: 'gadget', name: 'Deflector Field', cost: 420, weight: 7, power: 4, type: 'shield', cd: 9, dur: 2.5, reduce: 0.6 },
|
||||||
|
{ id: 'repair', slot: 'gadget', name: 'Repair Kit', cost: 500, weight: 8, power: 3, type: 'repair', cd: 8, charges: 2, heal: 0.26 },
|
||||||
|
{ id: 'emp', slot: 'gadget', name: 'EMP Burst', cost: 640, weight: 7, power: 5, type: 'emp', cd: 8, range: 3.2, stun: 1.5 },
|
||||||
];
|
];
|
||||||
|
|
||||||
RC.PARTS = {};
|
RC.PARTS = {};
|
||||||
|
|||||||
723
game/render3d.js
@@ -41,8 +41,8 @@
|
|||||||
c.fillStyle = g; c.fillRect(0, 0, 64, 64);
|
c.fillStyle = g; c.fillRect(0, 0, 64, 64);
|
||||||
});
|
});
|
||||||
|
|
||||||
function floorTex() {
|
function floorTex(A) {
|
||||||
const A = RC.ARENA, S = 64, N = A.half * 2 * S; // 64 px per metre
|
const S = 64, N = A.half * 2 * S; // 64 px per metre
|
||||||
const P = (x, z) => [(x + A.half) * S, (z + A.half) * S];
|
const P = (x, z) => [(x + A.half) * S, (z + A.half) * S];
|
||||||
let plate = null; // tex_floor.jpg from ComfyGen (make_tileable)
|
let plate = null; // tex_floor.jpg from ComfyGen (make_tileable)
|
||||||
const tex = canvasTex(N, N, draw);
|
const tex = canvasTex(N, N, draw);
|
||||||
@@ -105,6 +105,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// image from assets/Sprites as a WebGL texture; skipped quietly where file:// taints it (release embeds data: URIs)
|
||||||
|
function loadTex(file, onReady) {
|
||||||
|
const im = new Image();
|
||||||
|
im.onload = () => {
|
||||||
|
const probe = document.createElement('canvas').getContext('2d');
|
||||||
|
probe.drawImage(im, 0, 0, 1, 1);
|
||||||
|
try { probe.getImageData(0, 0, 1, 1); } catch (e) { return; }
|
||||||
|
const tex = new T.Texture(im);
|
||||||
|
tex.encoding = T.sRGBEncoding; tex.anisotropy = 4; tex.needsUpdate = true;
|
||||||
|
onReady(tex);
|
||||||
|
};
|
||||||
|
im.src = Kit.asset('assets/Sprites/' + file);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- particles
|
// ---------------------------------------------------------------- particles
|
||||||
function Particles(scene, max, size, additive, tex) {
|
function Particles(scene, max, size, additive, tex) {
|
||||||
const pos = new Float32Array(max * 3), col = new Float32Array(max * 4);
|
const pos = new Float32Array(max * 3), col = new Float32Array(max * 4);
|
||||||
@@ -159,10 +173,18 @@
|
|||||||
M.lamp = new T.MeshStandardMaterial({ color: 0xffffff, emissive: 0xfff2c0, emissiveIntensity: 1.5 }); // floodlights (intro switches them on)
|
M.lamp = new T.MeshStandardMaterial({ color: 0xffffff, emissive: 0xfff2c0, emissiveIntensity: 1.5 }); // floodlights (intro switches them on)
|
||||||
M.stripe = new T.MeshStandardMaterial({ map: stripeTex(), metalness: 0.3, roughness: 0.6 });
|
M.stripe = new T.MeshStandardMaterial({ map: stripeTex(), metalness: 0.3, roughness: 0.6 });
|
||||||
M.flame = new T.MeshBasicMaterial({ color: 0xff3a08, transparent: true, opacity: 0.42, blending: T.AdditiveBlending, depthWrite: false, side: T.DoubleSide });
|
M.flame = new T.MeshBasicMaterial({ color: 0xff3a08, transparent: true, opacity: 0.42, blending: T.AdditiveBlending, depthWrite: false, side: T.DoubleSide });
|
||||||
|
M.flameCore = new T.MeshBasicMaterial({ color: 0xffd060, transparent: true, opacity: 0.55, blending: T.AdditiveBlending, depthWrite: false, side: T.DoubleSide });
|
||||||
|
M.arc = new T.MeshBasicMaterial({ color: 0x6ec8ff, transparent: true, opacity: 0.5, blending: T.AdditiveBlending, depthWrite: false, side: T.DoubleSide });
|
||||||
M.trackTex = canvasTex(64, 16, (c, w, h) => { c.fillStyle = '#17181b'; c.fillRect(0, 0, w, h); c.fillStyle = '#2c2e33'; for (let x = 0; x < w; x += 8) c.fillRect(x, 0, 4, h); }, [6, 1]);
|
M.trackTex = canvasTex(64, 16, (c, w, h) => { c.fillStyle = '#17181b'; c.fillRect(0, 0, w, h); c.fillStyle = '#2c2e33'; for (let x = 0; x < w; x += 8) c.fillRect(x, 0, 4, h); }, [6, 1]);
|
||||||
M.track = new T.MeshStandardMaterial({ map: M.trackTex, roughness: 0.85, metalness: 0.2 });
|
M.track = new T.MeshStandardMaterial({ map: M.trackTex, roughness: 0.85, metalness: 0.2 });
|
||||||
|
M.wsteel = new T.MeshStandardMaterial({ color: 0xd2d7de, metalness: 0.95, roughness: 0.22 }); // bright weapon steel
|
||||||
|
M.wedge = new T.MeshStandardMaterial({ color: 0x9aa0a8, metalness: 0.85, roughness: 0.35 });
|
||||||
return M;
|
return M;
|
||||||
}
|
}
|
||||||
|
// shop: the robot is framed in the left column, not in the middle of the stage
|
||||||
|
const GARAGE_OFF_X = 455, GARAGE_OFF_Y = 16;
|
||||||
|
// shop zoom: 0.6 = furthest out (the default, whole robot in frame), 1.9 = closest
|
||||||
|
const GZ_MIN = 0.6, GZ_MAX = 1.9, GZ_DEF = GZ_MIN;
|
||||||
const box = (w, h, d, m) => { const o = new T.Mesh(new T.BoxGeometry(w, h, d), m); o.castShadow = true; o.receiveShadow = true; return o; };
|
const box = (w, h, d, m) => { const o = new T.Mesh(new T.BoxGeometry(w, h, d), m); o.castShadow = true; o.receiveShadow = true; return o; };
|
||||||
const cyl = (r1, r2, h, m, seg = 20) => { const o = new T.Mesh(new T.CylinderGeometry(r1, r2, h, seg), m); o.castShadow = true; return o; };
|
const cyl = (r1, r2, h, m, seg = 20) => { const o = new T.Mesh(new T.CylinderGeometry(r1, r2, h, seg), m); o.castShadow = true; return o; };
|
||||||
|
|
||||||
@@ -204,6 +226,17 @@
|
|||||||
return geo;
|
return geo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// body from a top-view outline, extruded upwards (shape plane XY -> XZ, extrusion -> +Y)
|
||||||
|
function prism(pts, h) {
|
||||||
|
const sh = new T.Shape();
|
||||||
|
sh.moveTo(pts[0][0], pts[0][1]);
|
||||||
|
for (let i = 1; i < pts.length; i++) sh.lineTo(pts[i][0], pts[i][1]);
|
||||||
|
sh.closePath();
|
||||||
|
const g = new T.ExtrudeGeometry(sh, { depth: h, bevelEnabled: true, bevelSize: 0.015, bevelThickness: 0.015, bevelSegments: 1 });
|
||||||
|
g.rotateX(-Math.PI / 2);
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
function buildRobot(build, paint) {
|
function buildRobot(build, paint) {
|
||||||
const m = mats(), st = RC.stats(build), P = RC.PARTS;
|
const m = mats(), st = RC.stats(build), P = RC.PARTS;
|
||||||
const ch = P[build.chassis], wh = P[build.wheels], ar = build.armour ? P[build.armour] : null;
|
const ch = P[build.chassis], wh = P[build.wheels], ar = build.armour ? P[build.armour] : null;
|
||||||
@@ -216,10 +249,16 @@
|
|||||||
root.add(tilt);
|
root.add(tilt);
|
||||||
const out = { root, tilt, body, skin, st, build, roll: 0, flash: 0, spinA: 0, sawA: 0, gunA: 0, smokeT: 0 };
|
const out = { root, tilt, body, skin, st, build, roll: 0, flash: 0, spinA: 0, sawA: 0, gunA: 0, smokeT: 0 };
|
||||||
const sk = (geo, w, h, d, y0) => { const o = new T.Mesh(skinUV(geo, w, d, h, y0), body); o.castShadow = o.receiveShadow = true; return o; };
|
const sk = (geo, w, h, d, y0) => { const o = new T.Mesh(skinUV(geo, w, d, h, y0), body); o.castShadow = o.receiveShadow = true; return o; };
|
||||||
const big = wh && wh.kind === 'big';
|
const look = paint.look || {}; // opponent look (looks.js), cosmetic only
|
||||||
const c = big ? 0.12 : 0.1; // ground clearance
|
const big = wh && (wh.kind === 'big' || wh.kind === 'stud');
|
||||||
|
const ws = look.wheelScale || 1;
|
||||||
|
const c = big ? 0.12 : 0.1 * ws; // ground clearance
|
||||||
out.c = c;
|
out.c = c;
|
||||||
|
|
||||||
|
// every piece gets userData.part = slot (lets tools/partshot.html render one part alone)
|
||||||
|
let from = 0;
|
||||||
|
const mark = part => { for (let i = from; i < tilt.children.length; i++) tilt.children[i].userData.part = part; from = tilt.children.length; };
|
||||||
|
|
||||||
// chassis
|
// chassis
|
||||||
let top = c + H;
|
let top = c + H;
|
||||||
if (ch.shape === 'wedge') {
|
if (ch.shape === 'wedge') {
|
||||||
@@ -236,6 +275,44 @@
|
|||||||
const ring = new T.Mesh(new T.TorusGeometry(1, 0.035, 8, 32), accent);
|
const ring = new T.Mesh(new T.TorusGeometry(1, 0.035, 8, 32), accent);
|
||||||
ring.rotation.x = Math.PI / 2; ring.scale.set(L * 0.5, Wd * 0.5, 1); ring.position.y = c + H * 0.5; tilt.add(ring);
|
ring.rotation.x = Math.PI / 2; ring.scale.set(L * 0.5, Wd * 0.5, 1); ring.position.y = c + H * 0.5; tilt.add(ring);
|
||||||
top = c + H * 1.2;
|
top = c + H * 1.2;
|
||||||
|
} else if (ch.shape === 'hex' || ch.shape === 'arrow') {
|
||||||
|
const hx = L / 2, hz = Wd / 2;
|
||||||
|
const pts = ch.shape === 'hex'
|
||||||
|
? [[-hx * 0.55, -hz], [hx * 0.55, -hz], [hx, 0], [hx * 0.55, hz], [-hx * 0.55, hz], [-hx, 0]]
|
||||||
|
: [[hx, 0], [hx * 0.2, -hz], [-hx, -hz * 0.78], [-hx, hz * 0.78], [hx * 0.2, hz]];
|
||||||
|
const o = sk(prism(pts, H), L, H, Wd, 0); o.position.y = c; tilt.add(o);
|
||||||
|
if (!drawn) { const st1 = box(L * 0.28, 0.02, Wd * 0.5, m.stripe); st1.position.set(-L * 0.22, top + 0.012, 0); tilt.add(st1); }
|
||||||
|
} else if (ch.shape === 'barrel') {
|
||||||
|
const rr = Math.min(Wd, H * 1.9) / 2;
|
||||||
|
const g = new T.CylinderGeometry(rr, rr, L, 18); g.rotateZ(Math.PI / 2);
|
||||||
|
const o = sk(g, L, H, Wd, 0); o.position.y = c + rr; tilt.add(o);
|
||||||
|
for (const sx of [-1, 1]) { const cap = cyl(rr * 0.5, rr * 0.5, 0.07, m.hub, 14); cap.rotation.z = Math.PI / 2; cap.position.set(sx * L / 2, c + rr, 0); tilt.add(cap); }
|
||||||
|
for (const bx of [-0.22, 0.22]) { const band = cyl(rr * 1.03, rr * 1.03, 0.05, m.dark, 18); band.rotation.z = Math.PI / 2; band.position.set(bx * L, c + rr, 0); tilt.add(band); }
|
||||||
|
top = c + rr * 2;
|
||||||
|
} else if (ch.shape === 'saucer') {
|
||||||
|
const o = sk(new T.CylinderGeometry(1, 1, 1, 22), L, H, Wd, 0);
|
||||||
|
o.scale.set(L / 2, H, Wd / 2); o.position.y = c + H / 2; tilt.add(o);
|
||||||
|
const ring = new T.Mesh(new T.TorusGeometry(1, 0.035, 8, 30), accent);
|
||||||
|
ring.rotation.x = Math.PI / 2; ring.scale.set(L / 2 * 1.02, Wd / 2 * 1.02, 1); ring.position.y = c + H * 0.72; tilt.add(ring);
|
||||||
|
top = c + H;
|
||||||
|
} else if (ch.shape === 'plow') {
|
||||||
|
const bl = L * 0.84, bw = Wd * 0.9;
|
||||||
|
const o = sk(new T.BoxGeometry(bl, H, bw), bl, H, bw, -H / 2); o.position.set(-L * 0.08, c + H / 2, 0); tilt.add(o);
|
||||||
|
const plate = box(0.09, H * 1.35, Wd * 1.1, m.steel); plate.position.set(L / 2 - 0.04, c + H * 0.62, 0); plate.rotation.z = -0.32; tilt.add(plate);
|
||||||
|
const edge = box(0.12, 0.1, Wd * 1.12, m.stripe); edge.position.set(L / 2 + 0.16, c * 0.4, 0); tilt.add(edge);
|
||||||
|
top = c + H;
|
||||||
|
} else if (ch.shape === 'frame') {
|
||||||
|
const bm = 0.07;
|
||||||
|
for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
|
||||||
|
const post = box(bm, H, bm, m.dark); post.position.set(sx * (L / 2 - bm / 2), c + H / 2, sz * (Wd / 2 - bm / 2)); tilt.add(post);
|
||||||
|
}
|
||||||
|
for (const y of [c + bm / 2, c + H - bm / 2]) {
|
||||||
|
for (const sz of [-1, 1]) { const rail = box(L, bm, bm, m.dark); rail.position.set(0, y, sz * (Wd / 2 - bm / 2)); tilt.add(rail); }
|
||||||
|
for (const sx of [-1, 1]) { const rail = box(bm, bm, Wd, m.dark); rail.position.set(sx * (L / 2 - bm / 2), y, 0); tilt.add(rail); }
|
||||||
|
}
|
||||||
|
const pan = sk(new T.BoxGeometry(L * 0.9, 0.09, Wd * 0.86), L * 0.9, 0.09, Wd * 0.86, -0.045);
|
||||||
|
pan.position.y = c + 0.07; tilt.add(pan);
|
||||||
|
top = c + H;
|
||||||
} else {
|
} else {
|
||||||
const o = sk(new T.BoxGeometry(L, H, Wd), L, H, Wd, -H / 2); o.position.y = c + H / 2; tilt.add(o);
|
const o = sk(new T.BoxGeometry(L, H, Wd), L, H, Wd, -H / 2); o.position.y = c + H / 2; tilt.add(o);
|
||||||
if (!drawn) {
|
if (!drawn) {
|
||||||
@@ -243,22 +320,81 @@
|
|||||||
const s2 = box(0.06, H * 0.6, Wd * 1.002, m.stripe); s2.position.set(-L / 2 + 0.08, c + H / 2, 0); tilt.add(s2);
|
const s2 = box(0.06, H * 0.6, Wd * 1.002, m.stripe); s2.position.set(-L / 2 + 0.08, c + H / 2, 0); tilt.add(s2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.top = top;
|
// look extras: raised cab with window slit, eye bumps (like the portraits)
|
||||||
|
if (look.cab) {
|
||||||
// armour plates (sides + rear), bolts
|
const cw = L * 0.4, chh = H * 0.62, cd = Wd * 0.64;
|
||||||
if (armour) {
|
const cab = sk(new T.BoxGeometry(cw, chh, cd), cw, chh, cd, -chh / 2); cab.position.set(-L * 0.16, top + chh / 2, 0); tilt.add(cab);
|
||||||
for (const sz of [-1, 1]) {
|
const win = box(0.02, chh * 0.25, cd * 0.8, m.dark); win.position.set(-L * 0.16 + cw / 2 + 0.005, top + chh * 0.62, 0); tilt.add(win);
|
||||||
const p = drawn ? sk(new T.BoxGeometry(L * 0.9, H * 0.78, 0.05), L * 0.9, H * 0.78, 0.05, -H * 0.39) : box(L * 0.9, H * 0.78, 0.05, armour);
|
top += chh;
|
||||||
p.position.set(0, c + H * 0.42, sz * (Wd / 2 + 0.028)); tilt.add(p);
|
|
||||||
for (const bx of [-0.36, 0, 0.36]) { const b = cyl(0.025, 0.025, 0.03, m.dark, 8); b.rotation.x = Math.PI / 2; b.position.set(bx * L, c + H * 0.55, sz * (Wd / 2 + 0.06)); tilt.add(b); }
|
|
||||||
}
|
|
||||||
const r = box(0.05, H * 0.78, Wd * 0.95, armour); r.position.set(-L / 2 - 0.028, c + H * 0.42, 0); tilt.add(r);
|
|
||||||
}
|
}
|
||||||
|
if (look.bumps) {
|
||||||
|
for (const sz of [-1, 1]) {
|
||||||
|
const b = sk(new T.SphereGeometry(1, 16, 8, 0, Math.PI * 2, 0, Math.PI / 2), 2, 1, 2, 0);
|
||||||
|
b.scale.set(0.13, 0.11, 0.13); b.position.set(L * 0.18, top - (ch.shape === 'wedge' ? H * 0.45 : 0), sz * Wd * 0.26); tilt.add(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.top = top;
|
||||||
|
mark('chassis');
|
||||||
|
|
||||||
|
// armour: every kind looks clearly different, so swapping it shows in the workshop preview
|
||||||
|
if (armour) {
|
||||||
|
const asty = (ar && ar.style) || 'plates';
|
||||||
|
const sideX = Wd / 2 + 0.028;
|
||||||
|
if (asty === 'mesh') { // open wire grille
|
||||||
|
for (const sz of [-1, 1]) {
|
||||||
|
for (const y of [c + H * 0.1, c + H * 0.74]) { const rail = box(L * 0.9, 0.05, 0.04, armour); rail.position.set(0, y, sz * sideX); tilt.add(rail); }
|
||||||
|
for (let k = 0; k < 6; k++) { const bar = box(0.045, H * 0.64, 0.04, armour); bar.position.set((k / 5 - 0.5) * L * 0.86, c + H * 0.42, sz * sideX); tilt.add(bar); }
|
||||||
|
}
|
||||||
|
} else if (asty === 'bumper') { // fat rubber buffers around the body
|
||||||
|
for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
|
||||||
|
const b = new T.Mesh(new T.SphereGeometry(0.14, 12, 9), armour);
|
||||||
|
b.scale.set(1, 0.78, 1); b.castShadow = true;
|
||||||
|
b.position.set(sx * L * 0.4, c + H * 0.42, sz * (Wd / 2 + 0.055)); tilt.add(b);
|
||||||
|
}
|
||||||
|
for (const sx of [-1, 1]) { const b = box(0.11, H * 0.52, Wd * 0.78, armour); b.position.set(sx * (L / 2 + 0.055), c + H * 0.42, 0); tilt.add(b); }
|
||||||
|
} else if (asty === 'tiles') { // ceramic tiles with gaps
|
||||||
|
for (const sz of [-1, 1]) for (let kx = 0; kx < 4; kx++) for (let ky = 0; ky < 2; ky++) {
|
||||||
|
const tl = box(L * 0.19, H * 0.32, 0.05, armour);
|
||||||
|
tl.position.set((kx / 3 - 0.5) * L * 0.74, c + H * (0.26 + ky * 0.36), sz * sideX); tilt.add(tl);
|
||||||
|
}
|
||||||
|
const rr = box(0.05, H * 0.72, Wd * 0.9, armour); rr.position.set(-L / 2 - 0.028, c + H * 0.42, 0); tilt.add(rr);
|
||||||
|
} else { // solid plates (steel / titanium / hardox / spiked)
|
||||||
|
for (const sz of [-1, 1]) {
|
||||||
|
const p = drawn ? sk(new T.BoxGeometry(L * 0.9, H * 0.78, 0.05), L * 0.9, H * 0.78, 0.05, -H * 0.39) : box(L * 0.9, H * 0.78, 0.05, armour);
|
||||||
|
p.position.set(0, c + H * 0.42, sz * (Wd / 2 + 0.028)); tilt.add(p);
|
||||||
|
for (const bx of [-0.36, 0, 0.36]) { const b = cyl(0.025, 0.025, 0.03, m.dark, 8); b.rotation.x = Math.PI / 2; b.position.set(bx * L, c + H * 0.55, sz * (Wd / 2 + 0.06)); tilt.add(b); }
|
||||||
|
if (asty === 'spike') for (let k = 0; k < 4; k++) {
|
||||||
|
const sp = cyl(0.001, 0.055, 0.18, m.stripe, 8);
|
||||||
|
sp.rotation.x = sz * Math.PI / 2;
|
||||||
|
sp.position.set((k / 3 - 0.5) * L * 0.62, c + H * 0.5, sz * (Wd / 2 + 0.12)); tilt.add(sp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const r = box(0.05, H * 0.78, Wd * 0.95, armour); r.position.set(-L / 2 - 0.028, c + H * 0.42, 0); tilt.add(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mark('armour');
|
||||||
|
|
||||||
// wheels
|
// wheels
|
||||||
out.wheels = [];
|
out.wheels = [];
|
||||||
const side = Wd / 2 + (armour ? 0.13 : 0.08);
|
const side = Wd / 2 + (armour ? 0.13 : 0.08);
|
||||||
if (wh.kind === 'tracks') {
|
if (wh.kind === 'hover') {
|
||||||
|
// air skirt: glowing ring, no wheels
|
||||||
|
const skirt = new T.Mesh(new T.CylinderGeometry(Wd * 0.6, Wd * 0.72, 0.14, 22),
|
||||||
|
new T.MeshStandardMaterial({ color: 0x223040, metalness: 0.5, roughness: 0.5, emissive: paint.accent, emissiveIntensity: 0.3 }));
|
||||||
|
skirt.scale.x = L / Wd * 0.92; skirt.position.set(-L * 0.04, 0.09, 0); skirt.castShadow = true; tilt.add(skirt);
|
||||||
|
const glow = new T.Mesh(new T.CylinderGeometry(Wd * 0.5, Wd * 0.5, 0.04, 22),
|
||||||
|
new T.MeshBasicMaterial({ color: paint.accent, transparent: true, opacity: 0.5, blending: T.AdditiveBlending, depthWrite: false }));
|
||||||
|
glow.scale.x = L / Wd * 0.92; glow.position.set(-L * 0.04, 0.02, 0); tilt.add(glow);
|
||||||
|
out.wheelR = 0.16;
|
||||||
|
} else if (wh.kind === 'drum') {
|
||||||
|
// one wide roller drum + two small rear casters
|
||||||
|
const R = (c + H) / 2 + 0.08;
|
||||||
|
const dr = cyl(R, R, Wd * 0.92, m.rubber, 20); dr.rotation.x = Math.PI / 2; dr.position.set(-L * 0.04, R, 0); tilt.add(dr); out.wheels.push(dr);
|
||||||
|
const hub = cyl(R * 0.4, R * 0.4, Wd * 0.94, m.hub, 12); hub.rotation.x = Math.PI / 2; hub.position.set(-L * 0.04, R, 0); tilt.add(hub);
|
||||||
|
for (const sz of [-1, 1]) { const w = new T.Group(); w.position.set(-L * 0.42, 0.13, sz * side); const t = cyl(0.13, 0.13, 0.14, m.hub, 10); t.rotation.x = Math.PI / 2; w.add(t); tilt.add(w); out.wheels.push(w); }
|
||||||
|
out.wheelR = R;
|
||||||
|
} else if (wh.kind === 'tracks' || look.tracksLook) {
|
||||||
for (const sz of [-1, 1]) {
|
for (const sz of [-1, 1]) {
|
||||||
const t = box(L * 1.02, 0.3, 0.2, m.track); t.position.set(0, 0.15, sz * side); tilt.add(t);
|
const t = box(L * 1.02, 0.3, 0.2, m.track); t.position.set(0, 0.15, sz * side); tilt.add(t);
|
||||||
for (const bx of [-0.42, 0.42]) { const w = cyl(0.15, 0.15, 0.21, m.hub, 14); w.rotation.x = Math.PI / 2; w.position.set(bx * L, 0.15, sz * side); tilt.add(w); }
|
for (const bx of [-0.42, 0.42]) { const w = cyl(0.15, 0.15, 0.21, m.hub, 14); w.rotation.x = Math.PI / 2; w.position.set(bx * L, 0.15, sz * side); tilt.add(w); }
|
||||||
@@ -274,61 +410,129 @@
|
|||||||
out.wheelR = r;
|
out.wheelR = r;
|
||||||
} else {
|
} else {
|
||||||
for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
|
for (const sx of [-1, 1]) for (const sz of [-1, 1]) {
|
||||||
const w = new T.Group(); w.position.set(sx * L * 0.32, 0.16, sz * side);
|
const wr = 0.16 * ws;
|
||||||
const tyre = cyl(0.16, 0.16, 0.12, m.rubber, 16); tyre.rotation.x = Math.PI / 2; w.add(tyre);
|
const w = new T.Group(); w.position.set(sx * L * 0.32, wr, sz * (side + (ws - 1) * 0.08));
|
||||||
const hub = cyl(0.07, 0.07, 0.13, m.hub, 8); hub.rotation.x = Math.PI / 2; w.add(hub);
|
const tyre = cyl(wr, wr, 0.12 * ws, m.rubber, 16); tyre.rotation.x = Math.PI / 2; w.add(tyre);
|
||||||
|
const hub = cyl(wr * 0.44, wr * 0.44, 0.13 * ws, m.hub, 8); hub.rotation.x = Math.PI / 2; w.add(hub);
|
||||||
tilt.add(w); out.wheels.push(w);
|
tilt.add(w); out.wheels.push(w);
|
||||||
}
|
}
|
||||||
out.wheelR = 0.16;
|
out.wheelR = 0.16 * ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
// headlights + antenna
|
mark('wheels');
|
||||||
for (const sz of [-0.3, 0.3]) { const l = box(0.03, 0.05, 0.1, m.glowW); l.position.set(L / 2 + 0.005, c + H * 0.62, sz * Wd); tilt.add(l); }
|
|
||||||
|
// headlights, or glowing eyes for opponents with a look
|
||||||
|
if (look.eyes) {
|
||||||
|
const eyeMat = new T.MeshStandardMaterial({ color: look.eyes, emissive: look.eyes, emissiveIntensity: 2.2 });
|
||||||
|
for (const sz of [-1, 1]) {
|
||||||
|
const e = new T.Mesh(new T.SphereGeometry(0.055, 12, 8), eyeMat);
|
||||||
|
e.position.set(L / 2 + 0.01, c + H * (ch.shape === 'wedge' ? 0.3 : 0.7), sz * Wd * 0.24); tilt.add(e);
|
||||||
|
}
|
||||||
|
} else for (const sz of [-0.3, 0.3]) { const l = box(0.03, 0.05, 0.1, m.glowW); l.position.set(L / 2 + 0.005, c + H * 0.62, sz * Wd); tilt.add(l); }
|
||||||
const ant = cyl(0.01, 0.01, 0.45, m.dark, 6); ant.position.set(-L / 2 + 0.12, top + 0.22, Wd / 2 - 0.12); tilt.add(ant);
|
const ant = cyl(0.01, 0.01, 0.45, m.dark, 6); ant.position.set(-L / 2 + 0.12, top + 0.22, Wd / 2 - 0.12); tilt.add(ant);
|
||||||
const tip = new T.Mesh(new T.SphereGeometry(0.035, 8, 6), new T.MeshStandardMaterial({ color: paint.accent, emissive: paint.accent, emissiveIntensity: 0.9 }));
|
const tip = new T.Mesh(new T.SphereGeometry(0.035, 8, 6), new T.MeshStandardMaterial({ color: paint.accent, emissive: paint.accent, emissiveIntensity: 0.9 }));
|
||||||
tip.position.set(-L / 2 + 0.12, top + 0.46, Wd / 2 - 0.12); tilt.add(tip);
|
tip.position.set(-L / 2 + 0.12, top + 0.46, Wd / 2 - 0.12); tilt.add(tip);
|
||||||
|
|
||||||
|
mark('lights');
|
||||||
|
|
||||||
// main weapon (front = +x)
|
// main weapon (front = +x)
|
||||||
const w = st.weapon;
|
const w = st.weapon;
|
||||||
if (w) {
|
if (w) {
|
||||||
|
const WS = m.wsteel, ED = m.wedge, HZ = m.stripe; // weapon steel, edge, hazard stripe
|
||||||
if (w.type === 'wedge') {
|
if (w.type === 'wedge') {
|
||||||
const p = box(0.55, 0.04, Wd * 1.05, m.steel); p.position.set(L / 2 + 0.22, c * 0.5 + 0.08, 0); p.rotation.z = -0.42; tilt.add(p);
|
if (w.id === 'lance') {
|
||||||
|
// long spike lance
|
||||||
|
const shaft = cyl(0.05, 0.05, 0.85, m.dark, 8); shaft.rotation.z = Math.PI / 2; shaft.position.set(L / 2 + 0.42, c + H * 0.4, 0); tilt.add(shaft);
|
||||||
|
const tip = cyl(0.001, 0.13, 0.42, HZ, 12); tip.rotation.z = -Math.PI / 2; tip.position.set(L / 2 + 0.95, c + H * 0.4, 0); tilt.add(tip);
|
||||||
|
} else {
|
||||||
|
// short ramp plate at the front (as before - stays close to the body so it does not poke through)
|
||||||
|
const p = box(0.5, 0.05, Wd * 1.05, ED); p.position.set(L / 2 + 0.18, c * 0.5 + 0.08, 0); p.rotation.z = -0.42; tilt.add(p);
|
||||||
|
const edge = box(0.12, 0.16, Wd * 1.06, HZ); edge.position.set(L / 2 + 0.34, 0.02, 0); tilt.add(edge);
|
||||||
|
}
|
||||||
} else if (w.type === 'flipper') {
|
} else if (w.type === 'flipper') {
|
||||||
const piv = new T.Group(); piv.position.set(L / 2 - 0.08, c + H * 0.3, 0); tilt.add(piv);
|
const lf = w.id === 'launcher' ? 1.3 : 1, wf = w.id === 'launcher' ? 1.12 : 1;
|
||||||
const p = box(0.62, 0.05, Wd * 0.92, m.steel); p.position.x = 0.31; piv.add(p);
|
const piv = new T.Group(); piv.position.set(L / 2 - 0.1, c + H * 0.22, 0); tilt.add(piv);
|
||||||
const s = box(0.6, 0.012, Wd * 0.3, accent); s.position.set(0.31, 0.03, 0); piv.add(s);
|
const p = box(0.78 * lf, 0.09, Wd * 0.95 * wf, WS); p.position.x = 0.39 * lf; piv.add(p);
|
||||||
|
const s = box(0.78 * lf, 0.03, Wd * 0.4, accent); s.position.set(0.39 * lf, 0.06, 0); piv.add(s);
|
||||||
|
const edge = box(0.12, 0.14, Wd * 0.98 * wf, HZ); edge.position.set(0.78 * lf, 0, 0); piv.add(edge);
|
||||||
|
const pist = cyl(0.05, 0.05, 0.4, m.hub, 8); pist.rotation.z = 1.0; pist.position.set(0.2, -0.16, 0); tilt.add(pist); // ram
|
||||||
out.flipper = piv;
|
out.flipper = piv;
|
||||||
} else if (w.type === 'hammer') {
|
} else if (w.type === 'hammer') {
|
||||||
const piv = new T.Group(); piv.position.set(-L * 0.08, top + 0.06, 0); tilt.add(piv);
|
const post = box(0.16, 0.26, 0.24, m.dark); post.position.set(-L * 0.1, top + 0.11, 0); tilt.add(post);
|
||||||
const post = box(0.12, 0.14, 0.18, m.dark); post.position.set(-L * 0.08, top + 0.03, 0); tilt.add(post);
|
const piv = new T.Group(); piv.position.set(-L * 0.1, top + 0.16, 0); tilt.add(piv);
|
||||||
const arm = box(L * 0.72, 0.07, 0.07, m.dark); arm.position.x = L * 0.36; piv.add(arm);
|
const arm = box(L * 0.82, 0.1, 0.1, m.dark); arm.position.x = L * 0.41; piv.add(arm);
|
||||||
const head = box(0.1, 0.34, 0.06, m.steel); head.position.set(L * 0.72, -0.1, 0); piv.add(head);
|
if (w.id === 'mace') {
|
||||||
const back = box(0.14, 0.12, 0.12, accent); back.position.set(L * 0.72, 0.08, 0); piv.add(back);
|
const ball = new T.Mesh(new T.SphereGeometry(0.24, 14, 10), WS); ball.castShadow = true; ball.position.set(L * 0.82, -0.05, 0); piv.add(ball);
|
||||||
|
for (let k = 0; k < 6; k++) { const a = k / 6 * Math.PI * 2; const sp = box(0.16, 0.07, 0.07, HZ); sp.position.set(L * 0.82 + Math.cos(a) * 0.26, -0.05, Math.sin(a) * 0.26); sp.rotation.y = -a; piv.add(sp); }
|
||||||
|
} else {
|
||||||
|
const head = box(0.26, 0.42, 0.26, WS); head.position.set(L * 0.82, -0.12, 0); piv.add(head); // big mallet head
|
||||||
|
const face = box(0.1, 0.44, 0.28, HZ); face.position.set(L * 0.82 + 0.17, -0.12, 0); piv.add(face);
|
||||||
|
const spike = box(0.18, 0.12, 0.12, accent); spike.position.set(L * 0.82, 0.12, 0); piv.add(spike);
|
||||||
|
}
|
||||||
out.hammer = piv;
|
out.hammer = piv;
|
||||||
} else if (w.type === 'saw') {
|
} else if (w.type === 'saw') {
|
||||||
const arm = box(0.35, 0.08, 0.08, m.dark); arm.position.set(L / 2 + 0.05, c + H * 0.55, 0); tilt.add(arm);
|
const arm = box(0.4, 0.12, 0.12, m.dark); arm.position.set(L / 2 + 0.06, c + H * 0.5, 0); tilt.add(arm);
|
||||||
const g = new T.Group(); g.position.set(L / 2 + 0.2, c + H * 0.55, 0); tilt.add(g);
|
if (w.id === 'drill') {
|
||||||
const d = cyl(0.3, 0.3, 0.025, m.steel, 28); d.rotation.x = Math.PI / 2; g.add(d);
|
// conical auger drill, spins on its forward (x) axis
|
||||||
for (let k = 0; k < 14; k++) { const t = box(0.07, 0.04, 0.026, m.steel); const a = k / 14 * Math.PI * 2; t.position.set(Math.cos(a) * 0.31, Math.sin(a) * 0.31, 0); t.rotation.z = a + 0.6; g.add(t); }
|
const g = new T.Group(); g.position.set(L / 2 + 0.42, c + H * 0.5, 0); tilt.add(g);
|
||||||
const hub = cyl(0.06, 0.06, 0.04, accent, 10); hub.rotation.x = Math.PI / 2; g.add(hub);
|
const cone = cyl(0.001, 0.2, 0.72, WS, 14); cone.rotation.z = -Math.PI / 2; cone.castShadow = true; g.add(cone);
|
||||||
out.saw = g;
|
for (let k = 0; k < 3; k++) { const fl = box(0.6, 0.03, 0.06, HZ); fl.position.x = -0.1; fl.rotation.x = k / 3 * Math.PI * 2; g.add(fl); }
|
||||||
|
out.saw = g; out.sawAxis = 'x';
|
||||||
|
} else {
|
||||||
|
const guard = new T.Mesh(new T.TorusGeometry(0.42, 0.05, 8, 20, Math.PI), accent); // orange guard over the top
|
||||||
|
guard.position.set(L / 2 + 0.28, c + H * 0.5, 0); tilt.add(guard);
|
||||||
|
const g = new T.Group(); g.position.set(L / 2 + 0.28, c + H * 0.5, 0); tilt.add(g);
|
||||||
|
const d = cyl(0.38, 0.38, 0.04, WS, 32); d.rotation.x = Math.PI / 2; g.add(d);
|
||||||
|
for (let k = 0; k < 16; k++) { const t = box(0.11, 0.06, 0.05, WS); const a = k / 16 * Math.PI * 2; t.position.set(Math.cos(a) * 0.4, Math.sin(a) * 0.4, 0); t.rotation.z = a + 0.6; g.add(t); }
|
||||||
|
const hub = cyl(0.09, 0.09, 0.07, accent, 12); hub.rotation.x = Math.PI / 2; g.add(hub);
|
||||||
|
out.saw = g;
|
||||||
|
}
|
||||||
} else if (w.type === 'spinner') {
|
} else if (w.type === 'spinner') {
|
||||||
const post = cyl(0.07, 0.07, 0.25, m.dark, 10); post.position.set(L / 2 + 0.02, c + H * 0.35, 0); tilt.add(post);
|
if (w.id === 'drum') {
|
||||||
const g = new T.Group(); g.position.set(L / 2 + 0.02, c + H * 0.32, 0); tilt.add(g);
|
const post = cyl(0.1, 0.12, 0.3, m.dark, 12); post.position.set(L / 2 + 0.02, c + H * 0.32, 0); tilt.add(post);
|
||||||
const bar = box(1.25, 0.07, 0.16, m.steel); g.add(bar);
|
const g = new T.Group(); g.position.set(L / 2 + 0.12, c + H * 0.34, 0); tilt.add(g);
|
||||||
for (const sx of [-1, 1]) { const t = box(0.1, 0.09, 0.2, accent); t.position.x = sx * 0.6; g.add(t); }
|
const drum = cyl(0.3, 0.3, 0.52, WS, 20); drum.castShadow = true; g.add(drum);
|
||||||
out.spinner = g;
|
for (const sx of [-1, 1]) { const tb = box(0.14, 0.54, 0.12, HZ); tb.position.set(sx * 0.3, 0, 0); g.add(tb); }
|
||||||
|
out.spinner = g;
|
||||||
|
} else {
|
||||||
|
const post = cyl(0.1, 0.12, 0.3, m.dark, 12); post.position.set(L / 2 + 0.04, c + H * 0.32, 0); tilt.add(post);
|
||||||
|
const g = new T.Group(); g.position.set(L / 2 + 0.04, c + H * 0.3, 0); tilt.add(g);
|
||||||
|
const bar = box(1.5, 0.12, 0.22, WS); g.add(bar);
|
||||||
|
const stripe = box(1.5, 0.13, 0.08, HZ); g.add(stripe);
|
||||||
|
for (const sx of [-1, 1]) { const t = box(0.18, 0.16, 0.32, accent); t.position.x = sx * 0.72; g.add(t); }
|
||||||
|
out.spinner = g;
|
||||||
|
}
|
||||||
|
} else if (w.type === 'lifter') {
|
||||||
|
const piv = new T.Group(); piv.position.set(L / 2 - 0.08, c + H * 0.16, 0); tilt.add(piv);
|
||||||
|
const bar = box(0.12, 0.09, Wd * 0.95, m.dark); bar.position.set(0.06, 0, 0); piv.add(bar);
|
||||||
|
for (const sz of [-1, 1]) {
|
||||||
|
const prong = box(0.85, 0.07, Wd * 0.26, WS); prong.position.set(0.46, 0, sz * Wd * 0.3); piv.add(prong);
|
||||||
|
const tip = box(0.16, 0.1, Wd * 0.28, HZ); tip.position.set(0.9, 0.015, sz * Wd * 0.3); piv.add(tip);
|
||||||
|
}
|
||||||
|
out.flipper = piv;
|
||||||
|
} else if (w.type === 'vspinner') {
|
||||||
|
const arm = box(0.3, 0.14, 0.14, m.dark); arm.position.set(L / 2 + 0.02, c + H * 0.45, 0); tilt.add(arm);
|
||||||
|
const g = new T.Group(); g.position.set(L / 2 + 0.32, c + H * 0.42, 0); tilt.add(g);
|
||||||
|
const d = cyl(0.45, 0.45, 0.11, WS, 26); d.rotation.x = Math.PI / 2; g.add(d);
|
||||||
|
for (let k = 0; k < 4; k++) {
|
||||||
|
const tth = box(0.22, 0.17, 0.14, HZ); const a = k / 4 * Math.PI * 2;
|
||||||
|
tth.position.set(Math.cos(a) * 0.45, Math.sin(a) * 0.45, 0); tth.rotation.z = a; g.add(tth);
|
||||||
|
}
|
||||||
|
const hub = cyl(0.1, 0.1, 0.14, accent, 12); hub.rotation.x = Math.PI / 2; g.add(hub);
|
||||||
|
out.vspin = g;
|
||||||
} else if (w.type === 'crusher') {
|
} else if (w.type === 'crusher') {
|
||||||
out.jaws = [];
|
out.jaws = [];
|
||||||
for (const sz of [-1, 1]) {
|
for (const sz of [-1, 1]) {
|
||||||
const piv = new T.Group(); piv.position.set(L / 2 - 0.02, c + H * 0.45, sz * Wd * 0.34); tilt.add(piv);
|
const piv = new T.Group(); piv.position.set(L / 2 - 0.02, c + H * 0.45, sz * Wd * 0.32); tilt.add(piv);
|
||||||
const j = box(0.58, 0.14, 0.08, m.steel); j.position.x = 0.29; piv.add(j);
|
const j = box(0.68, 0.2, 0.14, WS); j.position.x = 0.34; piv.add(j);
|
||||||
const tooth = box(0.08, 0.14, 0.14, accent); tooth.position.set(0.56, 0, -sz * 0.05); piv.add(tooth);
|
for (let k = 0; k < 3; k++) { const tooth = box(0.1, 0.18, 0.14, accent); tooth.position.set(0.3 + k * 0.18, -sz * 0.02, -sz * 0.07); tooth.rotation.z = -sz * 0.25; piv.add(tooth); }
|
||||||
piv.userData.side = sz; out.jaws.push(piv);
|
piv.userData.side = sz; out.jaws.push(piv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark('weapon');
|
||||||
|
|
||||||
// tower on top
|
// tower on top
|
||||||
const tw = st.tower;
|
const tw = st.tower;
|
||||||
if (tw) {
|
if (tw) {
|
||||||
@@ -337,9 +541,12 @@
|
|||||||
if (tw.type === 'flamer') {
|
if (tw.type === 'flamer') {
|
||||||
const tank = cyl(0.08, 0.08, 0.26, new T.MeshStandardMaterial({ color: 0xc0392b, metalness: 0.4, roughness: 0.4 }), 12); tank.position.set(-0.08, 0.25, 0); g.add(tank);
|
const tank = cyl(0.08, 0.08, 0.26, new T.MeshStandardMaterial({ color: 0xc0392b, metalness: 0.4, roughness: 0.4 }), 12); tank.position.set(-0.08, 0.25, 0); g.add(tank);
|
||||||
const n = cyl(0.045, 0.06, 0.42, m.steel, 10); n.rotation.z = -Math.PI / 2; n.position.set(0.24, 0.18, 0); g.add(n);
|
const n = cyl(0.045, 0.06, 0.42, m.steel, 10); n.rotation.z = -Math.PI / 2; n.position.set(0.24, 0.18, 0); g.add(n);
|
||||||
const f = new T.Mesh(new T.ConeGeometry(0.42, 2.6, 14, 1, true), M.flame);
|
const f = new T.Group(); f.visible = false; g.add(f);
|
||||||
f.rotation.z = Math.PI / 2; f.position.set(0.45 + 1.3, 0.18, 0); f.visible = false; g.add(f);
|
const outer = new T.Mesh(new T.ConeGeometry(0.44, 2.7, 16, 1, true), M.flame);
|
||||||
out.flame = f;
|
outer.rotation.z = Math.PI / 2; outer.position.set(0.45 + 1.35, 0.18, 0); f.add(outer);
|
||||||
|
const core = new T.Mesh(new T.ConeGeometry(0.2, 1.5, 12, 1, true), M.flameCore);
|
||||||
|
core.rotation.z = Math.PI / 2; core.position.set(0.45 + 0.75, 0.18, 0); f.add(core);
|
||||||
|
out.flame = f; out.flameParts = [outer, core];
|
||||||
} else if (tw.type === 'minigun') {
|
} else if (tw.type === 'minigun') {
|
||||||
const hous = box(0.22, 0.16, 0.2, accent); hous.position.y = 0.2; g.add(hous);
|
const hous = box(0.22, 0.16, 0.2, accent); hous.position.y = 0.2; g.add(hous);
|
||||||
const brl = new T.Group(); brl.position.set(0.1, 0.2, 0); g.add(brl);
|
const brl = new T.Group(); brl.position.set(0.1, 0.2, 0); g.add(brl);
|
||||||
@@ -347,12 +554,42 @@
|
|||||||
out.gun = brl;
|
out.gun = brl;
|
||||||
const fl = new T.Mesh(new T.SphereGeometry(0.09, 8, 6), new T.MeshBasicMaterial({ color: 0xffd060, transparent: true, blending: T.AdditiveBlending, depthWrite: false }));
|
const fl = new T.Mesh(new T.SphereGeometry(0.09, 8, 6), new T.MeshBasicMaterial({ color: 0xffd060, transparent: true, blending: T.AdditiveBlending, depthWrite: false }));
|
||||||
fl.position.set(0.62, 0.2, 0); fl.visible = false; g.add(fl); out.muzzle = fl;
|
fl.position.set(0.62, 0.2, 0); fl.visible = false; g.add(fl); out.muzzle = fl;
|
||||||
|
} else if (tw.type === 'zapper') {
|
||||||
|
const coil = cyl(0.1, 0.13, 0.22, m.dark, 12); coil.position.y = 0.2; g.add(coil);
|
||||||
|
for (let k = 0; k < 3; k++) { const ring = new T.Mesh(new T.TorusGeometry(0.1, 0.018, 6, 14), accent); ring.rotation.x = Math.PI / 2; ring.position.y = 0.14 + k * 0.07; g.add(ring); }
|
||||||
|
const rod = cyl(0.022, 0.022, 0.34, m.steel, 8); rod.rotation.z = -Math.PI / 2; rod.position.set(0.2, 0.3, 0); g.add(rod);
|
||||||
|
const ball = new T.Mesh(new T.SphereGeometry(0.06, 10, 8), new T.MeshStandardMaterial({ color: 0x9fd8ff, emissive: 0x3aa0ff, emissiveIntensity: 1.6 }));
|
||||||
|
ball.position.set(0.38, 0.3, 0); g.add(ball);
|
||||||
|
const arc = new T.Mesh(new T.ConeGeometry(0.13, 1.5, 8, 1, true), M.arc);
|
||||||
|
arc.rotation.z = -Math.PI / 2; arc.position.set(1.1, 0.3, 0); arc.visible = false; g.add(arc);
|
||||||
|
out.gun = coil; out.muzzle = ball; out.flame = arc; // reuse the beam slots
|
||||||
|
} else if (tw.type === 'mortar') {
|
||||||
|
const base2 = cyl(0.14, 0.16, 0.1, m.dark, 12); base2.position.y = 0.14; g.add(base2);
|
||||||
|
const tube = cyl(0.11, 0.13, 0.52, m.steel, 14); tube.position.set(-0.05, 0.36, 0); tube.rotation.z = 0.5; g.add(tube);
|
||||||
|
const mouth = cyl(0.13, 0.13, 0.05, accent, 14); mouth.position.set(0.1, 0.58, 0); mouth.rotation.z = 0.5; g.add(mouth);
|
||||||
|
for (const sz of [-1, 1]) { const leg = cyl(0.02, 0.02, 0.3, m.dark, 6); leg.position.set(0.12, 0.17, sz * 0.1); leg.rotation.z = -0.5; g.add(leg); }
|
||||||
|
} else if (tw.type === 'swarm') {
|
||||||
|
const pod = box(0.42, 0.3, 0.42, accent); pod.position.set(0.02, 0.28, 0); g.add(pod);
|
||||||
|
for (const y of [0.19, 0.3, 0.41]) for (const sz of [-0.12, 0, 0.12]) {
|
||||||
|
const tube = cyl(0.04, 0.04, 0.07, m.dark, 8); tube.rotation.z = Math.PI / 2; tube.position.set(0.23, y, sz); g.add(tube);
|
||||||
|
}
|
||||||
} else if (tw.type === 'rockets') {
|
} else if (tw.type === 'rockets') {
|
||||||
const pod = box(0.38, 0.26, 0.36, accent); pod.position.set(0.02, 0.27, 0); g.add(pod);
|
const pod = box(0.38, 0.26, 0.36, accent); pod.position.set(0.02, 0.27, 0); g.add(pod);
|
||||||
for (const [y, z] of [[0.2, -0.09], [0.2, 0.09], [0.34, -0.09], [0.34, 0.09]]) { const t = cyl(0.05, 0.05, 0.06, m.dark, 10); t.rotation.z = Math.PI / 2; t.position.set(0.22, y, z); g.add(t); }
|
for (const [y, z] of [[0.2, -0.09], [0.2, 0.09], [0.34, -0.09], [0.34, 0.09]]) { const t = cyl(0.05, 0.05, 0.06, m.dark, 10); t.rotation.z = Math.PI / 2; t.position.set(0.22, y, z); g.add(t); }
|
||||||
}
|
}
|
||||||
out.turret = g;
|
out.turret = g;
|
||||||
}
|
}
|
||||||
|
mark('tower');
|
||||||
|
|
||||||
|
// gadget: small pod on the rear deck, colour-coded by type
|
||||||
|
const gd = st.gadget;
|
||||||
|
if (gd) {
|
||||||
|
const gc = { righter: 0x40c0ff, turbo: 0xff5020, shield: 0x40e0c0, repair: 0x50e060, emp: 0xc060ff }[gd.type] || 0xffffff;
|
||||||
|
const pod = box(0.24, 0.16, 0.3, m.dark); pod.position.set(-L * 0.33, top + 0.02, 0); tilt.add(pod);
|
||||||
|
const led = new T.Mesh(new T.SphereGeometry(0.05, 8, 6), new T.MeshStandardMaterial({ color: gc, emissive: gc, emissiveIntensity: 0.8, roughness: 0.4 }));
|
||||||
|
led.position.set(-L * 0.33, top + 0.12, 0); tilt.add(led);
|
||||||
|
}
|
||||||
|
mark('gadget');
|
||||||
root.traverse(o => { if (o.isMesh && !o.material.transparent) { o.castShadow = true; } });
|
root.traverse(o => { if (o.isMesh && !o.material.transparent) { o.castShadow = true; } });
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -380,11 +617,20 @@
|
|||||||
else if (w && r.cd > 0) ang = lerp(-0.25, 1.9, clamp((w.cd - 0.43 - r.cd) / 0.5, 0, 1));
|
else if (w && r.cd > 0) ang = lerp(-0.25, 1.9, clamp((w.cd - 0.43 - r.cd) / 0.5, 0, 1));
|
||||||
R.hammer.rotation.z = ang;
|
R.hammer.rotation.z = ang;
|
||||||
}
|
}
|
||||||
if (R.saw) { if (r.sawOn) R.sawA += dt * 40; R.saw.rotation.z = -R.sawA; }
|
if (R.saw) { if (r.sawOn) R.sawA += dt * 40; R.saw.rotation[R.sawAxis || 'z'] = -R.sawA; }
|
||||||
if (R.spinner) { R.spinA += dt * r.spin * 38; R.spinner.rotation.y = R.spinA; }
|
if (R.spinner) { R.spinA += dt * r.spin * 38; R.spinner.rotation.y = R.spinA; }
|
||||||
|
if (R.vspin) { R.spinA += dt * r.spin * 40; R.vspin.rotation.z = -R.spinA; }
|
||||||
if (R.jaws) for (const j of R.jaws) j.rotation.y = j.userData.side * (r.grab > 0 ? -0.18 : 0.45);
|
if (R.jaws) for (const j of R.jaws) j.rotation.y = j.userData.side * (r.grab > 0 ? -0.18 : 0.45);
|
||||||
if (R.turret) R.turret.rotation.y = -(r.turretA - r.a);
|
if (R.turret) R.turret.rotation.y = -(r.turretA - r.a);
|
||||||
if (R.flame) { R.flame.visible = r.flameOn; if (r.flameOn) { const f = 0.85 + Math.random() * 0.3; R.flame.scale.set(f, 1, f); } }
|
if (R.flame) {
|
||||||
|
const tw2 = R.st.tower, beam = r.flameOn || (tw2 && tw2.type === 'zapper' && r.gunOn);
|
||||||
|
R.flame.visible = !!beam;
|
||||||
|
if (beam) {
|
||||||
|
const f = 0.85 + Math.random() * 0.3;
|
||||||
|
R.flame.scale.set(f, 1, f);
|
||||||
|
if (R.flameParts) for (const fp of R.flameParts) { const n = 0.78 + Math.random() * 0.5; fp.scale.set(n, 0.9 + Math.random() * 0.35, n); }
|
||||||
|
}
|
||||||
|
}
|
||||||
if (R.gun) { if (r.gunOn) R.gunA += dt * 30; R.gun.rotation.x = R.gunA; R.muzzle.visible = r.gunOn && Math.random() < 0.6; }
|
if (R.gun) { if (r.gunOn) R.gunA += dt * 30; R.gun.rotation.x = R.gunA; R.muzzle.visible = r.gunOn && Math.random() < 0.6; }
|
||||||
R.flash = Math.max(0, R.flash - dt * 4);
|
R.flash = Math.max(0, R.flash - dt * 4);
|
||||||
R.body.emissive.setRGB(R.flash * 0.9, R.flash * 0.15, 0);
|
R.body.emissive.setRGB(R.flash * 0.9, R.flash * 0.15, 0);
|
||||||
@@ -392,49 +638,116 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- arena
|
// ---------------------------------------------------------------- arena
|
||||||
function buildArena(scene) {
|
// theme colours per arena (combat.js arena.theme)
|
||||||
const A = RC.ARENA, m = mats(), half = A.half;
|
const THEME = {
|
||||||
const out = {};
|
steel: { bg: 0x07090d, fog: 0x07090d, rimA: 0xff7a1a, rimB: 0x4fa8ff, hazard: 0xd33 },
|
||||||
scene.background = new T.Color(0x07090d);
|
lava: { bg: 0x0d0604, fog: 0x1a0a06, rimA: 0xff5a1a, rimB: 0xff2a10, hazard: 0xff6020 },
|
||||||
scene.fog = new T.Fog(0x07090d, 26, 60);
|
blue: { bg: 0x05080f, fog: 0x070d1a, rimA: 0x3aa0ff, rimB: 0x9a60ff, hazard: 0x40c0ff },
|
||||||
|
};
|
||||||
|
|
||||||
// lights: one shadow-casting key light + floodlight colours
|
// persistent lights (reused across arena rebuilds)
|
||||||
|
function buildArena(scene) {
|
||||||
|
const out = {};
|
||||||
scene.add(new T.HemisphereLight(0x8fa6c8, 0x1a140f, 0.55));
|
scene.add(new T.HemisphereLight(0x8fa6c8, 0x1a140f, 0.55));
|
||||||
const key = new T.DirectionalLight(0xfff1dc, 1.25);
|
const key = new T.DirectionalLight(0xfff1dc, 1.25);
|
||||||
key.position.set(6, 16, 9); key.castShadow = true;
|
key.position.set(6, 16, 9); key.castShadow = true;
|
||||||
key.shadow.mapSize.set(2048, 2048);
|
key.shadow.mapSize.set(1024, 1024); // 2048 was a big per-frame shadow pass; 1024 is plenty at this scale
|
||||||
Object.assign(key.shadow.camera, { left: -11, right: 11, top: 11, bottom: -11, near: 1, far: 40 });
|
Object.assign(key.shadow.camera, { left: -11, right: 11, top: 11, bottom: -11, near: 1, far: 50 });
|
||||||
key.shadow.bias = -0.0008;
|
key.shadow.bias = -0.0008;
|
||||||
scene.add(key);
|
scene.add(key);
|
||||||
const rimA = new T.PointLight(0xff7a1a, 1.1, 22); rimA.position.set(-9, 5, 9); scene.add(rimA);
|
const rimA = new T.PointLight(0xff7a1a, 1.1, 22); scene.add(rimA);
|
||||||
const rimB = new T.PointLight(0x4fa8ff, 0.9, 22); rimB.position.set(9, 5, -9); scene.add(rimB);
|
const rimB = new T.PointLight(0x4fa8ff, 0.9, 22); scene.add(rimB);
|
||||||
out.lights = { key, rimA, rimB, hemi: scene.children.find(o => o.isHemisphereLight) };
|
out.lights = { key, rimA, rimB, hemi: scene.children.find(o => o.isHemisphereLight) };
|
||||||
out.flashLight = new T.PointLight(0xffaa55, 0, 9); scene.add(out.flashLight);
|
out.flashLight = new T.PointLight(0xffaa55, 0, 9); scene.add(out.flashLight);
|
||||||
|
out.scene = scene; out.group = null; out.id = null;
|
||||||
|
out.rocketGeo = new T.CylinderGeometry(0.05, 0.05, 0.32, 8); out.rocketGeo.rotateZ(Math.PI / 2);
|
||||||
|
out.rocketMat = new T.MeshStandardMaterial({ color: 0xdddddd, emissive: 0x331100 });
|
||||||
|
out.rocketMeshes = [];
|
||||||
|
buildArenaGeo(out, RC.ARENA);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function disposeGroup(g) {
|
||||||
|
g.traverse(o => {
|
||||||
|
if (o.geometry) o.geometry.dispose();
|
||||||
|
if (o.material) [].concat(o.material).forEach(mm => { if (mm.map && mm.map.dispose) mm.map.dispose(); mm.dispose(); });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// (re)build all arena geometry for arena def A into a fresh group
|
||||||
|
function buildArenaGeo(out, A) {
|
||||||
|
const m = mats(), half = A.half, th = THEME[A.theme] || THEME.steel;
|
||||||
|
const scene = out.scene;
|
||||||
|
if (out.group) { scene.remove(out.group); disposeGroup(out.group); }
|
||||||
|
const group = new T.Group(); scene.add(group); out.group = group; out.id = A.id;
|
||||||
|
const scene_add = o => group.add(o);
|
||||||
|
scene.background = new T.Color(th.bg);
|
||||||
|
scene.fog = new T.Fog(th.fog, half * 3, half * 5.5);
|
||||||
|
const { key, rimA, rimB, flashLight } = out.lights;
|
||||||
|
const sc = Math.max(11, half + 3);
|
||||||
|
Object.assign(key.shadow.camera, { left: -sc, right: sc, top: sc, bottom: -sc }); key.shadow.camera.updateProjectionMatrix();
|
||||||
|
rimA.color.setHex(th.rimA); rimA.position.set(-half - 1, 5, half + 1); rimA.distance = half * 2.6;
|
||||||
|
rimB.color.setHex(th.rimB); rimB.position.set(half + 1, 5, -half - 1); rimB.distance = half * 2.6;
|
||||||
|
out.hazardCol = th.hazard;
|
||||||
|
{ const scene = { add: scene_add }; buildArenaBody(scene, out, A, m, half, th); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// arena outline (same maths as wallPush in combat.js): square, octagon or a many-sided ring
|
||||||
|
function outline(A) {
|
||||||
|
const h = A.half;
|
||||||
|
if (A.shape === 'round') return Array.from({ length: 28 }, (_, i) => { const a = i / 28 * Math.PI * 2; return [Math.cos(a) * h, Math.sin(a) * h]; });
|
||||||
|
if (A.shape === 'octagon') { const d = h * 0.67; return [[-d, -h], [d, -h], [h, -d], [h, d], [d, h], [-d, h], [-h, d], [-h, -d]]; }
|
||||||
|
return [[-h, -h], [h, -h], [h, h], [-h, h]];
|
||||||
|
}
|
||||||
|
function floorGeo(A) {
|
||||||
|
const h = A.half;
|
||||||
|
if (A.shape === 'square') return new T.PlaneGeometry(h * 2, h * 2);
|
||||||
|
const pts = outline(A), sh = new T.Shape();
|
||||||
|
sh.moveTo(pts[0][0], pts[0][1]);
|
||||||
|
for (let i = 1; i < pts.length; i++) sh.lineTo(pts[i][0], pts[i][1]);
|
||||||
|
sh.closePath();
|
||||||
|
const g = new T.ShapeGeometry(sh), pos = g.attributes.position, uv = new Float32Array(pos.count * 2);
|
||||||
|
for (let i = 0; i < pos.count; i++) { uv[i * 2] = pos.getX(i) / (h * 2) + 0.5; uv[i * 2 + 1] = pos.getY(i) / (h * 2) + 0.5; }
|
||||||
|
g.setAttribute('uv', new T.BufferAttribute(uv, 2));
|
||||||
|
return g;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildArenaBody(scene, out, A, m, half, th) {
|
||||||
// floor
|
// floor
|
||||||
const floor = new T.Mesh(new T.PlaneGeometry(half * 2, half * 2), new T.MeshStandardMaterial({ map: floorTex(), metalness: 0.55, roughness: 0.62 }));
|
const floor = new T.Mesh(floorGeo(A), new T.MeshStandardMaterial({ map: floorTex(A), metalness: 0.55, roughness: 0.62 }));
|
||||||
floor.rotation.x = -Math.PI / 2; floor.receiveShadow = true; scene.add(floor);
|
floor.rotation.x = -Math.PI / 2; floor.receiveShadow = true; scene.add(floor);
|
||||||
const outer = new T.Mesh(new T.PlaneGeometry(80, 80), new T.MeshStandardMaterial({ color: 0x0d0f13, roughness: 1 }));
|
const outer = new T.Mesh(new T.PlaneGeometry(80, 80), new T.MeshStandardMaterial({ color: 0x0d0f13, roughness: 1 }));
|
||||||
outer.rotation.x = -Math.PI / 2; outer.position.y = -0.02; outer.receiveShadow = true; scene.add(outer);
|
outer.rotation.x = -Math.PI / 2; outer.position.y = -0.02; outer.receiveShadow = true; scene.add(outer);
|
||||||
|
|
||||||
// spike walls (instanced spikes)
|
// spike walls (instanced spikes)
|
||||||
const wallMat = new T.MeshStandardMaterial({ color: 0x30343b, metalness: 0.7, roughness: 0.45 });
|
const wallMat = new T.MeshStandardMaterial({ color: 0x30343b, metalness: 0.7, roughness: 0.45 });
|
||||||
const n = Math.round(half * 2 / 0.5);
|
// ComfyGen wall panels (tex_wall.jpg) on the arena walls, if the browser lets the image into WebGL
|
||||||
const spikes = new T.InstancedMesh(new T.ConeGeometry(0.07, 0.28, 8), m.steel, n * 4);
|
const panelMat = new T.MeshStandardMaterial({ color: 0x30343b, metalness: 0.6, roughness: 0.5 });
|
||||||
|
loadTex('tex_wall.jpg', tex => { tex.wrapS = T.RepeatWrapping; tex.repeat.set(5, 1); panelMat.map = tex; panelMat.color.set(0xb0b4bc); panelMat.needsUpdate = true; });
|
||||||
|
const pts = outline(A);
|
||||||
|
let perim = 0;
|
||||||
|
for (let i = 0; i < pts.length; i++) { const a2 = pts[i], b2 = pts[(i + 1) % pts.length]; perim += Math.hypot(b2[0] - a2[0], b2[1] - a2[1]); }
|
||||||
|
const spikes = new T.InstancedMesh(new T.ConeGeometry(0.07, 0.28, 8), m.steel, Math.ceil(perim / 0.5) + pts.length + 4);
|
||||||
const dm = new T.Object3D(); let si = 0;
|
const dm = new T.Object3D(); let si = 0;
|
||||||
for (const [nx, nz] of [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
|
for (let i = 0; i < pts.length; i++) {
|
||||||
const wall = box(nz ? half * 2 + 0.5 : 0.25, 0.55, nz ? 0.25 : half * 2 + 0.5, wallMat);
|
const [x1, z1] = pts[i], [x2, z2] = pts[(i + 1) % pts.length];
|
||||||
wall.position.set(nx * (half + 0.12), 0.275, nz * (half + 0.12)); scene.add(wall);
|
const mx = (x1 + x2) / 2, mz = (z1 + z2) / 2, len = Math.hypot(x2 - x1, z2 - z1), ang = Math.atan2(z2 - z1, x2 - x1);
|
||||||
const strip = box(nz ? half * 2 + 0.5 : 0.26, 0.08, nz ? 0.26 : half * 2 + 0.5, m.stripe);
|
const d = Math.hypot(mx, mz) || 1, ox = mx / d, oz = mz / d; // outwards from the middle
|
||||||
strip.position.set(nx * (half + 0.12), 0.58, nz * (half + 0.12)); scene.add(strip);
|
const wall = box(len + 0.3, 0.55, 0.25, panelMat);
|
||||||
for (let k = 0; k < n; k++) {
|
wall.position.set(mx + ox * 0.12, 0.275, mz + oz * 0.12); wall.rotation.y = -ang; scene.add(wall);
|
||||||
const t = -half + 0.25 + k * 0.5;
|
const strip = box(len + 0.3, 0.08, 0.26, m.stripe);
|
||||||
dm.position.set(nx ? nx * (half - 0.02) : t, 0.3, nz ? nz * (half - 0.02) : t);
|
strip.position.set(mx + ox * 0.12, 0.58, mz + oz * 0.12); strip.rotation.y = -ang; scene.add(strip);
|
||||||
|
const steps = Math.max(1, Math.round(len / 0.5));
|
||||||
|
for (let k = 0; k < steps; k++) {
|
||||||
|
const f = (k + 0.5) / steps;
|
||||||
|
dm.position.set(x1 + (x2 - x1) * f - ox * 0.02, 0.3, z1 + (z2 - z1) * f - oz * 0.02);
|
||||||
dm.rotation.set(0, 0, 0);
|
dm.rotation.set(0, 0, 0);
|
||||||
if (nx) dm.rotation.z = nx > 0 ? Math.PI / 2 : -Math.PI / 2; else dm.rotation.x = nz > 0 ? -Math.PI / 2 : Math.PI / 2;
|
dm.rotation.z = Math.PI / 2; dm.rotation.y = -Math.atan2(oz, ox); // point inwards
|
||||||
dm.updateMatrix(); spikes.setMatrixAt(si++, dm.matrix);
|
dm.updateMatrix();
|
||||||
|
if (si < spikes.count) spikes.setMatrixAt(si++, dm.matrix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
spikes.count = si;
|
||||||
spikes.castShadow = true; scene.add(spikes);
|
spikes.castShadow = true; scene.add(spikes);
|
||||||
|
|
||||||
// glass + posts + floodlight rigs
|
// glass + posts + floodlight rigs
|
||||||
@@ -466,6 +779,60 @@
|
|||||||
seats.count = ci; dm.scale.set(1, 1, 1); scene.add(seats);
|
seats.count = ci; dm.scale.set(1, 1, 1); scene.add(seats);
|
||||||
|
|
||||||
// floor saws
|
// floor saws
|
||||||
|
// --- cover and floor traps (static, built once per arena) ---
|
||||||
|
const BMAT = {
|
||||||
|
pillar: new T.MeshStandardMaterial({ color: 0x4a515c, metalness: 0.5, roughness: 0.6 }),
|
||||||
|
crate: new T.MeshStandardMaterial({ color: 0x6b5634, metalness: 0.2, roughness: 0.85 }),
|
||||||
|
scrap: new T.MeshStandardMaterial({ color: 0x5a5048, metalness: 0.6, roughness: 0.8 }),
|
||||||
|
barrier: new T.MeshStandardMaterial({ color: 0x9aa0a8, metalness: 0.6, roughness: 0.5 }),
|
||||||
|
};
|
||||||
|
let bseed = 7;
|
||||||
|
const brnd = () => { bseed = (bseed * 16807) % 2147483647; return bseed / 2147483647; };
|
||||||
|
for (const b of A.blocks) {
|
||||||
|
const g = new T.Group(); g.position.set(b.x, 0, b.z); scene.add(g);
|
||||||
|
const mat = BMAT[b.kind] || BMAT.crate;
|
||||||
|
if (b.kind === 'pillar') {
|
||||||
|
const rr = Math.min(b.hw, b.hd);
|
||||||
|
const col = cyl(rr, rr * 1.12, b.h, mat, 14); col.position.y = b.h / 2; col.castShadow = true; g.add(col);
|
||||||
|
const cap = cyl(rr * 1.18, rr * 1.18, 0.12, m.dark, 14); cap.position.y = b.h; g.add(cap);
|
||||||
|
const band = cyl(rr * 1.06, rr * 1.06, 0.18, m.stripe, 14); band.position.y = b.h * 0.42; g.add(band);
|
||||||
|
} else if (b.kind === 'scrap') {
|
||||||
|
for (let k = 0; k < 5; k++) {
|
||||||
|
const w2 = b.hw * (0.5 + brnd() * 0.75), h2 = b.h * (0.35 + brnd() * 0.65), d2 = b.hd * (0.5 + brnd() * 0.75);
|
||||||
|
const p2 = box(w2, h2, d2, mat);
|
||||||
|
p2.position.set((brnd() - 0.5) * b.hw, h2 / 2, (brnd() - 0.5) * b.hd);
|
||||||
|
p2.rotation.y = brnd() * 3; p2.castShadow = true; g.add(p2);
|
||||||
|
}
|
||||||
|
} else if (b.kind === 'barrier') {
|
||||||
|
const bar = box(b.hw * 2, b.h, b.hd * 2, mat); bar.position.y = b.h / 2; bar.castShadow = true; g.add(bar);
|
||||||
|
const top = box(b.hw * 2, 0.1, b.hd * 2.1, m.stripe); top.position.y = b.h; g.add(top);
|
||||||
|
} else {
|
||||||
|
const bx = box(b.hw * 2, b.h, b.hd * 2, mat); bx.position.y = b.h / 2; bx.castShadow = true; g.add(bx);
|
||||||
|
for (const sy of [0.28, 0.74]) { const band = box(b.hw * 2.05, 0.06, b.hd * 2.05, m.dark); band.position.y = b.h * sy; g.add(band); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const b of A.belts) {
|
||||||
|
const g = new T.Group(); g.position.set(b.x, 0.012, b.z); scene.add(g);
|
||||||
|
const pad = new T.Mesh(new T.PlaneGeometry(b.hw * 2, b.hd * 2), new T.MeshStandardMaterial({ color: 0x191d24, roughness: 0.92 }));
|
||||||
|
pad.rotation.x = -Math.PI / 2; pad.receiveShadow = true; g.add(pad);
|
||||||
|
const along = Math.abs(b.ax) > Math.abs(b.az); // slats across the running direction
|
||||||
|
for (let k = -3; k <= 3; k++) {
|
||||||
|
const slat = box(along ? 0.14 : b.hw * 1.9, 0.05, along ? b.hd * 1.9 : 0.14, m.stripe);
|
||||||
|
slat.position.set(along ? k * b.hw / 3.4 : 0, 0.03, along ? 0 : k * b.hd / 3.4);
|
||||||
|
g.add(slat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const o of A.oil) {
|
||||||
|
const sl = new T.Mesh(new T.CircleGeometry(o.r, 22), new T.MeshStandardMaterial({ color: 0x06070b, roughness: 0.2, metalness: 0.75 }));
|
||||||
|
sl.rotation.x = -Math.PI / 2; sl.position.set(o.x, 0.014, o.z); scene.add(sl);
|
||||||
|
}
|
||||||
|
out.rams = A.rams.map(d => {
|
||||||
|
const g = new T.Group(); g.position.set(d.x, 0, d.z); scene.add(g);
|
||||||
|
const head = box(0.5, 0.72, d.hd * 1.8, m.steel); head.position.y = 0.4; head.castShadow = true; g.add(head);
|
||||||
|
const face = box(0.12, 0.74, d.hd * 1.85, m.stripe); face.position.set(d.nx * 0.3, 0.4, d.nz * 0.3); g.add(face);
|
||||||
|
return { d, g, x0: d.x, z0: d.z };
|
||||||
|
});
|
||||||
|
|
||||||
out.saws = A.saws.map(h => {
|
out.saws = A.saws.map(h => {
|
||||||
const g = new T.Group(); g.position.set(h.x, 0.005, h.z); scene.add(g);
|
const g = new T.Group(); g.position.set(h.x, 0.005, h.z); scene.add(g);
|
||||||
const d = cyl(h.r * 0.85, h.r * 0.85, 0.035, m.steel, 32); g.add(d);
|
const d = cyl(h.r * 0.85, h.r * 0.85, 0.035, m.steel, 32); g.add(d);
|
||||||
@@ -522,11 +889,6 @@
|
|||||||
const l = new T.Mesh(new T.SphereGeometry(0.09, 10, 6), new T.MeshStandardMaterial({ color: 0x400000, emissive: 0xff1a1a, emissiveIntensity: 0 }));
|
const l = new T.Mesh(new T.SphereGeometry(0.09, 10, 6), new T.MeshStandardMaterial({ color: 0x400000, emissive: 0xff1a1a, emissiveIntensity: 0 }));
|
||||||
l.position.set(pit.x + sx * (pit.hw + 0.12), 0.08, pit.z + sz * (pit.hd + 0.12)); scene.add(l); return l;
|
l.position.set(pit.x + sx * (pit.hw + 0.12), 0.08, pit.z + sz * (pit.hd + 0.12)); scene.add(l); return l;
|
||||||
});
|
});
|
||||||
// rockets
|
|
||||||
out.rocketGeo = new T.CylinderGeometry(0.05, 0.05, 0.32, 8); out.rocketGeo.rotateZ(Math.PI / 2);
|
|
||||||
out.rocketMat = new T.MeshStandardMaterial({ color: 0xdddddd, emissive: 0x331100 });
|
|
||||||
out.rocketMeshes = [];
|
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- garage
|
// ---------------------------------------------------------------- garage
|
||||||
@@ -550,8 +912,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------- view
|
// ---------------------------------------------------------------- view
|
||||||
|
RC.buildRobotModel = buildRobot;
|
||||||
|
|
||||||
RC.Render = function (canvas, W, H) {
|
RC.Render = function (canvas, W, H) {
|
||||||
const renderer = new T.WebGLRenderer({ canvas, antialias: true, alpha: true });
|
const renderer = new T.WebGLRenderer({ canvas, antialias: true, alpha: true, powerPreference: 'high-performance' });
|
||||||
renderer.setClearColor(0x000000, 0);
|
renderer.setClearColor(0x000000, 0);
|
||||||
renderer.outputEncoding = T.sRGBEncoding;
|
renderer.outputEncoding = T.sRGBEncoding;
|
||||||
renderer.toneMapping = T.ACESFilmicToneMapping;
|
renderer.toneMapping = T.ACESFilmicToneMapping;
|
||||||
@@ -567,18 +931,63 @@
|
|||||||
const smoke = Particles(arenaScene, 300, 34, false, tex);
|
const smoke = Particles(arenaScene, 300, 34, false, tex);
|
||||||
const fire = Particles(arenaScene, 300, 18, true, tex);
|
const fire = Particles(arenaScene, 300, 18, true, tex);
|
||||||
|
|
||||||
const VIEW = 15.4, asp = W / H;
|
const asp = W / H;
|
||||||
const cam = new T.OrthographicCamera(-VIEW * asp / 2, VIEW * asp / 2, VIEW / 2, -VIEW / 2, 0.1, 120);
|
const cam = new T.OrthographicCamera(-1, 1, 1, -1, 0.1, 200);
|
||||||
const camBase = new T.Vector3(15.2, 15.5, 15.2), camLook = new T.Vector3(-1.25, 0, -1.25);
|
const camBase = new T.Vector3(15.2, 15.5, 15.2), camLook = new T.Vector3(-1.25, 0, -1.25);
|
||||||
|
// fit the orthographic camera to an arena of half-size h
|
||||||
|
function fitCam(h) {
|
||||||
|
const VIEW = h * 1.95;
|
||||||
|
cam.left = -VIEW * asp / 2; cam.right = VIEW * asp / 2; cam.top = VIEW / 2; cam.bottom = -VIEW / 2;
|
||||||
|
cam.updateProjectionMatrix();
|
||||||
|
const d = h * 1.9;
|
||||||
|
camBase.set(d, h * 1.95, d); camLook.set(-h * 0.16, 0, -h * 0.16);
|
||||||
|
}
|
||||||
|
fitCam(RC.ARENA.half);
|
||||||
cam.position.copy(camBase); cam.lookAt(camLook);
|
cam.position.copy(camBase); cam.lookAt(camLook);
|
||||||
const gcam = new T.PerspectiveCamera(34, asp, 0.1, 60);
|
const gcam = new T.PerspectiveCamera(34, asp, 0.1, 60);
|
||||||
gcam.position.set(3.7, 2.5, 4.4); gcam.lookAt(0, 0.3, 0);
|
// put the shop camera at the current zoom (base distance / zoom, aimed at the turntable)
|
||||||
gcam.setViewOffset(W, H, 300, 40, W, H); // robot sits in the left part of the shop
|
function placeGarageCam() {
|
||||||
|
const look = new T.Vector3(0, 0.3, 0), base = new T.Vector3(3.7, 2.5, 4.4);
|
||||||
|
gcam.position.copy(look).add(base.clone().sub(look).multiplyScalar(1 / gcamZoom));
|
||||||
|
gcam.lookAt(look);
|
||||||
|
}
|
||||||
|
gcam.setViewOffset(W, H, GARAGE_OFF_X, GARAGE_OFF_Y, W, H); // robot sits in the left part of the shop
|
||||||
// intro / title: perspective camera flying over the arena
|
// intro / title: perspective camera flying over the arena
|
||||||
const pcam = new T.PerspectiveCamera(40, asp, 0.1, 120);
|
const pcam = new T.PerspectiveCamera(40, asp, 0.1, 120);
|
||||||
|
|
||||||
let mode = 'garage', gRobot = null, robots = [], state = null, shake = 0, flashT = 0, introT = 0, scale = 1, hold = 0;
|
let mode = 'garage', gRobot = null, robots = [], state = null, shake = 0, flashT = 0, introT = 0, scale = 1, hold = 0;
|
||||||
let quality = 'high', fxMul = 1;
|
let quality = 'high', fxMul = 1, camMode = 'iso', chaseInit = false, gcamZoom = GZ_DEF;
|
||||||
|
placeGarageCam(); // after gcamZoom exists: start fully zoomed out
|
||||||
|
// workshop: show what the fitted weapon / turret actually does, on a short loop
|
||||||
|
let demoT = 0;
|
||||||
|
function demoGarage(dt) {
|
||||||
|
const R = gRobot; if (!R) return;
|
||||||
|
demoT += dt;
|
||||||
|
const c = demoT % 3; // one signature move every 3 s
|
||||||
|
if (R.saw) { R.sawA += dt * 26; R.saw.rotation[R.sawAxis || 'z'] = -R.sawA; }
|
||||||
|
if (R.spinner) { R.spinA += dt * 17; R.spinner.rotation.y = R.spinA; }
|
||||||
|
if (R.vspin) { R.spinA += dt * 19; R.vspin.rotation.z = -R.spinA; }
|
||||||
|
if (R.hammer) {
|
||||||
|
const k = c < 0.35 ? c / 0.35 : c < 1.2 ? 1 - (c - 0.35) / 0.85 : 0;
|
||||||
|
R.hammer.rotation.z = lerp(1.9, -0.25, k);
|
||||||
|
}
|
||||||
|
if (R.flipper) R.flipper.rotation.z = -0.32 + (c < 0.3 ? Math.sin(c / 0.3 * Math.PI) * 1.5 : 0);
|
||||||
|
if (R.jaws) {
|
||||||
|
const k = c < 1.2 ? Math.abs(Math.sin(c / 1.2 * Math.PI)) : 0;
|
||||||
|
for (const j of R.jaws) j.rotation.y = j.userData.side * (0.45 - k * 0.63);
|
||||||
|
}
|
||||||
|
if (R.gun) { R.gunA += dt * 16; R.gun.rotation.x = R.gunA; }
|
||||||
|
const shooting = c > 1.5 && c < 2.3;
|
||||||
|
if (R.flame) R.flame.visible = shooting;
|
||||||
|
if (R.muzzle) R.muzzle.visible = shooting && Math.random() < 0.5;
|
||||||
|
// launchers have no moving part: show a short recoil kick instead
|
||||||
|
const tw2 = R.st.tower;
|
||||||
|
if (R.turret && tw2 && (tw2.type === 'mortar' || tw2.type === 'swarm')) {
|
||||||
|
const kick = c > 1.5 && c < 1.75 ? Math.sin((c - 1.5) / 0.25 * Math.PI) : 0;
|
||||||
|
R.turret.rotation.z = -0.14 * kick;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const PX = [6, 34, 18], WORLD = [0.07, 0.7, 0.32]; // particle sizes: ortho px / perspective m
|
const PX = [6, 34, 18], WORLD = [0.07, 0.7, 0.32]; // particle sizes: ortho px / perspective m
|
||||||
const pointMode = persp => [sparks, smoke, fire].forEach((p, i) => { p.pts.material.size = persp ? WORLD[i] : PX[i]; });
|
const pointMode = persp => [sparks, smoke, fire].forEach((p, i) => { p.pts.material.size = persp ? WORLD[i] : PX[i]; });
|
||||||
|
|
||||||
@@ -587,7 +996,8 @@
|
|||||||
get introTime() { return introT; },
|
get introTime() { return introT; },
|
||||||
resize(sc) {
|
resize(sc) {
|
||||||
scale = sc;
|
scale = sc;
|
||||||
const cap = quality === 'low' ? 1 : quality === 'medium' ? 1.5 : 3;
|
// the stage is scaled up by CSS; rendering at full devicePixelRatio on top of that is the main CPU/GPU hog
|
||||||
|
const cap = quality === 'low' ? 1 : quality === 'medium' ? 1.25 : 1.5;
|
||||||
renderer.setPixelRatio(Math.min(cap, sc * (root.devicePixelRatio || 1)));
|
renderer.setPixelRatio(Math.min(cap, sc * (root.devicePixelRatio || 1)));
|
||||||
renderer.setSize(W, H);
|
renderer.setSize(W, H);
|
||||||
},
|
},
|
||||||
@@ -596,13 +1006,13 @@
|
|||||||
quality = q; fxMul = q === 'low' ? 0.35 : q === 'medium' ? 0.7 : 1;
|
quality = q; fxMul = q === 'low' ? 0.35 : q === 'medium' ? 0.7 : 1;
|
||||||
const sh = q !== 'low';
|
const sh = q !== 'low';
|
||||||
renderer.shadowMap.enabled = sh;
|
renderer.shadowMap.enabled = sh;
|
||||||
renderer.shadowMap.type = q === 'high' ? T.PCFSoftShadowMap : T.PCFShadowMap;
|
renderer.shadowMap.type = q === 'high' ? T.PCFSoftShadowMap : T.PCFShadowMap; // soft shadows only on high
|
||||||
for (const sc of [arenaScene, garageScene]) sc.traverse(o => { if (o.material) [].concat(o.material).forEach(m => { m.needsUpdate = true; }); });
|
for (const sc of [arenaScene, garageScene]) sc.traverse(o => { if (o.material) [].concat(o.material).forEach(m => { m.needsUpdate = true; }); });
|
||||||
api.resize(scale);
|
api.resize(scale);
|
||||||
},
|
},
|
||||||
// intro fly-over, then a slow orbit behind the title screen; skip() jumps to the orbit
|
// intro fly-over, then a slow orbit behind the title screen; skip() jumps to the orbit
|
||||||
showIntro(builds, paints) {
|
showIntro(builds, paints) {
|
||||||
api.showArena(RC.Combat.create({ robots: builds.map(b => RC.stats(b)), seed: 3 }), builds, paints);
|
api.showArena(RC.Combat.create({ robots: builds.map(b => RC.stats(b)), seed: 3, arena: 'workshop' }), builds, paints);
|
||||||
mode = 'intro'; introT = 0; pointMode(true);
|
mode = 'intro'; introT = 0; pointMode(true);
|
||||||
},
|
},
|
||||||
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
|
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
|
||||||
@@ -625,12 +1035,37 @@
|
|||||||
// turntable angle that points the robot's side (+z = right) at the camera
|
// turntable angle that points the robot's side (+z = right) at the camera
|
||||||
garage.turntable.rotation.y = Math.atan2(gcam.position.x, gcam.position.z) + a; hold = 1e9;
|
garage.turntable.rotation.y = Math.atan2(gcam.position.x, gcam.position.z) + a; hold = 1e9;
|
||||||
},
|
},
|
||||||
paintCam(on) { gcam.position.set(on ? 2.6 : 3.7, on ? 2.2 : 2.5, on ? 3.1 : 4.4); gcam.lookAt(0, 0.3, 0); },
|
portrait(build, paint) {
|
||||||
|
api.showGarage(build, paint);
|
||||||
|
garage.turntable.rotation.y = 0.55;
|
||||||
|
gcam.clearViewOffset(); gcam.position.set(1.75, 1.3, 2.1); gcam.lookAt(0, 0.4, 0);
|
||||||
|
renderer.render(garageScene, gcam);
|
||||||
|
let url = '';
|
||||||
|
try { url = canvas.toDataURL('image/png'); } catch (e) { /* tainted canvas: no picture */ }
|
||||||
|
gcam.setViewOffset(W, H, GARAGE_OFF_X, GARAGE_OFF_Y, W, H); api.paintCam(false);
|
||||||
|
return url;
|
||||||
|
},
|
||||||
|
paintCam(on) {
|
||||||
|
gcamZoom = GZ_DEF;
|
||||||
|
if (on) { gcam.position.set(2.6, 2.2, 3.1); gcam.lookAt(0, 0.3, 0); } else placeGarageCam();
|
||||||
|
},
|
||||||
|
// garage preview zoom (shop "- Zoom +"): move the camera closer / further
|
||||||
|
zoomGarage(mult) { gcamZoom = Kit.clamp(gcamZoom * mult, GZ_MIN, GZ_MAX); placeGarageCam(); },
|
||||||
|
resetGarageZoom() { gcamZoom = GZ_DEF; placeGarageCam(); },
|
||||||
|
// rebuild the arena scene if the fight uses a different one; rescale the camera
|
||||||
|
setArena(A) {
|
||||||
|
if (!A || arena.id === A.id) { if (A) fitCam(A.half); return; }
|
||||||
|
RC.setArena(A.id);
|
||||||
|
robots.forEach(R => arenaScene.remove(R.root)); robots = [];
|
||||||
|
buildArenaGeo(arena, A);
|
||||||
|
fitCam(A.half);
|
||||||
|
},
|
||||||
showArena(s, builds, paints) {
|
showArena(s, builds, paints) {
|
||||||
mode = 'arena'; state = s; pointMode(false); lightsOn(1);
|
api.setArena(s.arena);
|
||||||
|
mode = 'arena'; state = s; pointMode(camMode !== 'iso'); lightsOn(1); chaseInit = false;
|
||||||
for (const R of robots) arenaScene.remove(R.root);
|
for (const R of robots) arenaScene.remove(R.root);
|
||||||
robots = builds.map((b, i) => { const R = buildRobot(b, paints[i]); arenaScene.add(R.root); return R; });
|
robots = builds.map((b, i) => { const R = buildRobot(b, paints[i]); arenaScene.add(R.root); return R; });
|
||||||
sparks.clear(); smoke.clear(); fire.clear(); shake = 0;
|
sparks.clear(); smoke.clear(); fire.clear(); clearDebris(); shake = 0;
|
||||||
for (const m of arena.rocketMeshes) arenaScene.remove(m);
|
for (const m of arena.rocketMeshes) arenaScene.remove(m);
|
||||||
arena.rocketMeshes = [];
|
arena.rocketMeshes = [];
|
||||||
},
|
},
|
||||||
@@ -653,17 +1088,33 @@
|
|||||||
case 'press': puff(e.x, e.z, 14); burst(e.x, 0.1, e.z, 24, 5, [1, 0.8, 0.4]); shake = Math.max(shake, 0.45); break;
|
case 'press': puff(e.x, e.z, 14); burst(e.x, 0.1, e.z, 24, 5, [1, 0.8, 0.4]); shake = Math.max(shake, 0.45); break;
|
||||||
case 'drop': puff(e.x, e.z, 8); shake = Math.max(shake, 0.2); break;
|
case 'drop': puff(e.x, e.z, 8); shake = Math.max(shake, 0.2); break;
|
||||||
case 'ko': explode(e.x, 0.5, e.z, 1.2); break;
|
case 'ko': explode(e.x, 0.5, e.z, 1.2); break;
|
||||||
|
case 'broke':
|
||||||
|
breakPart(robots[e.who], e.part);
|
||||||
|
burst(e.x, 0.45, e.z, 22, 5, [1, 0.8, 0.4]); puff(e.x, e.z, 6);
|
||||||
|
shake = Math.max(shake, 0.28);
|
||||||
|
break;
|
||||||
case 'boost': for (let k = 0; k < 6; k++) fire.spawn(e.x, 0.3, e.z, (Math.random() - 0.5), 0.6, (Math.random() - 0.5), 0.4, 1, 0.6, 0.2); break;
|
case 'boost': for (let k = 0; k < 6; k++) fire.spawn(e.x, 0.3, e.z, (Math.random() - 0.5), 0.6, (Math.random() - 0.5), 0.4, 1, 0.6, 0.2); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// fight camera: 'iso' (whole arena) | 'chase' (behind robot 0) | 'fpv' (cockpit of robot 0)
|
||||||
|
get camMode() { return camMode; },
|
||||||
|
setCam(m) {
|
||||||
|
camMode = m; chaseInit = false;
|
||||||
|
pcam.fov = m === 'fpv' ? 72 : 55; pcam.updateProjectionMatrix();
|
||||||
|
if (mode === 'arena') pointMode(m !== 'iso');
|
||||||
|
if (robots[0] && robots[0].turret) robots[0].turret.visible = m !== 'fpv';
|
||||||
|
},
|
||||||
project(x, y, z) {
|
project(x, y, z) {
|
||||||
const v = new T.Vector3(x, y, z).project(cam);
|
const v = new T.Vector3(x, y, z).project(mode === 'arena' && camMode !== 'iso' ? pcam : cam);
|
||||||
|
// behind the camera (chase / cockpit): off screen
|
||||||
|
if (v.z > 1) return { x: -999, y: -999 };
|
||||||
return { x: (v.x + 1) / 2 * W, y: (1 - v.y) / 2 * H };
|
return { x: (v.x + 1) / 2 * W, y: (1 - v.y) / 2 * H };
|
||||||
},
|
},
|
||||||
frame(dt, now) {
|
frame(dt, now) {
|
||||||
if (mode === 'garage') {
|
if (mode === 'garage') {
|
||||||
if (hold > 0) hold -= dt; else garage.turntable.rotation.y += dt * 0.45;
|
if (hold > 0) hold -= dt; else garage.turntable.rotation.y += dt * 0.45;
|
||||||
|
demoGarage(dt);
|
||||||
renderer.render(garageScene, gcam);
|
renderer.render(garageScene, gcam);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -679,14 +1130,40 @@
|
|||||||
sparks.update(dt, 9, 1.2); smoke.update(dt, -0.6, 1.4); fire.update(dt, -2.5, 2);
|
sparks.update(dt, 9, 1.2); smoke.update(dt, -0.6, 1.4); fire.update(dt, -2.5, 2);
|
||||||
shake = Math.max(0, shake - dt * 1.2);
|
shake = Math.max(0, shake - dt * 1.2);
|
||||||
const sx = (Math.random() - 0.5) * shake, sz = (Math.random() - 0.5) * shake;
|
const sx = (Math.random() - 0.5) * shake, sz = (Math.random() - 0.5) * shake;
|
||||||
cam.position.set(camBase.x + sx, camBase.y, camBase.z + sz);
|
|
||||||
cam.lookAt(camLook.x + sx, camLook.y, camLook.z + sz);
|
|
||||||
flashT = Math.max(0, flashT - dt * 3);
|
flashT = Math.max(0, flashT - dt * 3);
|
||||||
arena.flashLight.intensity = flashT * 4;
|
arena.flashLight.intensity = flashT * 4;
|
||||||
|
if (camMode !== 'iso' && state && robots[0]) {
|
||||||
|
followCam(dt, sx, sz);
|
||||||
|
renderer.render(arenaScene, pcam);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cam.position.set(camBase.x + sx, camBase.y, camBase.z + sz);
|
||||||
|
cam.lookAt(camLook.x + sx, camLook.y, camLook.z + sz);
|
||||||
renderer.render(arenaScene, cam);
|
renderer.render(arenaScene, cam);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// chase: smooth camera behind and above robot 0 · fpv: eyes at the front edge of its top
|
||||||
|
const cpos = new T.Vector3(), clook = new T.Vector3();
|
||||||
|
function followCam(dt, sx, sz) {
|
||||||
|
const r = state.robots[0], R = robots[0], half = (state.arena || RC.ARENA).half;
|
||||||
|
const fx = Math.cos(r.a), fz = Math.sin(r.a);
|
||||||
|
let px, py, pz, lx, ly, lz;
|
||||||
|
if (camMode === 'fpv') {
|
||||||
|
const k = R.st.len * 0.08;
|
||||||
|
px = r.x + fx * k; pz = r.z + fz * k; py = Math.max(0.25, r.y) + R.top + 0.55;
|
||||||
|
lx = px + fx * 6; lz = pz + fz * 6; ly = py - 1.25;
|
||||||
|
cpos.set(px + sx * 0.3, py, pz + sz * 0.3); clook.set(lx, ly, lz);
|
||||||
|
} else {
|
||||||
|
px = Kit.clamp(r.x - fx * 3.6, -half - 1.2, half + 1.2); pz = Kit.clamp(r.z - fz * 3.6, -half - 1.2, half + 1.2); py = 2.2 + r.y * 0.5;
|
||||||
|
lx = r.x + fx * 1.6; lz = r.z + fz * 1.6; ly = 0.3 + r.y * 0.5;
|
||||||
|
const k = chaseInit ? Math.min(1, dt * 5) : 1;
|
||||||
|
chaseInit = true;
|
||||||
|
cpos.lerp(new T.Vector3(px + sx, py, pz + sz), k); clook.lerp(new T.Vector3(lx, ly, lz), k);
|
||||||
|
}
|
||||||
|
pcam.position.copy(cpos); pcam.lookAt(clook);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
|
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
|
||||||
const INTRO_END = RC.INTRO_END = 7.5;
|
const INTRO_END = RC.INTRO_END = 7.5;
|
||||||
const ease = u => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
|
const ease = u => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
|
||||||
@@ -742,9 +1219,49 @@
|
|||||||
arena.flashLight.position.set(x, 1.2, z); flashT = 1; shake = Math.max(shake, 0.3 * k);
|
arena.flashLight.position.set(x, 1.2, z); flashT = 1; shake = Math.max(shake, 0.3 * k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parts torn off in a fight: the real mesh leaves the robot and tumbles over the floor
|
||||||
|
const debris = [];
|
||||||
|
function dropPiece(obj) {
|
||||||
|
const wp = new T.Vector3(), wq = new T.Quaternion();
|
||||||
|
obj.getWorldPosition(wp); obj.getWorldQuaternion(wq);
|
||||||
|
arenaScene.add(obj);
|
||||||
|
obj.position.copy(wp); obj.quaternion.copy(wq);
|
||||||
|
debris.push({ o: obj, vx: (Math.random() - 0.5) * 3.5, vy: 2.2 + Math.random() * 1.8, vz: (Math.random() - 0.5) * 3.5,
|
||||||
|
rx: (Math.random() - 0.5) * 9, rz: (Math.random() - 0.5) * 9, t: 9 });
|
||||||
|
while (debris.length > 10) { const d = debris.shift(); arenaScene.remove(d.o); }
|
||||||
|
}
|
||||||
|
function updateDebris(dt) {
|
||||||
|
for (let i = debris.length - 1; i >= 0; i--) {
|
||||||
|
const d = debris[i];
|
||||||
|
d.t -= dt; d.vy -= 22 * dt;
|
||||||
|
d.o.position.x += d.vx * dt; d.o.position.y += d.vy * dt; d.o.position.z += d.vz * dt;
|
||||||
|
if (d.o.position.y < 0.07) { d.o.position.y = 0.07; d.vy = -d.vy * 0.3; d.vx *= 0.6; d.vz *= 0.6; d.rx *= 0.5; d.rz *= 0.5; }
|
||||||
|
d.o.rotation.x += d.rx * dt; d.o.rotation.z += d.rz * dt;
|
||||||
|
if (d.t <= 0) { arenaScene.remove(d.o); debris.splice(i, 1); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function clearDebris() { for (const d of debris) arenaScene.remove(d.o); debris.length = 0; }
|
||||||
|
// combat.js says a part broke off -> take it off the model (one piece tumbles away)
|
||||||
|
function breakPart(R, part) {
|
||||||
|
if (!R) return;
|
||||||
|
if (part === 'wheels') {
|
||||||
|
const w = (R.wheels || []).find(o => o.parent === R.tilt);
|
||||||
|
if (w) { R.wheels.splice(R.wheels.indexOf(w), 1); dropPiece(w); }
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const kill = R.tilt.children.filter(o => o.userData.part === part && o.visible);
|
||||||
|
if (!kill.length) return;
|
||||||
|
const main = kill[0];
|
||||||
|
for (const o of kill) if (o !== main) o.visible = false;
|
||||||
|
dropPiece(main);
|
||||||
|
if (part === 'weapon') { R.saw = null; R.spinner = null; R.hammer = null; R.flipper = null; R.jaws = null; }
|
||||||
|
if (part === 'tower') { R.turret = null; R.flame = null; R.gun = null; R.muzzle = null; }
|
||||||
|
}
|
||||||
|
|
||||||
function animateArena(dt, now) {
|
function animateArena(dt, now) {
|
||||||
const s = state; if (!s) return;
|
const s = state; if (!s) return;
|
||||||
const A = RC.ARENA;
|
const A = state.arena || RC.ARENA;
|
||||||
|
updateDebris(dt);
|
||||||
robots.forEach((R, i) => {
|
robots.forEach((R, i) => {
|
||||||
const r = s.robots[i];
|
const r = s.robots[i];
|
||||||
poseRobot(R, r, dt);
|
poseRobot(R, r, dt);
|
||||||
@@ -762,6 +1279,12 @@
|
|||||||
fire.spawn(r.x + Math.cos(r.turretA) * 0.6, r.y + R.top + 0.18, r.z + Math.sin(r.turretA) * 0.6, Math.cos(a) * v, 0.3, Math.sin(a) * v, 0.45, 1, 0.55, 0.15);
|
fire.spawn(r.x + Math.cos(r.turretA) * 0.6, r.y + R.top + 0.18, r.z + Math.sin(r.turretA) * 0.6, Math.cos(a) * v, 0.3, Math.sin(a) * v, 0.45, 1, 0.55, 0.15);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// wall rams punch out while they are armed
|
||||||
|
for (const rm of arena.rams || []) {
|
||||||
|
const on = RC.hazardOn(rm.d, s.t) ? 1 : 0, k = Math.min(1, dt * (on ? 20 : 5));
|
||||||
|
rm.g.position.x = lerp(rm.g.position.x, rm.x0 + rm.d.nx * on * 1.2, k);
|
||||||
|
rm.g.position.z = lerp(rm.g.position.z, rm.z0 + rm.d.nz * on * 1.2, k);
|
||||||
|
}
|
||||||
// saws
|
// saws
|
||||||
for (const S of arena.saws) {
|
for (const S of arena.saws) {
|
||||||
const on = RC.hazardOn(S.h, s.t), warn = RC.hazardOn(S.h, s.t + 0.6);
|
const on = RC.hazardOn(S.h, s.t), warn = RC.hazardOn(S.h, s.t + 0.6);
|
||||||
@@ -791,14 +1314,22 @@
|
|||||||
for (const d of arena.pitDoors) { d.position.x = A.pit.x + d.userData.sx * (A.pit.hw / 2 + o * A.pit.hw * 1.02); d.position.y = 0.025 + o * 0.01; }
|
for (const d of arena.pitDoors) { d.position.x = A.pit.x + d.userData.sx * (A.pit.hw / 2 + o * A.pit.hw * 1.02); d.position.y = 0.025 + o * 0.01; }
|
||||||
for (const l of arena.pitLamps) l.material.emissiveIntensity = s.pitAlarm ? (Math.sin(now / 150) > 0 ? 2.5 : 0.4) : 0;
|
for (const l of arena.pitLamps) l.material.emissiveIntensity = s.pitAlarm ? (Math.sin(now / 150) > 0 ? 2.5 : 0.4) : 0;
|
||||||
// rockets
|
// rockets
|
||||||
while (arena.rocketMeshes.length < s.rockets.length) { const m = new T.Mesh(arena.rocketGeo, arena.rocketMat); arenaScene.add(m); arena.rocketMeshes.push(m); }
|
while (arena.rocketMeshes.length < s.rockets.length) {
|
||||||
|
const gr = new T.Group();
|
||||||
|
const body = new T.Mesh(arena.rocketGeo, arena.rocketMat); gr.add(body);
|
||||||
|
const nose = new T.Mesh(new T.ConeGeometry(0.055, 0.12, 8), arena.rocketMat);
|
||||||
|
nose.rotation.z = -Math.PI / 2; nose.position.x = 0.21; gr.add(nose);
|
||||||
|
for (const sz of [-1, 1]) { const fin = new T.Mesh(new T.BoxGeometry(0.09, 0.012, 0.07), arena.rocketMat); fin.position.set(-0.13, 0, sz * 0.045); gr.add(fin); }
|
||||||
|
arenaScene.add(gr); arena.rocketMeshes.push(gr);
|
||||||
|
}
|
||||||
arena.rocketMeshes.forEach((m, i) => {
|
arena.rocketMeshes.forEach((m, i) => {
|
||||||
const k = s.rockets[i];
|
const k = s.rockets[i];
|
||||||
m.visible = !!k;
|
m.visible = !!k;
|
||||||
if (k) {
|
if (k) {
|
||||||
m.position.set(k.x, k.y, k.z); m.rotation.y = -k.a;
|
m.position.set(k.x, k.y, k.z); m.rotation.y = -k.a;
|
||||||
fire.spawn(k.x - Math.cos(k.a) * 0.2, k.y, k.z - Math.sin(k.a) * 0.2, 0, 0.2, 0, 0.3, 1, 0.6, 0.2);
|
const bx = k.x - Math.cos(k.a) * 0.22, bz = k.z - Math.sin(k.a) * 0.22;
|
||||||
if (Math.random() < 0.5) smoke.spawn(k.x, k.y, k.z, 0, 0.2, 0, 0.8, 0.5, 0.5, 0.5);
|
for (let q = 0; q < 2; q++) fire.spawn(bx, k.y, bz, (Math.random() - 0.5) * 0.4, 0.25, (Math.random() - 0.5) * 0.4, 0.26, 1, 0.65, 0.22);
|
||||||
|
smoke.spawn(bx, k.y, bz, (Math.random() - 0.5) * 0.3, 0.35, (Math.random() - 0.5) * 0.3, 1.1, 0.55, 0.55, 0.55);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
RC.stats = build => {
|
RC.stats = build => {
|
||||||
const ch = part(build, 'chassis'), mo = part(build, 'motor'), wh = part(build, 'wheels');
|
const ch = part(build, 'chassis'), mo = part(build, 'motor'), wh = part(build, 'wheels');
|
||||||
const ar = part(build, 'armour'), we = part(build, 'weapon'), to = part(build, 'tower');
|
const ar = part(build, 'armour'), we = part(build, 'weapon'), to = part(build, 'tower'), gd = part(build, 'gadget');
|
||||||
const v = RC.validate(build);
|
const v = RC.validate(build);
|
||||||
const mass = Math.max(30, v.weight);
|
const mass = Math.max(30, v.weight);
|
||||||
let value = 0;
|
let value = 0;
|
||||||
@@ -45,8 +45,8 @@
|
|||||||
grip: wh ? wh.grip : 6,
|
grip: wh ? wh.grip : 6,
|
||||||
push: wh ? wh.push : 1,
|
push: wh ? wh.push : 1,
|
||||||
len, wid, h: ch ? ch.h : 0.42,
|
len, wid, h: ch ? ch.h : 0.42,
|
||||||
rad: Math.hypot(len, wid) / 2 * 0.82,
|
rad: Math.hypot(len, wid) / 2 * 0.9, // close to the body corners so robots do not clip through each other
|
||||||
weapon: we, tower: to,
|
weapon: we, tower: to, gadget: gd, armour: ar,
|
||||||
invertible: !!(wh && wh.invertible),
|
invertible: !!(wh && wh.invertible),
|
||||||
lowProfile: !!(ch && ch.lowProfile),
|
lowProfile: !!(ch && ch.lowProfile),
|
||||||
frontArmour: ch && ch.frontArmour ? ch.frontArmour : 0,
|
frontArmour: ch && ch.frontArmour ? ch.frontArmour : 0,
|
||||||
|
|||||||
56
game/shop.js
@@ -10,9 +10,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const RC = root.RC, $ = Kit.$;
|
const RC = root.RC, $ = Kit.$;
|
||||||
RC.PAINTS = [0xd8452b, 0xff7a1a, 0xf2c230, 0x5fae3b, 0x2e9c8f, 0x2a6fd8, 0x6a3fb0, 0xd94f9a, 0xe6e6e6, 0x8c8c8c, 0x3a3d44, 0x15171b];
|
RC.PAINTS = [0xd8452b, 0xff7a1a, 0xf2c230, 0x5fae3b, 0x2e9c8f, 0x2a6fd8, 0x6a3fb0, 0xd94f9a, 0xe6e6e6, 0x8c8c8c, 0x3a3d44, 0x15171b];
|
||||||
|
// ready-made [body, accent] combinations
|
||||||
|
RC.SCHEMES = [[0xff7a1a, 0x15171b], [0x15171b, 0xff7a1a], [0x2a6fd8, 0xe6e6e6], [0xd8452b, 0xf2c230],
|
||||||
|
[0x5fae3b, 0x15171b], [0x6a3fb0, 0xf2c230], [0xe6e6e6, 0xd8452b], [0x3a3d44, 0x2e9c8f]];
|
||||||
const hex = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
const hex = n => '#' + (n >>> 0).toString(16).padStart(6, '0');
|
||||||
const SELL = 0.5;
|
const SELL = 0.5;
|
||||||
const GLYPH = { chassis: '🧱', motor: '⚙️', wheels: '🛞', battery: '🔋', armour: '🛡️', weapon: '🪓', tower: '🔥' };
|
const HOTKEY = { weapon: 'hk_weapon', tower: 'hk_tower', gadget: 'hk_gadget' };
|
||||||
|
const GLYPH = { chassis: '🧱', motor: '⚙️', wheels: '🛞', battery: '🔋', armour: '🛡️', weapon: '🪓', tower: '🔥', gadget: '🧰' };
|
||||||
const ICO = { hp: ['ico_hp', '❤️'], armour: ['ico_armour', '🛡️'], speed: ['ico_speed', '⏱️'], weight: ['ico_weight', '⚖️'],
|
const ICO = { hp: ['ico_hp', '❤️'], armour: ['ico_armour', '🛡️'], speed: ['ico_speed', '⏱️'], weight: ['ico_weight', '⚖️'],
|
||||||
power: ['ico_power', '⚡'], money: ['ico_credits', '🪙'], fame: ['ico_fame', '⭐'], accel: [null, '🚀'], turn: [null, '↻'] };
|
power: ['ico_power', '⚡'], money: ['ico_credits', '🪙'], fame: ['ico_fame', '⭐'], accel: [null, '🚀'], turn: [null, '↻'] };
|
||||||
RC.pic = (name, glyph = '', cls = '') =>
|
RC.pic = (name, glyph = '', cls = '') =>
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
|
|
||||||
RC.Shop = function (opt) {
|
RC.Shop = function (opt) {
|
||||||
const t = opt.t;
|
const t = opt.t;
|
||||||
let slot = 'weapon', sel = undefined, tipN = 0;
|
let slot = 'weapon', sel = undefined, tipN = 0, topTab = 'build';
|
||||||
|
|
||||||
function chipsFor(p) {
|
function chipsFor(p) {
|
||||||
const s = [];
|
const s = [];
|
||||||
@@ -32,6 +36,8 @@
|
|||||||
if (p.dmg) s.push(`<span>${t('st_dmg', { n: p.dmg })}</span>`);
|
if (p.dmg) s.push(`<span>${t('st_dmg', { n: p.dmg })}</span>`);
|
||||||
if (p.dps) s.push(`<span>${t('st_dps', { n: p.dps })}</span>`);
|
if (p.dps) s.push(`<span>${t('st_dps', { n: p.dps })}</span>`);
|
||||||
if (p.range) s.push(`<span>${t('st_range', { n: p.range })}</span>`);
|
if (p.range) s.push(`<span>${t('st_range', { n: p.range })}</span>`);
|
||||||
|
// which button works this part in a fight
|
||||||
|
if (HOTKEY[p.slot]) s.push(`<span class="key">⌨ ${t(HOTKEY[p.slot])}</span>`);
|
||||||
s.push(`<span>${ico('weight')}${p.weight} kg</span>`);
|
s.push(`<span>${ico('weight')}${p.weight} kg</span>`);
|
||||||
if (p.slot === 'battery') s.push(`<span>${ico('power')}+${p.power}</span>`);
|
if (p.slot === 'battery') s.push(`<span>${ico('power')}+${p.power}</span>`);
|
||||||
else if (p.power) s.push(`<span>${ico('power')}${p.power}</span>`);
|
else if (p.power) s.push(`<span>${ico('power')}${p.power}</span>`);
|
||||||
@@ -96,19 +102,59 @@
|
|||||||
['armour', t('m_armour'), bar(st.reduce, 0.4, false, alt && alt.reduce), Math.round(st.reduce * 100) + '%'],
|
['armour', t('m_armour'), bar(st.reduce, 0.4, false, alt && alt.reduce), Math.round(st.reduce * 100) + '%'],
|
||||||
['speed', t('m_speed'), bar(st.top, 7, false, alt && alt.top), st.top.toFixed(1) + ' m/s'],
|
['speed', t('m_speed'), bar(st.top, 7, false, alt && alt.top), st.top.toFixed(1) + ' m/s'],
|
||||||
['accel', t('m_accel'), bar(st.accel, 30, false, alt && alt.accel), st.accel.toFixed(1)],
|
['accel', t('m_accel'), bar(st.accel, 30, false, alt && alt.accel), st.accel.toFixed(1)],
|
||||||
['turn', t('m_turn'), bar(st.turn, 3, false, alt && alt.turn), st.turn.toFixed(1)],
|
['turn', t('m_turn'), bar(st.turn, 3.6, false, alt && alt.turn), st.turn.toFixed(1)],
|
||||||
].map(r => `<span class="st" title="${r[1]}">${ico(r[0])}${r[2]}<span>${r[3]}</span></span>`).join('');
|
].map(r => `<span class="st" title="${r[1]}">${ico(r[0])}${r[2]}<span>${r[3]}</span></span>`).join('');
|
||||||
|
|
||||||
// paint
|
// paint
|
||||||
for (const [id, key] of [['paintBody', 'body'], ['paintAccent', 'accent']]) {
|
for (const [id, key] of [['paintBody', 'body'], ['paintAccent', 'accent']]) {
|
||||||
$(id).innerHTML = `<span class="lb">${t('paint_' + key)}</span>` + RC.PAINTS.map(c => `<span class="sw ${save.paint[key] === c ? 'on' : ''}" data-c="${c}" style="background:${hex(c)}"></span>`).join('');
|
$(id).innerHTML = RC.PAINTS.map(c => `<span class="sw ${save.paint[key] === c ? 'on' : ''}" data-c="${c}" style="background:${hex(c)}"></span>`).join('');
|
||||||
$(id).querySelectorAll('.sw').forEach(el => { el.onclick = () => { save.paint[key] = +el.dataset.c; opt.sfx.click(); opt.onSave(); opt.onPaint(); render(); }; });
|
$(id).querySelectorAll('.sw').forEach(el => { el.onclick = () => { save.paint[key] = +el.dataset.c; opt.sfx.click(); opt.onSave(); opt.onPaint(); render(); }; });
|
||||||
}
|
}
|
||||||
|
// ready-made two-colour schemes
|
||||||
|
const sc = $('paintSchemes');
|
||||||
|
if (sc) {
|
||||||
|
sc.innerHTML = RC.SCHEMES.map(([b2, a2]) => {
|
||||||
|
const on = save.paint.body === b2 && save.paint.accent === a2;
|
||||||
|
return `<span class="sw duo ${on ? 'on' : ''}" data-b="${b2}" data-a="${a2}"><i style="background:${hex(b2)}"></i><i style="background:${hex(a2)}"></i></span>`;
|
||||||
|
}).join('');
|
||||||
|
sc.querySelectorAll('.sw').forEach(el => {
|
||||||
|
el.onclick = () => { save.paint.body = +el.dataset.b; save.paint.accent = +el.dataset.a; opt.sfx.click(); opt.onSave(); opt.onPaint(); render(); };
|
||||||
|
});
|
||||||
|
}
|
||||||
$('gErr').textContent = v.errors.map(e => t('err_' + e.replace(/^(need|bad)_.*/, '$1'), { slot: t('slot_' + e.split('_')[1]) })).join(' · ');
|
$('gErr').textContent = v.errors.map(e => t('err_' + e.replace(/^(need|bad)_.*/, '$1'), { slot: t('slot_' + e.split('_')[1]) })).join(' · ');
|
||||||
$('bLeague').disabled = !v.ok; $('bTrain').disabled = !v.ok;
|
$('bLeague').disabled = !v.ok; $('bTrain').disabled = !v.ok;
|
||||||
const name = $('rname');
|
const name = $('rname');
|
||||||
if (document.activeElement !== name) name.value = save.robotName;
|
if (document.activeElement !== name) name.value = save.robotName;
|
||||||
if (!$('mechTip').textContent) tip();
|
if (!$('mechTip').textContent) tip();
|
||||||
|
renderTopTabs(); renderFitted();
|
||||||
|
// live preview: show the selected part on the 3D robot (even parts you can't afford yet)
|
||||||
|
if (opt.onPreview) opt.onPreview(topTab === 'build' && sel !== b[slot] ? Object.assign({}, b, { [slot]: sel }) : b);
|
||||||
|
}
|
||||||
|
|
||||||
|
// top mode tabs: Parts / Paint / Hangar
|
||||||
|
function renderTopTabs() {
|
||||||
|
const tabs = [['build', '🔧 ' + t('tab_build')], ['paint', '🎨 ' + t('tab_paint')], ['hangar', '🚗 ' + t('tab_hangar')]];
|
||||||
|
$('shopTabs').innerHTML = tabs.map(([k, label]) => `<button class="${k === topTab ? 'on' : ''}" data-tab="${k}">${label}</button>`).join('');
|
||||||
|
$('shopTabs').querySelectorAll('button').forEach(bt => { bt.onclick = () => { setTab(bt.dataset.tab); opt.sfx.click(); }; });
|
||||||
|
$('buildView').classList.toggle('hide', topTab !== 'build');
|
||||||
|
$('paintView').classList.toggle('hide', topTab !== 'paint');
|
||||||
|
$('hangarView').classList.toggle('hide', topTab !== 'hangar');
|
||||||
|
if (topTab === 'hangar' && opt.onHangarView) opt.onHangarView($('hangarView'));
|
||||||
|
}
|
||||||
|
function setTab(k) { topTab = k; renderTopTabs(); }
|
||||||
|
|
||||||
|
// fitted parts summary (left column): every slot with the equipped part + quick remove/jump
|
||||||
|
function renderFitted() {
|
||||||
|
const save = opt.getSave(), b = save.build;
|
||||||
|
$('fitted').innerHTML = RC.SLOTS.map(sl => {
|
||||||
|
const id = b[sl], p = id && RC.PARTS[id];
|
||||||
|
const rm = p && !RC.REQUIRED[sl] ? `<span class="frm" data-rm="${sl}">✕</span>` : '<span></span>';
|
||||||
|
return `<div class="frow" data-goto="${sl}">${RC.pic('slot_' + sl, GLYPH[sl])}<span class="fn ${p ? '' : 'empty'}">${p ? p.name : t('none')}</span>${rm}</div>`;
|
||||||
|
}).join('');
|
||||||
|
$('fitted').querySelectorAll('.frow').forEach(el => { el.onclick = e => {
|
||||||
|
if (e.target.dataset.rm) { const s = e.target.dataset.rm; opt.getSave().build[s] = null; opt.sfx.click(); opt.onSave(); opt.onBuild(); render(); return; }
|
||||||
|
slot = el.dataset.goto; sel = opt.getSave().build[slot] || null; topTab = 'build'; opt.sfx.click(); render();
|
||||||
|
}; });
|
||||||
}
|
}
|
||||||
|
|
||||||
function act2(what) {
|
function act2(what) {
|
||||||
@@ -140,6 +186,6 @@
|
|||||||
});
|
});
|
||||||
$('rname').addEventListener('keydown', e => { if (e.key === 'Enter') $('rname').blur(); e.stopPropagation(); });
|
$('rname').addEventListener('keydown', e => { if (e.key === 'Enter') $('rname').blur(); e.stopPropagation(); });
|
||||||
$('mechPic').innerHTML = `<img src="${Kit.asset('assets/Sprites/npc_mechanic.png')}" alt="" onerror="this.classList.add('missing')">`;
|
$('mechPic').innerHTML = `<img src="${Kit.asset('assets/Sprites/npc_mechanic.png')}" alt="" onerror="this.classList.add('missing')">`;
|
||||||
return { render, tip, reset() { sel = undefined; } };
|
return { render, tip, setTab, reset() { sel = undefined; topTab = 'build'; } };
|
||||||
};
|
};
|
||||||
})(window);
|
})(window);
|
||||||
|
|||||||
149
game/uicheck.js
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
/* Robot Clash - layout self-test (dev only, loaded always but idle without ?uicheck).
|
||||||
|
|
||||||
|
RC.uiCheck() measures the live DOM and reports layout faults as text:
|
||||||
|
- containers that scroll (content taller than the box)
|
||||||
|
- elements sticking out of #stage
|
||||||
|
- overlapping pairs that must not touch (HUD over content, pad over cooldowns, ...)
|
||||||
|
- tap targets below 34 px (tablet rule)
|
||||||
|
- labels cut off with an ellipsis
|
||||||
|
- heading font actually loaded
|
||||||
|
The result goes into <pre id="uicheck"> and document.title, so it can be read from a
|
||||||
|
headless --dump-dom run without taking a screenshot (Michael's rule: never screenshots). */
|
||||||
|
(function (root) {
|
||||||
|
'use strict';
|
||||||
|
const RC = (root.RC = root.RC || {});
|
||||||
|
// catch script errors as soon as this file loads (it runs before game.js), so a headless
|
||||||
|
// --dump-dom run shows them instead of silently rendering a half-dead page
|
||||||
|
const jsErrors = [];
|
||||||
|
addEventListener('error', e => jsErrors.push(String(e.message || e.error) + ' @ ' + (e.filename || '').split('/').pop() + ':' + e.lineno));
|
||||||
|
addEventListener('unhandledrejection', e => jsErrors.push('promise: ' + String(e.reason)));
|
||||||
|
|
||||||
|
const MIN_TAP = 34; // px, smallest allowed button edge on touch
|
||||||
|
const EPS = 1.5; // rounding slack
|
||||||
|
|
||||||
|
const vis = el => {
|
||||||
|
if (!el || !el.getBoundingClientRect) return false;
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
if (r.width < 1 || r.height < 1) return false;
|
||||||
|
const st = getComputedStyle(el);
|
||||||
|
return st.display !== 'none' && st.visibility !== 'hidden' && +st.opacity > 0.05;
|
||||||
|
};
|
||||||
|
const all = sel => Array.from(document.querySelectorAll(sel)).filter(vis);
|
||||||
|
const one = sel => all(sel)[0] || null;
|
||||||
|
const name = el => el.id ? '#' + el.id : '.' + (el.className || el.tagName).toString().trim().split(/\s+/)[0];
|
||||||
|
const overlap = (a, b) => {
|
||||||
|
const r = a.getBoundingClientRect(), q = b.getBoundingClientRect();
|
||||||
|
const w = Math.min(r.right, q.right) - Math.max(r.left, q.left);
|
||||||
|
const h = Math.min(r.bottom, q.bottom) - Math.max(r.top, q.top);
|
||||||
|
return w > EPS && h > EPS ? Math.round(w) + 'x' + Math.round(h) : null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// containers that are allowed to scroll only when genuinely full (long lists)
|
||||||
|
const SCROLLERS = ['#cards', '.roomlist', '.plist', '#hangarView', '#paintView', '.card', '.board'];
|
||||||
|
// pairs that must never cover each other: [a, b, why]
|
||||||
|
const PAIRS = [
|
||||||
|
['#hud', '#rname', 'HUD over robot name'],
|
||||||
|
['#hud', '#shopTabs', 'HUD over shop tabs'],
|
||||||
|
['#hud', '.card', 'HUD over dialog'],
|
||||||
|
['#hud', '.lobbyfull', 'HUD over lobby'],
|
||||||
|
['#hud', '.opps', 'HUD over league grid'],
|
||||||
|
['#hud', '.fbox', 'HUD over the health box'],
|
||||||
|
['#winctl', '#hud', 'window buttons over HUD'],
|
||||||
|
['#winctl', '#fightHud', 'window buttons over fight HUD'],
|
||||||
|
['#fCds', '#pad > div:first-child', 'cooldown chips under the d-pad'],
|
||||||
|
['#fCds', '#pad .fire', 'cooldown chips under the fire buttons'],
|
||||||
|
['#fCds', '.fbox', 'cooldown chips over a fight box'],
|
||||||
|
['#pad', '#fightHud', 'touch pad over fight HUD'],
|
||||||
|
];
|
||||||
|
|
||||||
|
RC.uiCheck = function () {
|
||||||
|
const bad = [], note = [];
|
||||||
|
const stage = document.getElementById('stage');
|
||||||
|
if (!stage) return { ok: false, lines: ['no #stage'] };
|
||||||
|
const sr = stage.getBoundingClientRect();
|
||||||
|
|
||||||
|
// 1. scrolling containers
|
||||||
|
for (const sel of SCROLLERS) {
|
||||||
|
for (const el of all(sel)) {
|
||||||
|
const over = el.scrollHeight - el.clientHeight;
|
||||||
|
if (over > EPS) bad.push(`SCROLL ${name(el)} +${Math.round(over)}px (${el.scrollHeight}>${el.clientHeight})`);
|
||||||
|
const overX = el.scrollWidth - el.clientWidth;
|
||||||
|
if (overX > EPS) bad.push(`SCROLL-X ${name(el)} +${Math.round(overX)}px`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. out of the stage
|
||||||
|
for (const sel of ['#hud', '#shop', '#fightHud', '#pad', '.card', '.lobbyfull', '.title', '#fCds', '#detail', '.gbar', '.fitted']) {
|
||||||
|
for (const el of all(sel)) {
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
const out = [
|
||||||
|
r.left < sr.left - EPS ? 'left ' + Math.round(sr.left - r.left) : '',
|
||||||
|
r.right > sr.right + EPS ? 'right ' + Math.round(r.right - sr.right) : '',
|
||||||
|
r.top < sr.top - EPS ? 'top ' + Math.round(sr.top - r.top) : '',
|
||||||
|
r.bottom > sr.bottom + EPS ? 'bottom ' + Math.round(r.bottom - sr.bottom) : '',
|
||||||
|
].filter(Boolean);
|
||||||
|
if (out.length) bad.push(`OUTSIDE ${name(el)} ${out.join(', ')}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. forbidden overlaps
|
||||||
|
for (const [sa, sb, why] of PAIRS) {
|
||||||
|
const a = one(sa), b = one(sb);
|
||||||
|
if (!a || !b) continue;
|
||||||
|
const o = overlap(a, b);
|
||||||
|
if (o) bad.push(`OVERLAP ${sa} / ${sb} ${o} - ${why}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. tap targets (buttons that are visible right now)
|
||||||
|
const scale = sr.width / (stage.offsetWidth || sr.width) || 1; // Kit.fit scales the stage
|
||||||
|
for (const b of all('button')) {
|
||||||
|
const r = b.getBoundingClientRect();
|
||||||
|
const w = r.width / scale, h = r.height / scale;
|
||||||
|
if (h < MIN_TAP - EPS || w < 18) {
|
||||||
|
const lbl = (b.textContent || b.id || '?').trim().slice(0, 14);
|
||||||
|
bad.push(`SMALL button "${lbl}" ${Math.round(w)}x${Math.round(h)} (min ${MIN_TAP} high)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. clipped labels
|
||||||
|
for (const el of all('.nm, .fn, .pn, .rn, .hmn, .hn, .who')) {
|
||||||
|
if (el.scrollWidth - el.clientWidth > 2) bad.push(`CLIPPED "${(el.textContent || '').trim().slice(0, 18)}" in ${name(el)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. heading font - fonts.check() lies about missing families, so measure instead:
|
||||||
|
// render the same text in "Russo One" and in a family that cannot exist; equal width = fallback.
|
||||||
|
const fontOk = (() => {
|
||||||
|
const c = document.createElement('canvas').getContext('2d');
|
||||||
|
const probe = f => { c.font = '40px ' + f; return c.measureText('ROBOT CLASH 123').width; };
|
||||||
|
const miss = probe('"__no_such_font__", monospace');
|
||||||
|
return Math.abs(probe('"Russo One", "__no_such_font__", monospace') - miss) > 0.5;
|
||||||
|
})();
|
||||||
|
if (fontOk === false) bad.push('FONT "Russo One" not loaded (headings fall back)');
|
||||||
|
note.push(`stage ${Math.round(sr.width)}x${Math.round(sr.height)} scale ${scale.toFixed(2)} · mode ${document.body.dataset.mode || '?'} · font ${fontOk}`);
|
||||||
|
|
||||||
|
for (const e of jsErrors) bad.unshift('JS ERROR ' + e);
|
||||||
|
if (!document.body.dataset.mode) bad.push('NO SCREEN - setScreen() never ran (game did not start)');
|
||||||
|
return { ok: bad.length === 0, lines: bad, note };
|
||||||
|
};
|
||||||
|
|
||||||
|
// ?uicheck - run after layout settled and print into the page (and the title, for --dump-dom)
|
||||||
|
RC.uiCheckRun = function () {
|
||||||
|
const show = () => {
|
||||||
|
const r = RC.uiCheck();
|
||||||
|
let pre = document.getElementById('uicheck');
|
||||||
|
if (!pre) {
|
||||||
|
pre = document.createElement('pre');
|
||||||
|
pre.id = 'uicheck';
|
||||||
|
pre.style.cssText = 'position:fixed;left:0;top:0;max-width:60vw;max-height:100vh;overflow:auto;margin:0;z-index:9999;' +
|
||||||
|
'font:12px/1.4 monospace;white-space:pre-wrap;padding:6px 8px;background:rgba(0,0,0,.85);pointer-events:none';
|
||||||
|
document.body.appendChild(pre);
|
||||||
|
}
|
||||||
|
pre.style.color = r.ok ? '#6dff9e' : '#ff5a4a';
|
||||||
|
pre.textContent = (r.ok ? 'UI ok' : 'UI FAIL ' + r.lines.length) + '\n' + r.note.join('\n') +
|
||||||
|
(r.lines.length ? '\n' + r.lines.join('\n') : '');
|
||||||
|
document.title = (r.ok ? 'UI ok' : 'UI FAIL ' + r.lines.length) + ' | ' + (document.body.dataset.mode || '?');
|
||||||
|
};
|
||||||
|
const go = () => { show(); setTimeout(show, 600); setTimeout(show, 1600); };
|
||||||
|
if (document.fonts && document.fonts.ready) document.fonts.ready.then(go); else setTimeout(go, 300);
|
||||||
|
};
|
||||||
|
})(typeof window !== 'undefined' ? window : globalThis);
|
||||||
132
package-lock.json
generated
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
{
|
||||||
|
"name": "robot-clash",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {
|
||||||
|
"": {
|
||||||
|
"name": "robot-clash",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"terser": "^5.46.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/gen-mapping": {
|
||||||
|
"version": "0.3.13",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||||
|
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.24"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/resolve-uri": {
|
||||||
|
"version": "3.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz",
|
||||||
|
"integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/source-map": {
|
||||||
|
"version": "0.3.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
|
||||||
|
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/gen-mapping": "^0.3.5",
|
||||||
|
"@jridgewell/trace-mapping": "^0.3.25"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/sourcemap-codec": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",
|
||||||
|
"integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/@jridgewell/trace-mapping": {
|
||||||
|
"version": "0.3.31",
|
||||||
|
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||||
|
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/resolve-uri": "^3.1.0",
|
||||||
|
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/acorn": {
|
||||||
|
"version": "8.19.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz",
|
||||||
|
"integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"acorn": "bin/acorn"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.4.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/buffer-from": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
||||||
|
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/commander": {
|
||||||
|
"version": "2.20.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
|
||||||
|
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
|
"node_modules/source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/source-map-support": {
|
||||||
|
"version": "0.5.21",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
|
||||||
|
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"buffer-from": "^1.0.0",
|
||||||
|
"source-map": "^0.6.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/terser": {
|
||||||
|
"version": "5.51.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/terser/-/terser-5.51.2.tgz",
|
||||||
|
"integrity": "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "BSD-2-Clause",
|
||||||
|
"dependencies": {
|
||||||
|
"@jridgewell/source-map": "^0.3.3",
|
||||||
|
"acorn": "^8.15.0",
|
||||||
|
"commander": "^2.20.0",
|
||||||
|
"source-map-support": "~0.5.20"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"terser": "bin/terser"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
package.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"name": "robot-clash",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"description": "Robot Clash - build helpers only (the game itself needs no build step).",
|
||||||
|
"devDependencies": {
|
||||||
|
"terser": "^5.46.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,14 @@ if /i "%SCRIPT%"=="generate_voice" set PY="%TOOLS%\.venv-tts\Scripts\python.exe
|
|||||||
if /i "%SCRIPT%"=="make_voice_refs" set PY="%TOOLS%\.venv-tts\Scripts\python.exe"
|
if /i "%SCRIPT%"=="make_voice_refs" set PY="%TOOLS%\.venv-tts\Scripts\python.exe"
|
||||||
set PYTHONIOENCODING=utf-8
|
set PYTHONIOENCODING=utf-8
|
||||||
pushd "%HERE%"
|
pushd "%HERE%"
|
||||||
%PY% "%TOOLS%\%SCRIPT%.py" %1 %2 %3 %4 %5 %6 %7 %8 %9
|
set ARGS=
|
||||||
|
:collect
|
||||||
|
if "%~1"=="" goto run
|
||||||
|
set ARGS=%ARGS% %1
|
||||||
|
shift
|
||||||
|
goto collect
|
||||||
|
:run
|
||||||
|
%PY% "%TOOLS%\%SCRIPT%.py"%ARGS%
|
||||||
set RC=%ERRORLEVEL%
|
set RC=%ERRORLEVEL%
|
||||||
popd
|
popd
|
||||||
exit /b %RC%
|
exit /b %RC%
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ _SCENE = "digital painting, cinematic lighting, high detail, dark industrial moo
|
|||||||
|
|
||||||
PROMPTS = [
|
PROMPTS = [
|
||||||
# app icon
|
# app icon
|
||||||
("icon", "game app icon: a fierce armoured battle robot for arena fights, heavy riveted steel box body with a huge raised front flipper plate and a spinning saw, angry glowing orange eyes on the front armour, chunky, not a car, no windows, no arms, no legs, "
|
("icon", "game app icon: a low flat wedge-shaped battle robot shaped like a steel doorstop on hidden wheels, seen from the front at an angle, "
|
||||||
"orange and black hazard paint, sparks flying, bold silhouette, plain solid black background"),
|
"huge raised front flipper plate, two glowing orange eye lights in the armour, orange and black hazard paint, sparks flying, "
|
||||||
|
"bold simple silhouette, centred, plain solid black background"),
|
||||||
|
|
||||||
# scenes (not cut out)
|
# scenes (not cut out)
|
||||||
("bg_workshop", f"interior of a cluttered robot workshop garage at night, workbenches with tools, welding sparks, "
|
("bg_workshop", f"interior of a cluttered robot workshop garage at night, workbenches with tools, welding sparks, "
|
||||||
@@ -85,9 +86,9 @@ PROMPTS = [
|
|||||||
("opp_buzzkill", f"yellow and black striped robot with a big front circular saw, {_ROBOT}"),
|
("opp_buzzkill", f"yellow and black striped robot with a big front circular saw, {_ROBOT}"),
|
||||||
("opp_flapjack", f"blue and white low robot with a huge flipper plate and big tyres, {_ROBOT}"),
|
("opp_flapjack", f"blue and white low robot with a huge flipper plate and big tyres, {_ROBOT}"),
|
||||||
("opp_pincer", f"red and gold heavy robot on tank tracks with hydraulic crushing jaws, {_ROBOT}"),
|
("opp_pincer", f"red and gold heavy robot on tank tracks with hydraulic crushing jaws, {_ROBOT}"),
|
||||||
("opp_thunderclap", f"purple robot with an overhead axe hammer and a flamethrower turret, {_ROBOT}"),
|
("opp_thunderclap", f"purple low flat armoured box robot on four wheels with a long axe arm hinged on top lying along its back and a small flamethrower nozzle turret, {_ROBOT}"),
|
||||||
("opp_gravedigger", f"black domed robot with green lights, tank tracks and a rocket pod turret, {_ROBOT}"),
|
("opp_gravedigger", f"black domed robot with green lights, tank tracks and a rocket pod turret, {_ROBOT}"),
|
||||||
("opp_overlord", f"menacing black and red domed robot with a heavy horizontal spinning bar weapon, {_ROBOT}"),
|
("opp_overlord", f"menacing black and red round dome shell robot like an upturned wok on hidden wheels, long horizontal spinning steel bar across the front at floor height, {_ROBOT}"),
|
||||||
|
|
||||||
# shop mechanic (original character)
|
# shop mechanic (original character)
|
||||||
("npc_mechanic", "game character portrait, gruff middle-aged robot mechanic with welding goggles pushed up on the forehead, "
|
("npc_mechanic", "game character portrait, gruff middle-aged robot mechanic with welding goggles pushed up on the forehead, "
|
||||||
@@ -99,9 +100,57 @@ PROMPTS = [
|
|||||||
"even lighting, no perspective, no shadows"),
|
"even lighting, no perspective, no shadows"),
|
||||||
("tex_wall", "seamless texture of dark painted steel wall panel with rivets and yellow black hazard stripe band, "
|
("tex_wall", "seamless texture of dark painted steel wall panel with rivets and yellow black hazard stripe band, "
|
||||||
"even lighting, front view, no perspective"),
|
"even lighting, front view, no perspective"),
|
||||||
|
|
||||||
|
# --- new towers ---
|
||||||
|
("part_zapper", f"robot turret: electric arc emitter with copper coils and crackling blue spark, {_STYLE}"),
|
||||||
|
("part_mortar", f"robot turret: short stubby mortar tube angled upwards on a base plate, {_STYLE}"),
|
||||||
|
("part_swarm", f"robot turret: boxy rocket pod with nine small launch tubes in a grid, {_STYLE}"),
|
||||||
|
# --- new armour ---
|
||||||
|
("part_mesh", f"set of thin steel wire mesh grille panels for a robot, {_STYLE}"),
|
||||||
|
("part_buffer", f"set of fat black rubber buffer blocks and bumpers for a robot, {_STYLE}"),
|
||||||
|
("part_spiked", f"set of steel armour plates covered in short sharp spikes, {_STYLE}"),
|
||||||
|
("part_ceramic", f"set of pale ceramic armour tiles in a grid, chipped edges, {_STYLE}"),
|
||||||
|
# --- new chassis ---
|
||||||
|
("part_cage", f"open welded tube frame robot chassis, bare scrap metal cage, no panels, {_STYLE}"),
|
||||||
|
("part_hexpod", f"six-sided hexagonal robot chassis shell with angled sloping sides, {_STYLE}"),
|
||||||
|
("part_boiler", f"robot chassis made from a rolled steel drum lying on its side, riveted bands, {_STYLE}"),
|
||||||
|
("part_fang", f"long low arrow-shaped robot chassis with a sharp pointed prow, {_STYLE}"),
|
||||||
|
("part_plough", f"robot chassis with a big angled snowplough blade bolted across the nose, {_STYLE}"),
|
||||||
|
("part_discus", f"wide flat round disc-shaped robot chassis, very low, {_STYLE}"),
|
||||||
|
# --- new wheels ---
|
||||||
|
("part_omni", f"set of small omni-directional caster wheels with rollers and steel forks, {_STYLE}"),
|
||||||
|
("part_studs", f"pair of chunky studded off-road robot tyres with metal spikes, {_STYLE}"),
|
||||||
|
("part_drumwh", f"single wide steel roller drum wheel with a hub, {_STYLE}"),
|
||||||
|
("part_hover", f"robot hover skirt, a flat plate over a glowing orange air cushion ring, {_STYLE}"),
|
||||||
|
# --- new weapons ---
|
||||||
|
("part_lance", f"long pointed steel ramming lance spike on a front mount, {_STYLE}"),
|
||||||
|
("part_drill", f"robot weapon: large conical spinning auger drill bit with spiral flutes, {_STYLE}"),
|
||||||
|
("part_mace", f"robot weapon: heavy spiked steel ball mace on a swinging arm, {_STYLE}"),
|
||||||
|
("part_launcher", f"robot weapon: huge curved scoop launcher plate on a hinge, {_STYLE}"),
|
||||||
|
("part_drum", f"robot weapon: thick horizontal spinning drum rotor with hardened teeth, {_STYLE}"),
|
||||||
|
("part_lifter", f"robot weapon: wide two-prong lifting scoop on a hinge, {_STYLE}"),
|
||||||
|
("part_vdisc", f"robot weapon: large upright vertical spinning disc with four cutting teeth, {_STYLE}"),
|
||||||
|
# --- gadgets ---
|
||||||
|
("part_righter", f"robot gadget: pop-out self-righting lever arm device, {_STYLE}"),
|
||||||
|
("part_turbo", f"robot gadget: nitro boost canister with orange flame jets, {_STYLE}"),
|
||||||
|
("part_shield", f"robot gadget: glowing blue energy deflector field emitter dish, {_STYLE}"),
|
||||||
|
("part_repair", f"robot gadget: repair kit toolbox with a red cross and a wrench, {_STYLE}"),
|
||||||
|
("part_emp", f"robot gadget: EMP burst coil emitter crackling with blue electricity, {_STYLE}"),
|
||||||
|
("slot_gadget", f"robot utility gadget module, {_ICON}"),
|
||||||
|
|
||||||
|
# --- title logo (wide lettering) + text-free emblem fallback ---
|
||||||
|
("logo", "game logo lettering that reads exactly 'ROBOT CLASH', two words on two lines, bold industrial "
|
||||||
|
"block capitals cut from brushed scratched steel, thick bevelled edges, orange rim glow, small "
|
||||||
|
"yellow and black hazard stripe accents, a few sparks, centred, plain solid black background, "
|
||||||
|
"no extra words, no frame, no border"),
|
||||||
|
("logo_emblem", "game logo emblem without any text: a crossed wrench and circular saw blade behind a low "
|
||||||
|
"flat wedge-shaped battle robot head with two glowing orange eyes, inside a worn steel "
|
||||||
|
"badge with hazard stripes, bold simple silhouette, centred single subject, "
|
||||||
|
"plain solid black background"),
|
||||||
]
|
]
|
||||||
|
|
||||||
SIZES = {
|
SIZES = {
|
||||||
|
"logo": (1344, 576), "logo_emblem": (1024, 1024),
|
||||||
"bg_workshop": (1536, 864), "bg_title": (1536, 864), "bg_win": (1536, 864), "bg_lose": (1536, 864),
|
"bg_workshop": (1536, 864), "bg_title": (1536, 864), "bg_win": (1536, 864), "bg_lose": (1536, 864),
|
||||||
"npc_mechanic": (832, 1024),
|
"npc_mechanic": (832, 1024),
|
||||||
}
|
}
|
||||||
|
|||||||
53
sprite-generator/variants.py
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
"""Robot Clash - shop images made from the real 3D parts (generate_variants.py, Flux.2 Klein + ReferenceLatent).
|
||||||
|
|
||||||
|
Reference r3d_<id> = the part exactly as the game builds it (tools/partshots.ps1 renders them into output/).
|
||||||
|
Flux keeps shape, proportions and viewing angle and paints it in the sprite style, so the shop picture
|
||||||
|
matches what ends up on the robot.
|
||||||
|
|
||||||
|
..\\tools\\partshots.ps1 3D renders -> output/r3d_<id>_raw_00001_.png
|
||||||
|
gen generate_variants all part images (part_<id>)
|
||||||
|
gen adopt --size 192 part_<id>
|
||||||
|
|
||||||
|
VARIANTS = [(name, ref_name, prompt)]
|
||||||
|
"""
|
||||||
|
STYLE = (
|
||||||
|
"keep exactly the same object, the same shape, proportions, parts and viewing angle as the reference image; "
|
||||||
|
"render it as a detailed game sprite: scratched painted steel, bolts and rivets, small yellow and black hazard stripe details, "
|
||||||
|
"soft studio lighting, crisp edges, high detail, centred single subject, plain solid black background, no text"
|
||||||
|
)
|
||||||
|
|
||||||
|
_P = {
|
||||||
|
'crate': "a plain rectangular steel robot chassis box with a raised accent strip on top",
|
||||||
|
'doorstop': "a low wedge-shaped steel robot chassis, flat sloped front, hazard stripes on the flat rear deck",
|
||||||
|
'bulwark': "a large heavy rectangular steel robot chassis box with a raised accent strip on top",
|
||||||
|
'scarab': "a robot chassis base plate with a smooth round steel dome shell and an accent ring around the dome",
|
||||||
|
'rubber': "a set of four small rubber robot wheels with steel hubs",
|
||||||
|
'bigtyre': "a pair of huge chunky rubber tyres with steel hubs",
|
||||||
|
'tracks': "a pair of long tank crawler tracks with round end wheels",
|
||||||
|
'steel': "a U-shaped set of three plain grey riveted steel armour plates (two side plates and a rear plate)",
|
||||||
|
'titan': "a U-shaped set of three light blue-grey titanium armour panels with bolts",
|
||||||
|
'hardox': "a U-shaped set of three thick yellowish hardened steel wear plates with heavy bolts",
|
||||||
|
'wedge': "a flat angled steel ramming wedge plate",
|
||||||
|
'flipper': "a flat steel flipper plate with an accent stripe, hinged at its rear edge",
|
||||||
|
'hammer': "a robot axe hammer: long steel arm on a pivot block with an axe head pointing down at the end",
|
||||||
|
'saw': "a large circular saw blade on a short motor arm",
|
||||||
|
'crusher': "two hydraulic crusher jaw arms side by side with sharp teeth at the tips",
|
||||||
|
'spinner': "a long horizontal steel spinner bar with hardened teeth blocks at both ends on a central hub",
|
||||||
|
'flamer': "a small robot turret base with a red fuel tank and a steel flamethrower nozzle",
|
||||||
|
'minigun': "a small robot turret base with a housing and a rotating multi-barrel minigun",
|
||||||
|
'rockets': "a small robot turret base carrying a box-shaped rocket pod with four tubes",
|
||||||
|
}
|
||||||
|
|
||||||
|
VARIANTS = [(f"part_{k}", f"r3d_{k}", v) for k, v in _P.items()]
|
||||||
|
|
||||||
|
# motor + battery are not visible on the 3D robot: restyle the existing picture (reference = itself)
|
||||||
|
_INNER = {
|
||||||
|
'sparky': "a small cheap electric motor with a few wires",
|
||||||
|
'hornet': "a sleek electric motor with cooling fins",
|
||||||
|
'bulldog': "a massive high torque gear motor with a big gearbox",
|
||||||
|
'comet': "a high speed racing electric motor with a glowing blue cooling ring",
|
||||||
|
'lead': "a heavy old lead acid battery block with two terminals",
|
||||||
|
'nicd': "a pack of green battery cells strapped together",
|
||||||
|
'lipo': "a slim modern lithium battery stack with small charge lights",
|
||||||
|
}
|
||||||
|
VARIANTS += [(f"part_{k}", f"part_{k}", v) for k, v in _INNER.items()]
|
||||||
84
tests/online.test.js
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
// Live test against the real Firebase project (needs network): node --experimental-eventsource tests/online.test.js
|
||||||
|
// Creates two throw-away accounts, runs lobby -> challenge -> match -> state/input sync, then deletes everything.
|
||||||
|
'use strict';
|
||||||
|
const path = require('path');
|
||||||
|
const mem = {};
|
||||||
|
global.window = globalThis;
|
||||||
|
global.Kit = { store: () => ({ get: (k, d) => (k in mem ? mem[k] : d), set: (k, v) => { mem[k] = v; } }), cleanName: s => String(s || '').slice(0, 20) };
|
||||||
|
for (const f of ['parts.js', 'robot.js', 'combat.js', 'ai.js', 'net.js', 'lobby.js', 'netfight.js']) require(path.join(__dirname, '..', 'game', f));
|
||||||
|
const RC = globalThis.RC;
|
||||||
|
const CFG = { apiKey: 'AIzaSyCE29VQnubM_9ok46nnosg07MpvhZH3O5w', dbUrl: 'https://robot-clash-aa37b-default-rtdb.firebaseio.com' };
|
||||||
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||||||
|
let fails = 0;
|
||||||
|
const ok = (c, msg) => { console.log((c ? 'ok ' : 'FAIL ') + msg); if (!c) fails++; };
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const stamp = Date.now();
|
||||||
|
const A = RC.Net(CFG), B = RC.Net(CFG);
|
||||||
|
ok(A.enabled, 'config accepted');
|
||||||
|
const ra = await A.auth.register(`rc-test-a-${stamp}@example.com`, 'test-pass-123', 'TestA');
|
||||||
|
const rb = await B.auth.register(`rc-test-b-${stamp}@example.com`, 'test-pass-123', 'TestB');
|
||||||
|
ok(ra.ok && rb.ok, `register two accounts ${ra.error || ''} ${rb.error || ''}`);
|
||||||
|
if (!ra.ok || !rb.ok) process.exit(1);
|
||||||
|
const again = RC.Net(CFG); const rl = await again.auth.login(`RC-TEST-A-${stamp}@example.com `, 'test-pass-123');
|
||||||
|
ok(rl.ok && again.auth.current.name === 'TestA', `login again shows the real name (${again.auth.current && again.auth.current.name}), e-mail case/space tolerant`);
|
||||||
|
const G = RC.Net(CFG); const rg = await G.auth.guest('GastTest');
|
||||||
|
ok(rg.ok && G.auth.current.guest, 'anonymous guest sign-in ' + (rg.error || ''));
|
||||||
|
const LG = RC.Lobby({ net: G, getProfile: () => ({ name: 'GastTest', flag: 'DE', build: RC.STARTER, paint: { body: 1, accent: 2 }, fame: 0 }) });
|
||||||
|
await LG.enter();
|
||||||
|
const wrong = await RC.Net(CFG).auth.login(`rc-test-a-${stamp}@example.com`, 'nope-nope');
|
||||||
|
ok(!wrong.ok, 'wrong password rejected: ' + wrong.error);
|
||||||
|
|
||||||
|
const prof = n => () => ({ name: n, flag: 'DE', build: RC.STARTER, paint: { body: 1, accent: 2 }, fame: 5 });
|
||||||
|
const LA = RC.Lobby({ net: A, getProfile: prof('TestA') }), LB = RC.Lobby({ net: B, getProfile: prof('TestB') });
|
||||||
|
let listA = [], incomingB = null, matchA = null, matchB = null;
|
||||||
|
LA.onList(r => { listA = r; }); LB.onIncoming(c => { incomingB = c; });
|
||||||
|
LA.onMatch(m => { matchA = m; }); LB.onMatch(m => { matchB = m; });
|
||||||
|
await LA.enter(); await LB.enter();
|
||||||
|
await sleep(2500);
|
||||||
|
ok(listA.some(r => r.uid === B.uid && r.name === 'TestB' && r.flag === 'DE'), 'A sees B in the lobby (push stream)');
|
||||||
|
ok(listA.some(r => r.uid === G.uid && r.name === 'GastTest'), 'A sees the anonymous guest in the lobby');
|
||||||
|
LG.leave();
|
||||||
|
|
||||||
|
LA.challenge(B.uid);
|
||||||
|
await sleep(2500);
|
||||||
|
ok(incomingB && incomingB.from === A.uid, 'B receives the challenge');
|
||||||
|
const t0 = Date.now();
|
||||||
|
if (incomingB) await LB.accept(A.uid);
|
||||||
|
while (!(matchA && matchB) && Date.now() - t0 < 12000) await sleep(100);
|
||||||
|
console.log(` match start took ${Date.now() - t0} ms (A ${!!matchA}, B ${!!matchB})`);
|
||||||
|
ok(matchA && matchB && matchA.id === matchB.id, 'both sides get the match');
|
||||||
|
ok(matchA && matchB && matchA.host !== matchB.host, 'exactly one host');
|
||||||
|
ok(matchA && matchA.opp.name === 'TestB' && matchB.opp.name === 'TestA', 'opponent data arrives');
|
||||||
|
|
||||||
|
if (matchA && matchB) {
|
||||||
|
const host = matchA.host ? A : B, guest = matchA.host ? B : A, id = matchA.id;
|
||||||
|
const mk = () => RC.Combat.create({ robots: [RC.stats(RC.STARTER), RC.stats(RC.STARTER)], seed: matchA.seed });
|
||||||
|
const sH = mk(), sG = mk();
|
||||||
|
const nfH = RC.NetFight({ net: host, id, host: true }), nfG = RC.NetFight({ net: guest, id, host: false });
|
||||||
|
nfH.start(); nfG.start();
|
||||||
|
for (let i = 0; i < 35; i++) { nfH.idle(0.1); nfG.idle(0.1); await sleep(100); } // 3.5 s countdown like the game
|
||||||
|
for (let i = 0; i < 180; i++) { // 3 s real time
|
||||||
|
nfH.hostStep(sH, { throttle: 1, turn: 0 }, 1 / 60); sH.events.length = 0;
|
||||||
|
nfG.guestFrame(sG, { throttle: 1, turn: 0.5, fire: false, fire2: false }, 1 / 60);
|
||||||
|
await sleep(16);
|
||||||
|
}
|
||||||
|
await sleep(800);
|
||||||
|
nfG.guestFrame(sG, { throttle: 1, turn: 0.5, fire: false, fire2: false }, 1 / 60);
|
||||||
|
ok(sG.t > 1, `guest receives host snapshots (t=${sG.t.toFixed(2)})`);
|
||||||
|
ok(Math.abs(sG.robots[1].x - sH.robots[0].x) < 1.5, `guest sees host robot near its real place (${sG.robots[1].x.toFixed(2)} vs ${sH.robots[0].x.toFixed(2)})`);
|
||||||
|
ok(Math.abs(sH.robots[1].a - Math.PI) > 0.2, `host applies guest input (guest robot turned, a=${sH.robots[1].a.toFixed(2)})`);
|
||||||
|
ok(nfH.peerAlive && nfG.peerAlive, 'both peers alive');
|
||||||
|
// rules: guest must not be able to write the state, a stranger must not read the match
|
||||||
|
ok((await guest.db.put(`matches/${id}/state`, { seq: 1 })) === false, 'rule: guest cannot write host state');
|
||||||
|
nfH.stop(); nfG.stop();
|
||||||
|
}
|
||||||
|
// cleanup: lobby, match, challenge, accounts
|
||||||
|
LA.endMatch(); LB.endMatch(); await sleep(500); LA.leave(); LB.leave(); await sleep(800);
|
||||||
|
for (const n of [A, B, G]) {
|
||||||
|
const t = await n.token();
|
||||||
|
await fetch(`https://identitytoolkit.googleapis.com/v1/accounts:delete?key=${CFG.apiKey}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ idToken: t }) });
|
||||||
|
}
|
||||||
|
console.log(fails ? `${fails} failure(s)` : 'all ok');
|
||||||
|
process.exit(fails ? 1 : 0);
|
||||||
|
})();
|
||||||
@@ -52,5 +52,144 @@ ok(wins.overlord >= wins.rustbucket, 'top robot beats bottom robot more often');
|
|||||||
RC.Combat.step(s, 1 / 60, [{}, {}]);
|
RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
ok(s.result && s.result.winner === 1 && s.result.reason === 'pit', 'pit = loss');
|
ok(s.result && s.result.winner === 1 && s.result.reason === 'pit', 'pit = loss');
|
||||||
}
|
}
|
||||||
|
// gadgets
|
||||||
|
ok(RC.validate({ ...RC.STARTER, gadget: 'turbo' }).ok, 'gadget build valid');
|
||||||
|
ok(RC.stats({ ...RC.STARTER, gadget: 'emp' }).gadget.type === 'emp', 'gadget in stats');
|
||||||
|
{
|
||||||
|
// repair kit heals and spends a charge
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, gadget: 'repair' }), RC.stats(RC.STARTER)], seed: 2 });
|
||||||
|
const r = s.robots[0]; r.hp = r.maxHp * 0.3; const before = r.hp, uses = r.gUses;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
ok(r.hp > before && r.gUses === uses - 1, 'repair heals + spends charge');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// shield cuts incoming damage
|
||||||
|
const base = RC.stats(RC.STARTER), s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, gadget: 'shield' }), base], seed: 3 });
|
||||||
|
const r = s.robots[0];
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
ok(r.shield > 0, 'shield active after use');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// emp stuns a nearby enemy
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, gadget: 'emp' }), RC.stats(RC.STARTER)], seed: 4 });
|
||||||
|
const a = s.robots[0], b = s.robots[1]; b.x = a.x + 1; b.z = a.z;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
ok(b.stun > 0, 'emp stuns nearby enemy');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// self-righter flips a toppled robot back
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, gadget: 'righter' }), RC.stats(RC.STARTER)], seed: 5 });
|
||||||
|
const r = s.robots[0]; r.flipped = 2;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
ok(r.flipped === 0, 'self-righter clears flipped');
|
||||||
|
}
|
||||||
|
|
||||||
|
// cooldown readout for the fight HUD
|
||||||
|
{
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, weapon: 'hammer', tower: 'rockets', gadget: 'repair' }), RC.stats(RC.STARTER)], seed: 6 });
|
||||||
|
const r = s.robots[0];
|
||||||
|
let cd = RC.Combat.cooldowns(r);
|
||||||
|
ok(cd.length === 3 && cd.map(c => c.slot).join() === 'weapon,tower,gadget', 'cooldowns: one entry per fitted slot');
|
||||||
|
ok(cd.every(c => c.p === 0), 'cooldowns: everything ready at the start');
|
||||||
|
ok(cd[2].n === 2, 'cooldowns: repair kit reports its charges');
|
||||||
|
r.hp = r.maxHp * 0.5;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire: true, fire2: true, fire3: true }, {}]);
|
||||||
|
cd = RC.Combat.cooldowns(r);
|
||||||
|
ok(cd[0].p > 0.9 && cd[1].p > 0.9 && cd[2].p > 0.9, 'cooldowns: full right after use');
|
||||||
|
ok(cd[2].n === 1, 'cooldowns: repair charge was spent');
|
||||||
|
for (let i = 0; i < 60 * 12; i++) RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
ok(RC.Combat.cooldowns(r).every(c => c.p === 0), 'cooldowns: back to zero when they ran out');
|
||||||
|
}
|
||||||
|
|
||||||
|
// battle damage: parts tear off at fixed shares of health
|
||||||
|
{
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, armour: 'steel', weapon: 'hammer' }), RC.stats(RC.STARTER)], seed: 7 });
|
||||||
|
const r = s.robots[0], A = s.arena;
|
||||||
|
r.x = A.saws[0].x; r.z = A.saws[0].z; // park him on a floor saw so he keeps taking hits
|
||||||
|
r.hp = r.maxHp * 0.61;
|
||||||
|
const broke = [];
|
||||||
|
for (let i = 0; i < 60 * 2 && !s.result; i++) {
|
||||||
|
RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
for (const e of s.events) if (e.type === 'broke') broke.push(e.part);
|
||||||
|
s.events.length = 0;
|
||||||
|
}
|
||||||
|
ok(r.hp < r.maxHp * 0.6, 'the saw actually did damage');
|
||||||
|
ok(broke.includes('armour'), 'armour tears off below 60% health');
|
||||||
|
ok(r.lost.armour === true, 'the robot remembers the lost armour');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, weapon: 'hammer' }), RC.stats(RC.STARTER)], seed: 8 });
|
||||||
|
const r = s.robots[0];
|
||||||
|
r.lost.weapon = true;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire: true }, {}]);
|
||||||
|
ok(r.swing === 0 && r.cd === 0, 'a torn-off weapon cannot be fired any more');
|
||||||
|
ok(RC.Combat.cooldowns(r)[0].broke === true, 'the HUD is told the weapon is gone');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const speed = lost => {
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats(RC.STARTER), RC.stats(RC.STARTER)], seed: 9 });
|
||||||
|
const r = s.robots[0];
|
||||||
|
if (lost) r.lost.wheels = true;
|
||||||
|
for (let i = 0; i < 120; i++) RC.Combat.step(s, 1 / 60, [{ throttle: 1 }, {}]);
|
||||||
|
return Math.hypot(r.vx, r.vz);
|
||||||
|
};
|
||||||
|
ok(speed(true) < speed(false) * 0.95, 'a burst wheel slows the robot down');
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- arena furniture: cover, belts, oil, and the new outlines ---
|
||||||
|
const arenaById = id => RC.ARENAS.find(a => a.id === id);
|
||||||
|
function drive(arenaId, place, input, secs) {
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats(RC.STARTER), RC.stats(RC.STARTER)], seed: 11, arena: arenaId });
|
||||||
|
const r = s.robots[0];
|
||||||
|
Object.assign(r, place);
|
||||||
|
for (let i = 0; i < 60 * secs && !s.result; i++) { RC.Combat.step(s, 1 / 60, [input, {}]); s.events.length = 0; }
|
||||||
|
return { s, r };
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// every arena must be built sanely: nothing outside the outline, nothing buried in a block
|
||||||
|
const rad = RC.stats(RC.STARTER).rad * 0.9;
|
||||||
|
let bad = [];
|
||||||
|
for (const A of RC.ARENAS) {
|
||||||
|
const out = [];
|
||||||
|
for (const p of A.starts) if (RC.wallPush(A, p.x, p.z, rad) || RC.inBlock(A, p.x, p.z, rad)) out.push('start');
|
||||||
|
if (RC.wallPush(A, A.pit.x, A.pit.z, A.pit.hw) || RC.inBlock(A, A.pit.x, A.pit.z, 0)) out.push('pit');
|
||||||
|
for (const g of [A.press, A.crane]) if (RC.wallPush(A, g.x, g.z, g.hw)) out.push('guardian');
|
||||||
|
for (const h of A.saws) if (RC.wallPush(A, h.x, h.z, h.r)) out.push('saw');
|
||||||
|
for (const h of A.flames) if (RC.wallPush(A, h.x, h.z, h.hw)) out.push('flame');
|
||||||
|
for (const b of A.blocks) if (RC.wallPush(A, b.x, b.z, Math.max(b.hw, b.hd))) out.push('block');
|
||||||
|
if (out.length) bad.push(A.id + ':' + out.join('/'));
|
||||||
|
}
|
||||||
|
ok(bad.length === 0, 'every arena fits inside its own outline (' + bad.join(' ') + ')');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// a pillar is solid: driving at it does not get you through
|
||||||
|
const A = arenaById('crucible'), b = A.blocks[0];
|
||||||
|
const { r } = drive('crucible', { x: 0, z: -5, a: Math.PI / 2 }, { throttle: 1 }, 4);
|
||||||
|
ok(r.z < b.z - b.hd, 'a solid block stops the robot (z=' + r.z.toFixed(2) + ')');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// conveyor belt drags a robot that is not even driving
|
||||||
|
const A = arenaById('colosseum'), bl = A.belts[0];
|
||||||
|
const { r } = drive('colosseum', { x: bl.x, z: bl.z - 1, a: 0 }, {}, 1.2);
|
||||||
|
ok(r.z > bl.z - 1 + 0.4, 'the belt drags an idle robot along (dz=' + (r.z - bl.z + 1).toFixed(2) + ')');
|
||||||
|
}
|
||||||
|
{
|
||||||
|
// oil makes steering mushy
|
||||||
|
const turn = place => Math.abs(drive('scrapyard', place, { throttle: 1, turn: 1 }, 0.6).r.av);
|
||||||
|
const dry = turn({ x: 7.5, z: -1, a: 0 }), wet = turn({ x: -2.4, z: 1, a: 0 });
|
||||||
|
ok(wet < dry * 0.85, 'oil cuts the turn rate (dry ' + dry.toFixed(2) + ' vs oil ' + wet.toFixed(2) + ')');
|
||||||
|
}
|
||||||
|
for (const id of ['crucible', 'colosseum', 'foundry', 'arena64']) {
|
||||||
|
// round and octagon walls must hold the robot in
|
||||||
|
const A = arenaById(id), rad = RC.stats(RC.STARTER).rad * 0.9;
|
||||||
|
let worst = 0;
|
||||||
|
for (const dir of [0, 1, 2, 3, 4, 5, 6, 7]) {
|
||||||
|
const a = dir / 8 * Math.PI * 2;
|
||||||
|
const { r } = drive(id, { x: 0, z: 0, a, vx: 0, vz: 0 }, { throttle: 1 }, 6);
|
||||||
|
if (RC.wallPush(A, r.x, r.z, rad * 0.98)) worst++;
|
||||||
|
}
|
||||||
|
ok(worst === 0, `${A.shape} wall of ${id} keeps the robot inside`);
|
||||||
|
}
|
||||||
|
|
||||||
console.log(fails ? `${fails} failure(s)` : 'all ok');
|
console.log(fails ? `${fails} failure(s)` : 'all ok');
|
||||||
process.exit(fails ? 1 : 0);
|
process.exit(fails ? 1 : 0);
|
||||||
|
|||||||
56
tools/partshot.html
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<!-- Dev tool (not shipped): renders ONE robot part exactly as the game builds it in 3D, on black,
|
||||||
|
3/4 view from the front right. Used as reference for the shop images (ComfyGen generate_variants).
|
||||||
|
partshot.html?id=flipper part id from game/parts.js (chassis, armour, wheels, weapon, tower)
|
||||||
|
partshot.html?id=flipper&size=768 canvas size in px
|
||||||
|
Screenshot via Chrome headless: tools/partshots.ps1 -->
|
||||||
|
<html><head><meta charset="utf-8"><title>partshot</title>
|
||||||
|
<style>html,body{margin:0;background:#000;overflow:hidden}canvas{display:block}</style></head>
|
||||||
|
<body>
|
||||||
|
<canvas id="c"></canvas>
|
||||||
|
<script src="../game/vendor/three.min.js"></script>
|
||||||
|
<script src="../game/kit/kit-core.js"></script>
|
||||||
|
<script src="../game/parts.js"></script>
|
||||||
|
<script src="../game/robot.js"></script>
|
||||||
|
<script src="../game/combat.js"></script>
|
||||||
|
<script src="../game/looks.js"></script>
|
||||||
|
<script src="../game/render3d.js"></script>
|
||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
const T = THREE, q = new URLSearchParams(location.search);
|
||||||
|
const id = q.get('id') || 'flipper', size = +q.get('size') || 768, p = RC.PARTS[id];
|
||||||
|
const cv = document.getElementById('c');
|
||||||
|
const renderer = new T.WebGLRenderer({ canvas: cv, antialias: true, preserveDrawingBuffer: true });
|
||||||
|
renderer.setPixelRatio(1); renderer.setSize(size, size);
|
||||||
|
renderer.outputEncoding = T.sRGBEncoding; renderer.toneMapping = T.ACESFilmicToneMapping; renderer.toneMappingExposure = 0.85;
|
||||||
|
const scene = new T.Scene(); scene.background = new T.Color(0x000000);
|
||||||
|
scene.add(new T.HemisphereLight(0xc8d4ea, 0x2a2018, 0.9));
|
||||||
|
const key = new T.DirectionalLight(0xfff2e0, 1.9); key.position.set(3, 6, 4); scene.add(key);
|
||||||
|
const rimA = new T.DirectionalLight(0xff8a3a, 0.9); rimA.position.set(-4, 2, 3); scene.add(rimA);
|
||||||
|
const rimB = new T.DirectionalLight(0x6aa8ff, 0.8); rimB.position.set(-2, 3, -5); scene.add(rimB);
|
||||||
|
|
||||||
|
// neutral steel paint with orange accent - the player paints the body later, parts keep their own colours
|
||||||
|
const build = Object.assign({}, RC.STARTER, { [p.slot]: id });
|
||||||
|
if (p.slot === 'weapon' || p.slot === 'tower') build.armour = null;
|
||||||
|
const R = RC.buildRobotModel(build, { body: 0x8d939c, accent: 0xff7a1a });
|
||||||
|
scene.add(R.root);
|
||||||
|
R.tilt.children.forEach(o => { o.visible = o.userData.part === p.slot; });
|
||||||
|
|
||||||
|
// frame the visible pieces
|
||||||
|
// only visible, solid meshes (the hidden flame cone of the flamer would blow up the frame)
|
||||||
|
R.root.updateMatrixWorld(true);
|
||||||
|
const bb = new T.Box3();
|
||||||
|
R.tilt.children.forEach(o => { if (o.visible) o.traverse(m => {
|
||||||
|
if (m.isMesh && m.visible && !m.material.transparent) { m.geometry.computeBoundingBox(); bb.union(m.geometry.boundingBox.clone().applyMatrix4(m.matrixWorld)); }
|
||||||
|
}); });
|
||||||
|
const c = bb.getCenter(new T.Vector3()), s = bb.getSize(new T.Vector3()), r = s.length() / 2;
|
||||||
|
const cam = new T.PerspectiveCamera(28, 1, 0.05, 100);
|
||||||
|
const dir = new T.Vector3(1, 0.78, 0.95).normalize();
|
||||||
|
cam.position.copy(c).addScaledVector(dir, r / Math.sin(T.MathUtils.degToRad(14)) * 1.12);
|
||||||
|
cam.lookAt(c);
|
||||||
|
renderer.render(scene, cam);
|
||||||
|
document.title = 'done';
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body></html>
|
||||||
26
tools/partshots.ps1
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Renders every visible robot part (chassis, armour, wheels, weapon, tower) with tools/partshot.html
|
||||||
|
# into sprite-generator/output/r3d_<id>_raw_00001_.png - references for the shop images:
|
||||||
|
# .\tools\partshots.ps1 all parts
|
||||||
|
# .\tools\partshots.ps1 flipper one part
|
||||||
|
# Then in sprite-generator: gen generate_variants (variants.py), gen adopt --size 192 part_<id>
|
||||||
|
param([string[]]$Ids)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$root = Split-Path $PSScriptRoot -Parent
|
||||||
|
$chrome = @("$env:ProgramFiles\Google\Chrome\Application\chrome.exe", "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") |
|
||||||
|
Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
|
if (-not $chrome) { throw 'Chrome or Edge not found' }
|
||||||
|
if (-not $Ids) {
|
||||||
|
$Ids = 'crate', 'doorstop', 'bulwark', 'scarab', 'rubber', 'bigtyre', 'tracks', 'steel', 'titan', 'hardox',
|
||||||
|
'wedge', 'flipper', 'hammer', 'saw', 'crusher', 'spinner', 'flamer', 'minigun', 'rockets'
|
||||||
|
}
|
||||||
|
$out = Join-Path $root 'sprite-generator\output'
|
||||||
|
New-Item -ItemType Directory -Force $out | Out-Null
|
||||||
|
$profileDir = Join-Path $env:TEMP 'robotclash-partshot'
|
||||||
|
$page = 'file:///' + ((Join-Path $root 'tools\partshot.html') -replace '\\', '/' -replace ' ', '%20')
|
||||||
|
$ErrorActionPreference = 'Continue' # Chrome reports "bytes written" on stderr
|
||||||
|
foreach ($id in $Ids) {
|
||||||
|
$png = Join-Path $out "r3d_${id}_raw_00001_.png"
|
||||||
|
& $chrome --headless=new --use-angle=swiftshader --enable-unsafe-swiftshader --hide-scrollbars --window-size=768,768 `
|
||||||
|
--virtual-time-budget=3000 --user-data-dir="$profileDir" --screenshot="$png" "${page}?id=$id&size=768" 2>&1 | Out-Null
|
||||||
|
if (Test-Path $png) { " r3d_$id -> $png" } else { " r3d_$id FAILED" }
|
||||||
|
}
|
||||||
27
tools/uishots.ps1
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Layout check: screenshots of every screen (Chrome headless) into tools\shots\.
|
||||||
|
# .\tools\uishots.ps1 desktop 1280x800
|
||||||
|
# .\tools\uishots.ps1 -Tablet tablet landscape 1024x768 + portrait 768x1024 (touch emulation)
|
||||||
|
param([switch]$Tablet)
|
||||||
|
$root = Split-Path $PSScriptRoot -Parent
|
||||||
|
$chrome = @("$env:ProgramFiles\Google\Chrome\Application\chrome.exe", "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe") |
|
||||||
|
Where-Object { Test-Path $_ } | Select-Object -First 1
|
||||||
|
if (-not $chrome) { throw 'Chrome or Edge not found' }
|
||||||
|
$out = Join-Path $PSScriptRoot 'shots'
|
||||||
|
New-Item -ItemType Directory -Force $out | Out-Null
|
||||||
|
$page = 'file:///' + ((Join-Path $root 'game\index.html') -replace '\\', '/' -replace ' ', '%20')
|
||||||
|
$screens = [ordered]@{
|
||||||
|
title = 'title'; shop_weapon = 'play'; shop_chassis = 'play&tab=chassis'; shop_wheels = 'play&tab=wheels'; shop_tower = 'play&tab=tower'
|
||||||
|
paint = 'play&paint'; league = 'play&screen=league'; vs = 'play&screen=vs'; settings = 'play&screen=settings'
|
||||||
|
help = 'play&screen=help'; lobby = 'play&screen=lobby'; fight_fpv = 'fight=3&ff=4'; fight_iso = 'fight=3&ff=4&cam=iso'
|
||||||
|
}
|
||||||
|
$sizes = if ($Tablet) { @(@{n='tabL';s='1024,768'}, @{n='tabP';s='768,1024'}) } else { @(@{n='desk';s='1280,800'}) }
|
||||||
|
foreach ($sz in $sizes) {
|
||||||
|
foreach ($k in $screens.Keys) {
|
||||||
|
$png = Join-Path $out "$($sz.n)_$k.png"
|
||||||
|
$cargs = @('--headless=new', '--use-angle=swiftshader', '--enable-unsafe-swiftshader', '--hide-scrollbars', "--window-size=$($sz.s)",
|
||||||
|
'--virtual-time-budget=5000', "--user-data-dir=$env:TEMP\robotclash-uishots", "--screenshot=$png")
|
||||||
|
if ($Tablet) { $cargs += '--touch-events=enabled'; $cargs += '--blink-settings=primaryPointerType=2,availablePointerTypes=2,primaryHoverType=1,availableHoverTypes=1' }
|
||||||
|
& $chrome @cargs "${page}?$($screens[$k])" 2>&1 | Out-Null
|
||||||
|
" $($sz.n)_$k"
|
||||||
|
}
|
||||||
|
}
|
||||||