map change
This commit is contained in:
@@ -65,10 +65,13 @@ for (const [token, tag] of await Promise.all(scriptJobs)) html = html.replace(to
|
|||||||
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));
|
||||||
// everything the scripts load at runtime: must come before the first other <script>
|
// everything the scripts load at runtime: must come before the first other <script>
|
||||||
html = html.replace('<script>', () => `<script>window.KIT_ASSETS = ${JSON.stringify(assets)};</script>\n<script>`);
|
// build stamp: identifies this exact release, so a leaked copy can be traced back
|
||||||
|
const BUILD = new Date().toISOString().slice(0, 16).replace('T', '.').replace(/[:-]/g, '');
|
||||||
|
html = html.replace('<script>', () => `<script>window.RC_BUILD = ${JSON.stringify(BUILD)};window.KIT_ASSETS = ${JSON.stringify(assets)};</script>\n<script>`);
|
||||||
|
|
||||||
|
html = html.replace('<head>', () => '<head><!-- Robot Clash (c) 2026 Michael Media | https://michael-media.de | build ' + BUILD + ' | Alle Rechte vorbehalten. Weitergabe oder Neuveroeffentlichung dieser Datei ist nicht gestattet. -->');
|
||||||
const out = path.join(root, 'release', 'robotclash.html');
|
const out = path.join(root, 'release', 'robotclash.html');
|
||||||
fs.mkdirSync(path.dirname(out), { recursive: true });
|
fs.mkdirSync(path.dirname(out), { recursive: true });
|
||||||
fs.writeFileSync(out, html);
|
fs.writeFileSync(out, html);
|
||||||
const mb = n => (n / 1024 / 1024).toFixed(1);
|
const mb = n => (n / 1024 / 1024).toFixed(1);
|
||||||
console.log(`Fertig: ${out} (${mb(fs.statSync(out).size)} MB, ${Object.keys(assets).length} Assets, ${mb(bytes)} MB roh)`);
|
console.log(`Fertig: ${out} (${mb(fs.statSync(out).size)} MB, ${Object.keys(assets).length} Assets, ${mb(bytes)} MB roh, Build ${BUILD})`);
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
// solid cover and slicks: drive round them, they are not deadly
|
// 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 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;
|
for (const o of ar.oil || []) if (Math.hypot(x - o.x, z - o.z) < o.r) return 1;
|
||||||
|
for (const mn of s.mines || []) if (mn.arm <= 0 && Math.hypot(x - mn.x, z - mn.z) < mn.r + me.st.rad) return 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
game/assets/Sprites/part_liion.png
Normal file
BIN
game/assets/Sprites/part_liion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
game/assets/Sprites/part_mines.png
Normal file
BIN
game/assets/Sprites/part_mines.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
game/assets/Sprites/part_supercap.png
Normal file
BIN
game/assets/Sprites/part_supercap.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
@@ -148,7 +148,7 @@
|
|||||||
const s = {
|
const s = {
|
||||||
arena: A, t: 0, left: A.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), A)),
|
robots: opt.robots.map((st, i) => makeRobot(st, i, (opt.names || [])[i] || 'Robot ' + (i + 1), A)),
|
||||||
rockets: [], events: [], result: null, endIn: 0,
|
rockets: [], mines: [], 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: A.crane.x, z: A.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,
|
||||||
@@ -243,6 +243,7 @@
|
|||||||
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++) 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);
|
||||||
|
mines(s, dt);
|
||||||
hazards(s, dt);
|
hazards(s, dt);
|
||||||
|
|
||||||
if (!s.result && s.left <= 0) {
|
if (!s.result && s.left <= 0) {
|
||||||
@@ -541,6 +542,17 @@
|
|||||||
if (r.gUses <= 0) return;
|
if (r.gUses <= 0) return;
|
||||||
r.hp = Math.min(r.maxHp, r.hp + r.maxHp * g.heal); r.gUses--; r.gcd = g.cd;
|
r.hp = Math.min(r.maxHp, r.hp + r.maxHp * g.heal); r.gUses--; r.gcd = g.cd;
|
||||||
break;
|
break;
|
||||||
|
case 'mines': { // drop a mine behind you
|
||||||
|
if (r.gUses <= 0) return;
|
||||||
|
const [mx, mz] = fwd(r);
|
||||||
|
const d = r.st.len / 2 + 0.9; // well behind, not under your own tail
|
||||||
|
r.gUses--; r.gcd = g.cd;
|
||||||
|
// own: the layer is safe for a moment - drive back over it later and it still gets you
|
||||||
|
s.mines.push({ x: r.x - mx * d, z: r.z - mz * d, owner: r.i, arm: g.arm, own: 3,
|
||||||
|
r: g.r, dmg: g.dmg, launch: g.launch });
|
||||||
|
s.events.push({ type: 'mine_drop', who: r.i, x: r.x - mx * d, z: r.z - mz * d });
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 'emp': // stun the enemy if close
|
case 'emp': // stun the enemy if close
|
||||||
r.gcd = g.cd;
|
r.gcd = g.cd;
|
||||||
if (!e.out && Math.hypot(e.x - r.x, e.z - r.z) < g.range + e.st.rad) {
|
if (!e.out && Math.hypot(e.x - r.x, e.z - r.z) < g.range + e.st.rad) {
|
||||||
@@ -563,10 +575,33 @@
|
|||||||
case 'shield': return dist < 3 && me.flipped <= 0;
|
case 'shield': return dist < 3 && me.flipped <= 0;
|
||||||
case 'repair': return me.gUses > 0 && me.hp < me.maxHp * 0.45;
|
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);
|
case 'emp': return !e.out && dist < g.range * 0.9 && (e.boost > 0 || e.spin > 0.2 || dist < 2.5);
|
||||||
|
case 'mines': return me.gUses > 0 && dist > 1.4 && dist < 7; // drop one while they chase you
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mines(s, dt) {
|
||||||
|
for (let i = s.mines.length - 1; i >= 0; i--) {
|
||||||
|
const mn = s.mines[i];
|
||||||
|
if (mn.own > 0) mn.own -= dt;
|
||||||
|
if (mn.arm > 0) { mn.arm -= dt; continue; } // short delay so you can drive off it
|
||||||
|
for (const r of s.robots) {
|
||||||
|
if (r.out || r.dead || r.y > 0.35) continue;
|
||||||
|
if (mn.owner === r.i && mn.own > 0) continue; // grace period for whoever dropped it
|
||||||
|
if (Math.hypot(r.x - mn.x, r.z - mn.z) > mn.r + r.st.rad * 0.6) continue;
|
||||||
|
const light = Math.sqrt(70 / r.st.mass);
|
||||||
|
// your own mine pays the opponent, like any other hazard
|
||||||
|
damage(s, r, mn.dmg, mn.owner === r.i ? null : s.robots[mn.owner], { from: { x: mn.x, z: mn.z }, kind: 'mine' });
|
||||||
|
r.vy = Math.max(r.vy, mn.launch * light);
|
||||||
|
r.av += (s.rand() - 0.5) * 7;
|
||||||
|
if (!r.st.invertible && s.rand() < 0.5) r.flipped = 2.2;
|
||||||
|
s.events.push({ type: 'boom', x: mn.x, z: mn.z, y: 0.22, big: true });
|
||||||
|
s.mines.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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];
|
||||||
|
|||||||
72
game/game.js
72
game/game.js
@@ -19,7 +19,17 @@
|
|||||||
|
|
||||||
// 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';
|
||||||
const CREDITS = `© 2026 Michael Media · <a href="${DISCORD}" target="_blank" rel="noopener">Discord</a>`;
|
const SITE = 'https://michael-media.de';
|
||||||
|
// build stamp comes from build-web.mjs; identifies the exact release in a leaked copy
|
||||||
|
const BUILD = (typeof window !== 'undefined' && window.RC_BUILD) || '';
|
||||||
|
const CREDITS = `© 2026 <a href="${SITE}" target="_blank" rel="noopener">Michael Media</a>`
|
||||||
|
+ ` · <a href="${DISCORD}" target="_blank" rel="noopener">Discord</a>`
|
||||||
|
+ (BUILD ? ` · <span class="build">${BUILD}</span>` : '');
|
||||||
|
// Soft domain lock: the published build only runs on our own site. Local file, localhost and the
|
||||||
|
// exe always run. This stops a lazy re-upload, nothing more - the file itself can always be copied.
|
||||||
|
const HOSTS = ['michael-media.de', 'www.michael-media.de', 'localhost', '127.0.0.1', ''];
|
||||||
|
const hostOk = () => location.protocol === 'file:' || HOSTS.includes(location.hostname)
|
||||||
|
|| (Kit.host && Kit.host.exe) || document.documentElement.classList.contains('exe');
|
||||||
|
|
||||||
// ---------------------------------------------------------------- services
|
// ---------------------------------------------------------------- services
|
||||||
const L = Kit.i18n(window.LANG, { prefix: ID });
|
const L = Kit.i18n(window.LANG, { prefix: ID });
|
||||||
@@ -107,6 +117,7 @@
|
|||||||
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 'broke': audio.sfx('sfx_hit'); audio.noise(0.45, 0.5, 900); audio.tone(240, 0.35, 'sawtooth', 0.22, -190); break;
|
||||||
|
case 'mine_drop': audio.tone(520, 0.08, 'square', 0.12, -160); audio.noise(0.06, 0.12, 2200); 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;
|
||||||
@@ -214,6 +225,27 @@
|
|||||||
|
|
||||||
// ---------------------------------------------------------------- intro + title
|
// ---------------------------------------------------------------- intro + title
|
||||||
let introCue = 0;
|
let introCue = 0;
|
||||||
|
let gateDone = false;
|
||||||
|
function startGate(next) {
|
||||||
|
if (gateDone) { next(); return; }
|
||||||
|
gateDone = true;
|
||||||
|
setScreen('intro'); // defined UI state while the gate is up (HUD stays hidden)
|
||||||
|
const logo = `<img class="tlogoimg" src="${Kit.asset('assets/Sprites/logo.png')}" alt="ROBOT CLASH"
|
||||||
|
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="hazbar"></div><p class="tag">${t('click_start')}</p>
|
||||||
|
<p class="credits">${CREDITS}</p></div></div>`;
|
||||||
|
overlay.classList.remove('hide'); overlay.classList.add('clear'); overlay.style.backgroundImage = '';
|
||||||
|
const go = e => {
|
||||||
|
if (e) { e.stopPropagation(); if (e.preventDefault) e.preventDefault(); } // must not also skip the intro
|
||||||
|
removeEventListener('pointerdown', go, true); removeEventListener('keydown', go, true);
|
||||||
|
if (audio.unlock) audio.unlock();
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
addEventListener('pointerdown', go, true);
|
||||||
|
addEventListener('keydown', go, true);
|
||||||
|
}
|
||||||
|
|
||||||
function startIntro() {
|
function startIntro() {
|
||||||
setScreen('intro');
|
setScreen('intro');
|
||||||
hideOverlay();
|
hideOverlay();
|
||||||
@@ -230,7 +262,7 @@
|
|||||||
function introTick() {
|
function introTick() {
|
||||||
if (mode !== 'intro' || !view) return;
|
if (mode !== 'intro' || !view) return;
|
||||||
const it = view.introTime;
|
const it = view.introTime;
|
||||||
for (const [at, f] of [[1.2, SFX.clunk], [1.5, SFX.clunk], [1.62, SFX.clunk], [4.25, SFX.clunk], [4.6, SFX.clunk]]) {
|
for (const [at, f] of [[0.4, SFX.clunk], [0.62, SFX.clunk], [2.2, SFX.clunk], [2.5, SFX.clunk], [3.4, SFX.clunk]]) {
|
||||||
if (introCue < at && it >= at) f();
|
if (introCue < at && it >= at) f();
|
||||||
}
|
}
|
||||||
introCue = it;
|
introCue = it;
|
||||||
@@ -433,7 +465,7 @@
|
|||||||
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(); startTutorial(openGarage); } else openGarage();
|
||||||
}
|
}
|
||||||
// saves from older versions: missing parts, invalid ids, hangar migration
|
// saves from older versions: missing parts, invalid ids, hangar migration
|
||||||
function repairSave() {
|
function repairSave() {
|
||||||
@@ -563,6 +595,25 @@
|
|||||||
<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>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>`;
|
||||||
}
|
}
|
||||||
|
// first start: four short cards instead of the full help page
|
||||||
|
const TUT = ['tut_1', 'tut_2', 'tut_3', 'tut_4'];
|
||||||
|
function startTutorial(done) {
|
||||||
|
let i = 0;
|
||||||
|
const step = () => {
|
||||||
|
if (i >= TUT.length) { done(); return; }
|
||||||
|
const n = i + 1;
|
||||||
|
overlayEnter();
|
||||||
|
card(`<h2>${t('tut_title')} <span class="muted">${n}/${TUT.length}</span></h2>
|
||||||
|
<p>${t(TUT[i])}</p>
|
||||||
|
<div class="row"><button id="tSkip">${t('tut_skip')}</button>
|
||||||
|
<button class="primary" id="tNext">${n === TUT.length ? t('tut_go') : t('tut_next')}</button></div>`,
|
||||||
|
{ bg: 'bg_workshop.jpg' });
|
||||||
|
$('tNext').onclick = () => { SFX.click(); i++; step(); };
|
||||||
|
$('tSkip').onclick = () => { SFX.click(); done(); };
|
||||||
|
};
|
||||||
|
step();
|
||||||
|
}
|
||||||
|
|
||||||
function showHelp(back) {
|
function showHelp(back) {
|
||||||
overlayEnter();
|
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()}
|
||||||
@@ -689,6 +740,7 @@
|
|||||||
setScreen('fight');
|
setScreen('fight');
|
||||||
audio.music('music_fight');
|
audio.music('music_fight');
|
||||||
banner('📍 ' + t('arena_' + s.arena.id), '#ff7a1a', 2.2);
|
banner('📍 ' + t('arena_' + s.arena.id), '#ff7a1a', 2.2);
|
||||||
|
if (save.games === 0 && !F.online) setTimeout(() => { if (mode === 'fight') banner(t('tut_controls'), '#ffffff', 5); }, 2400);
|
||||||
const pg = $('padGadget'); if (pg) pg.style.display = s.robots[0].st.gadget ? '' : 'none';
|
const pg = $('padGadget'); if (pg) pg.style.display = s.robots[0].st.gadget ? '' : 'none';
|
||||||
buildCds();
|
buildCds();
|
||||||
buildDmg(0, save.build); buildDmg(1, opp.build);
|
buildDmg(0, save.build); buildDmg(1, opp.build);
|
||||||
@@ -782,6 +834,11 @@
|
|||||||
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 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 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)');
|
for (const b of A.blocks) rect(b, 'rgba(150,160,175,.6)');
|
||||||
|
for (const mn of s.mines || []) {
|
||||||
|
const [px, py] = P(mn.x, mn.z);
|
||||||
|
ctx.fillStyle = mn.arm > 0 ? 'rgba(200,200,200,.45)' : 'rgba(255,70,40,.95)';
|
||||||
|
ctx.beginPath(); ctx.arc(px, py, Math.max(2, mn.r * k), 0, 7); ctx.fill();
|
||||||
|
}
|
||||||
s.robots.forEach((r, i) => {
|
s.robots.forEach((r, i) => {
|
||||||
if (r.out) return;
|
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);
|
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);
|
||||||
@@ -1083,7 +1140,9 @@
|
|||||||
accounts.resume();
|
accounts.resume();
|
||||||
if (net && net.enabled) { net.auth.resume(); net.auth.onChange(() => { hud(); if (mode === 'title') showTitle(); }); }
|
if (net && net.enabled) { net.auth.resume(); net.auth.onChange(() => { hud(); if (mode === 'title') showTitle(); }); }
|
||||||
hud();
|
hud();
|
||||||
if (!view) {
|
if (!hostOk()) {
|
||||||
|
card(`<h1>Robot Clash</h1><p>${t('wrong_host')}</p><p class="credits">${CREDITS}</p>`);
|
||||||
|
} else 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
|
||||||
@@ -1119,7 +1178,8 @@
|
|||||||
painter.open(); view.showGarage(save.build, paintObj());
|
painter.open(); view.showGarage(save.build, paintObj());
|
||||||
}
|
}
|
||||||
} else if (DEV.has('online') && net.enabled) { startIntroOrTitle(); startOnline(); }
|
} else if (DEV.has('online') && net.enabled) { startIntroOrTitle(); startOnline(); }
|
||||||
else if (DEV.has('title')) startIntroOrTitle();
|
else if (DEV.has('title')) startGate(startIntroOrTitle);
|
||||||
else startIntro();
|
else startGate(startIntro);
|
||||||
|
if (DEV.has('tut')) startTutorial(openGarage); // dev: ?play&tut previews the first-start cards
|
||||||
if (DEV.has('uicheck') && RC.uiCheckRun) RC.uiCheckRun(); // dev: &uicheck prints layout faults as text
|
if (DEV.has('uicheck') && RC.uiCheckRun) RC.uiCheckRun(); // dev: &uicheck prints layout faults as text
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -120,6 +120,7 @@
|
|||||||
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
|
.row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
|
||||||
.credits { margin: 14px 0 0; font-size: 12px; color: var(--dim); }
|
.credits { margin: 14px 0 0; font-size: 12px; color: var(--dim); }
|
||||||
.credits a { color: var(--accent); text-decoration: none; }
|
.credits a { color: var(--accent); text-decoration: none; }
|
||||||
|
.credits .build { color: #5a6273; font-size: 10.5px; }
|
||||||
.credits a:hover { text-decoration: underline; }
|
.credits a:hover { text-decoration: underline; }
|
||||||
.keys { display: grid; grid-template-columns: auto auto; gap: 3px 14px; text-align: left; margin: 10px auto 0; width: max-content; font-size: 13px; color: var(--dim); }
|
.keys { display: grid; grid-template-columns: auto auto; gap: 3px 14px; text-align: left; margin: 10px auto 0; width: max-content; font-size: 13px; color: var(--dim); }
|
||||||
.keys b { color: var(--text); }
|
.keys b { color: var(--text); }
|
||||||
|
|||||||
22
game/lang.js
22
game/lang.js
@@ -9,6 +9,14 @@ window.LANG = {
|
|||||||
league_chip: 'S{s} · {n}/{m}',
|
league_chip: 'S{s} · {n}/{m}',
|
||||||
sound_on: 'Sound on', sound_off: 'Sound off', pause: 'Pause',
|
sound_on: 'Sound on', sound_off: 'Sound off', pause: 'Pause',
|
||||||
win_min: 'Minimise', win_full: 'Fullscreen (F11)', win_close: 'Close',
|
win_min: 'Minimise', win_full: 'Fullscreen (F11)', win_close: 'Close',
|
||||||
|
click_start: 'Click or press any key to start',
|
||||||
|
tut_title: 'Quick start', tut_next: 'Next', tut_skip: 'Skip', tut_go: "Let's build",
|
||||||
|
tut_1: 'Every robot needs four parts: chassis, motor, wheels and a battery. You pick them under Parts.',
|
||||||
|
tut_2: 'A weapon is optional - without one you can only ram. A wedge is cheap, a flipper throws them over.',
|
||||||
|
tut_3: 'Watch the two bars on the left: 100 kg is the limit, and your battery has to power every part.',
|
||||||
|
tut_4: 'Then press LEAGUE. Even a defeat pays a little, and prize money buys better parts.',
|
||||||
|
tut_controls: 'W/S drive · A/D turn · Space weapon · Shift tower · G gadget · C camera',
|
||||||
|
wrong_host: 'This copy of Robot Clash may only be played on michael-media.de.',
|
||||||
no_webgl: 'This game needs WebGL (3D graphics). Please use a current browser or update the graphics driver.',
|
no_webgl: 'This game needs WebGL (3D graphics). Please use a current browser or update the graphics driver.',
|
||||||
menu_text: 'Build your combat robot from parts, fight your way up the league<br>and send your opponents into the pit.',
|
menu_text: 'Build your combat robot from parts, fight your way up the league<br>and send your opponents into the pit.',
|
||||||
name_placeholder: 'Your name',
|
name_placeholder: 'Your name',
|
||||||
@@ -58,6 +66,8 @@ window.LANG = {
|
|||||||
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_liion: 'Big cell block - runs a heavy weapon and a turret together.',
|
||||||
|
pd_supercap: 'Supercapacitor bank: the most power there is, and it weighs accordingly.',
|
||||||
pd_mesh: 'Thin wire grille - barely any weight, barely any protection.',
|
pd_mesh: 'Thin wire grille - barely any weight, barely any protection.',
|
||||||
pd_buffer: 'Fat rubber buffers that soak up rams.',
|
pd_buffer: 'Fat rubber buffers that soak up rams.',
|
||||||
pd_spiked: 'Plates with spikes, and they look the part.',
|
pd_spiked: 'Plates with spikes, and they look the part.',
|
||||||
@@ -89,6 +99,7 @@ window.LANG = {
|
|||||||
pd_shield: 'Field that cuts damage for a few seconds (G).',
|
pd_shield: 'Field that cuts damage for a few seconds (G).',
|
||||||
pd_repair: 'Patches hull - two charges (G).',
|
pd_repair: 'Patches hull - two charges (G).',
|
||||||
pd_emp: 'Stuns a nearby enemy for a moment (G).',
|
pd_emp: 'Stuns a nearby enemy for a moment (G).',
|
||||||
|
pd_mines: 'Drops a mine behind you (G). It arms after a second - whoever drives over it gets thrown into the air. That includes you.',
|
||||||
// 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.',
|
||||||
@@ -213,6 +224,14 @@ window.LANG = {
|
|||||||
league_chip: 'S{s} · {n}/{m}',
|
league_chip: 'S{s} · {n}/{m}',
|
||||||
sound_on: 'Sound an', sound_off: 'Sound aus', pause: 'Pause',
|
sound_on: 'Sound an', sound_off: 'Sound aus', pause: 'Pause',
|
||||||
win_min: 'Minimieren', win_full: 'Vollbild (F11)', win_close: 'Schließen',
|
win_min: 'Minimieren', win_full: 'Vollbild (F11)', win_close: 'Schließen',
|
||||||
|
click_start: 'Klicken oder Taste drücken zum Starten',
|
||||||
|
tut_title: 'Kurzanleitung', tut_next: 'Weiter', tut_skip: 'Überspringen', tut_go: 'Los bauen',
|
||||||
|
tut_1: 'Jeder Roboter braucht vier Teile: Chassis, Motor, Räder und Batterie. Die wählst du unter „Teile".',
|
||||||
|
tut_2: 'Eine Waffe ist freiwillig – ohne kannst du nur rammen. Ein Keil ist billig, ein Flipper wirft um.',
|
||||||
|
tut_3: 'Achte auf die zwei Balken links: 100 kg sind das Limit, und die Batterie muss alle Teile versorgen.',
|
||||||
|
tut_4: 'Dann auf LIGA drücken. Auch eine Niederlage bringt Geld, und vom Preisgeld kaufst du bessere Teile.',
|
||||||
|
tut_controls: 'W/S fahren · A/D drehen · Leertaste Waffe · Shift Turm · G Gadget · C Kamera',
|
||||||
|
wrong_host: 'Diese Ausgabe von Robot Clash darf nur auf michael-media.de gespielt werden.',
|
||||||
no_webgl: 'Dieses Spiel braucht WebGL (3D-Grafik). Bitte einen aktuellen Browser nutzen oder den Grafiktreiber aktualisieren.',
|
no_webgl: 'Dieses Spiel braucht WebGL (3D-Grafik). Bitte einen aktuellen Browser nutzen oder den Grafiktreiber aktualisieren.',
|
||||||
menu_text: 'Bau deinen Kampfroboter aus Teilen, kämpf dich durch die Liga<br>und schick deine Gegner in die Grube.',
|
menu_text: 'Bau deinen Kampfroboter aus Teilen, kämpf dich durch die Liga<br>und schick deine Gegner in die Grube.',
|
||||||
name_placeholder: 'Dein Name',
|
name_placeholder: 'Dein Name',
|
||||||
@@ -262,6 +281,8 @@ window.LANG = {
|
|||||||
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_liion: 'Großer Zellenblock – trägt schwere Waffe und Turm gleichzeitig.',
|
||||||
|
pd_supercap: 'Superkondensator-Bank: der meiste Strom, und entsprechend schwer.',
|
||||||
pd_mesh: 'Dünnes Drahtgitter – kaum Gewicht, kaum Schutz.',
|
pd_mesh: 'Dünnes Drahtgitter – kaum Gewicht, kaum Schutz.',
|
||||||
pd_buffer: 'Dicke Gummipuffer, die Rammstöße schlucken.',
|
pd_buffer: 'Dicke Gummipuffer, die Rammstöße schlucken.',
|
||||||
pd_spiked: 'Platten mit Stacheln, sehen auch so aus.',
|
pd_spiked: 'Platten mit Stacheln, sehen auch so aus.',
|
||||||
@@ -293,6 +314,7 @@ window.LANG = {
|
|||||||
pd_shield: 'Feld, das ein paar Sekunden Schaden abfängt (G).',
|
pd_shield: 'Feld, das ein paar Sekunden Schaden abfängt (G).',
|
||||||
pd_repair: 'Flickt die Hülle – zwei Ladungen (G).',
|
pd_repair: 'Flickt die Hülle – zwei Ladungen (G).',
|
||||||
pd_emp: 'Legt einen nahen Gegner kurz lahm (G).',
|
pd_emp: 'Legt einen nahen Gegner kurz lahm (G).',
|
||||||
|
pd_mines: 'Legt eine Mine hinter dir ab (G). Nach einer Sekunde scharf – wer drüberfährt, fliegt hoch. Auch du.',
|
||||||
// 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.',
|
||||||
|
|||||||
@@ -77,6 +77,9 @@
|
|||||||
if (outgoing) return;
|
if (outgoing) return;
|
||||||
outgoing = uid;
|
outgoing = uid;
|
||||||
const p = prof();
|
const p = prof();
|
||||||
|
// a rematch reuses the match id, so clear whatever a crashed fight left behind -
|
||||||
|
// otherwise the waiting side would pick up the old seed (and the old arena) at once
|
||||||
|
await db.del(`matches/${matchId(me(), uid)}`);
|
||||||
await beat('searching');
|
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' } });
|
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)
|
// wait for the other side to create the match (they host if their uid < mine)
|
||||||
@@ -85,7 +88,7 @@
|
|||||||
const watch = db.stream(`matches/${id}/meta/seed`, seed => {
|
const watch = db.stream(`matches/${id}/meta/seed`, seed => {
|
||||||
if (seed == null) return;
|
if (seed == null) return;
|
||||||
clearTimeout(give); watch.close(); outgoing = null;
|
clearTimeout(give); watch.close(); outgoing = null;
|
||||||
createMatch(uid); // add my own robot to the match meta
|
createMatch(uid, false); // add my own robot; the seed is already set by the other side
|
||||||
watchMatch(id, uid, host);
|
watchMatch(id, uid, host);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -93,17 +96,20 @@
|
|||||||
async function accept(from) {
|
async function accept(from) {
|
||||||
const id = matchId(me(), from), host = isHost(me(), from);
|
const id = matchId(me(), from), host = isHost(me(), from);
|
||||||
await db.del(`challenges/${me()}/${from}`);
|
await db.del(`challenges/${me()}/${from}`);
|
||||||
await createMatch(from);
|
await createMatch(from, true); // whoever accepts rolls the seed (and with it the arena)
|
||||||
watchMatch(id, from, host);
|
watchMatch(id, from, host);
|
||||||
}
|
}
|
||||||
function decline(from) { db.del(`challenges/${me()}/${from}`); }
|
function decline(from) { db.del(`challenges/${me()}/${from}`); }
|
||||||
function cancel() { if (outgoing) { db.del(`challenges/${outgoing}/${me()}`); outgoing = null; beat('idle'); } }
|
function cancel() { if (outgoing) { db.del(`challenges/${outgoing}/${me()}`); outgoing = null; beat('idle'); } }
|
||||||
|
|
||||||
async function createMatch(oppUid) {
|
// setSeed: only the side that accepts writes the seed, so both read the exact same value.
|
||||||
|
// It is rolled fresh for every match - a seed derived from the match id would hand the same
|
||||||
|
// pair of players the same arena for ever.
|
||||||
|
async function createMatch(oppUid, setSeed) {
|
||||||
const id = matchId(me(), oppUid), p = prof();
|
const id = matchId(me(), oppUid), p = prof();
|
||||||
const seed = (parseInt(id.slice(-6), 36) % 1e9) || 1; // same on both sides
|
const meta = { [me()]: { name: p.name, flag: p.flag || 'XX', build: p.build, paint: p.paint } };
|
||||||
// meta holds both players' robots; written once, guarded so the first writer wins
|
if (setSeed) meta.seed = ((Math.random() * 1e9) | 0) || 1;
|
||||||
await db.patch(`matches/${id}/meta`, { seed, [me()]: { name: p.name, flag: p.flag || 'XX', build: p.build, paint: p.paint } });
|
await db.patch(`matches/${id}/meta`, meta);
|
||||||
await beat('inmatch');
|
await beat('inmatch');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
seq: ++seq, t: rnd(s.t), left: rnd(s.left), pitOpen: rnd(s.pitOpen), pitAlarm: s.pitAlarm,
|
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 },
|
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) })),
|
rockets: s.rockets.map(k => ({ x: rnd(k.x), z: rnd(k.z), y: rnd(k.y), a: rnd(k.a) })),
|
||||||
|
mines: s.mines.map(k => ({ x: rnd(k.x), z: rnd(k.z), arm: rnd(k.arm) })),
|
||||||
r: [packRobot(s.robots[0]), packRobot(s.robots[1])],
|
r: [packRobot(s.robots[0]), packRobot(s.robots[1])],
|
||||||
ev: evBuf.slice(-24), result: s.result, endIn: rnd(s.endIn),
|
ev: evBuf.slice(-24), result: s.result, endIn: rnd(s.endIn),
|
||||||
};
|
};
|
||||||
@@ -108,6 +109,7 @@
|
|||||||
s.press.st = snap.press.st; s.press.y = snap.press.y;
|
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;
|
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);
|
syncRockets(s, snap.rockets);
|
||||||
|
syncMines(s, snap.mines);
|
||||||
s.result = snap.result; s.endIn = snap.endIn;
|
s.result = snap.result; s.endIn = snap.endIn;
|
||||||
// snapshot order [host, guest]; locally guest must be index 0 -> swap
|
// snapshot order [host, guest]; locally guest must be index 0 -> swap
|
||||||
applyRobot(s.robots[0], snap.r[1], dt); // me (guest)
|
applyRobot(s.robots[0], snap.r[1], dt); // me (guest)
|
||||||
@@ -134,6 +136,12 @@
|
|||||||
for (let i = 0; i < list.length; i++) s.rockets[i] = Object.assign(s.rockets[i] || { owner: 1, sp: 6, t: 3 }, list[i]);
|
for (let i = 0; i < list.length; i++) s.rockets[i] = Object.assign(s.rockets[i] || { owner: 1, sp: 6, t: 3 }, list[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function syncMines(s, list) {
|
||||||
|
list = list || [];
|
||||||
|
s.mines.length = list.length;
|
||||||
|
for (let i = 0; i < list.length; i++) s.mines[i] = Object.assign(s.mines[i] || { owner: 0, r: 0.85 }, list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
let prevInput = null;
|
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; }
|
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; }
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
{ 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 },
|
||||||
{ id: 'nicd', slot: 'battery', name: 'NiCd Pack', cost: 320, weight: 7, power: 13 },
|
{ id: 'nicd', slot: 'battery', name: 'NiCd Pack', cost: 320, weight: 7, power: 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 },
|
||||||
|
{ id: 'liion', slot: 'battery', name: 'Li-Ion Brick', cost: 1150, weight: 8, power: 24 },
|
||||||
|
{ id: 'supercap', slot: 'battery', name: 'Supercap Bank', cost: 1700, weight: 11, power: 30 },
|
||||||
|
|
||||||
// armour: reduce = share of damage absorbed, hp bonus
|
// armour: reduce = share of damage absorbed, hp bonus
|
||||||
{ id: 'mesh', slot: 'armour', name: 'Wire Mesh', cost: 120, weight: 5, reduce: 0.08, hp: 4, tint: 0x9aa3ad, style: 'mesh' },
|
{ id: 'mesh', slot: 'armour', name: 'Wire Mesh', cost: 120, weight: 5, reduce: 0.08, hp: 4, tint: 0x9aa3ad, style: 'mesh' },
|
||||||
@@ -83,6 +85,8 @@
|
|||||||
{ id: 'shield', slot: 'gadget', name: 'Deflector Field', cost: 420, weight: 7, power: 4, type: 'shield', cd: 9, dur: 2.5, reduce: 0.6 },
|
{ 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: '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 },
|
{ id: 'emp', slot: 'gadget', name: 'EMP Burst', cost: 640, weight: 7, power: 5, type: 'emp', cd: 8, range: 3.2, stun: 1.5 },
|
||||||
|
{ id: 'mines', slot: 'gadget', name: 'Mine Layer', cost: 560, weight: 9, power: 3, type: 'mines', cd: 2.2, charges: 3,
|
||||||
|
dmg: 26, launch: 7.5, r: 0.85, arm: 1.2 },
|
||||||
];
|
];
|
||||||
|
|
||||||
RC.PARTS = {};
|
RC.PARTS = {};
|
||||||
|
|||||||
@@ -661,8 +661,9 @@
|
|||||||
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.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.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.rocketMat = new T.MeshStandardMaterial({ color: 0xe8e8e8, emissive: 0xff5a10, emissiveIntensity: 0.75 });
|
||||||
out.rocketMeshes = [];
|
out.rocketMeshes = [];
|
||||||
|
out.mineMeshes = [];
|
||||||
buildArenaGeo(out, RC.ARENA);
|
buildArenaGeo(out, RC.ARENA);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -758,10 +759,14 @@
|
|||||||
}
|
}
|
||||||
for (const [px, pz] of [[-1, -1], [1, -1], [-1, 1]]) {
|
for (const [px, pz] of [[-1, -1], [1, -1], [-1, 1]]) {
|
||||||
const post = box(0.22, 3.4, 0.22, wallMat); post.position.set(px * (half + 0.35), 1.7, pz * (half + 0.35)); scene.add(post);
|
const post = box(0.22, 3.4, 0.22, wallMat); post.position.set(px * (half + 0.35), 1.7, pz * (half + 0.35)); scene.add(post);
|
||||||
const lamp = box(0.5, 0.3, 0.3, m.lamp); lamp.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(lamp);
|
const rig = new T.Group(); rig.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(rig);
|
||||||
|
const hous = box(0.46, 0.36, 0.34, new T.MeshStandardMaterial({ color: 0x23272e, metalness: 0.6, roughness: 0.5 }));
|
||||||
|
hous.castShadow = true; rig.add(hous);
|
||||||
|
const lens = box(0.3, 0.2, 0.3, m.lamp); lens.position.set(-px * 0.13, -0.12, -pz * 0.13); rig.add(lens);
|
||||||
|
const arm = cyl(0.035, 0.035, 0.36, m.dark, 6); arm.position.set(px * 0.12, 0.26, pz * 0.12); rig.add(arm);
|
||||||
}
|
}
|
||||||
// audience stands behind the back walls
|
// audience stands behind the back walls
|
||||||
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ roughness: 0.9 }), 900);
|
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ color: 0x1b1d24, roughness: 0.95 }), 900);
|
||||||
const col = new T.Color(); let ci = 0; let sd = 11;
|
const col = new T.Color(); let ci = 0; let sd = 11;
|
||||||
const rnd = () => { sd = (sd * 16807) % 2147483647; return sd / 2147483647; };
|
const rnd = () => { sd = (sd * 16807) % 2147483647; return sd / 2147483647; };
|
||||||
for (const [nx, nz] of [[-1, 0], [0, -1]]) for (let row = 0; row < 5; row++) {
|
for (const [nx, nz] of [[-1, 0], [0, -1]]) for (let row = 0; row < 5; row++) {
|
||||||
@@ -776,7 +781,10 @@
|
|||||||
col.setHSL(rnd(), 0.3, 0.07 + rnd() * 0.08); seats.setColorAt(ci, col); ci++;
|
col.setHSL(rnd(), 0.3, 0.07 + rnd() * 0.08); seats.setColorAt(ci, col); ci++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
seats.count = ci; dm.scale.set(1, 1, 1); scene.add(seats);
|
seats.count = ci; dm.scale.set(1, 1, 1);
|
||||||
|
seats.instanceMatrix.needsUpdate = true;
|
||||||
|
if (seats.instanceColor) seats.instanceColor.needsUpdate = true;
|
||||||
|
scene.add(seats);
|
||||||
|
|
||||||
// floor saws
|
// floor saws
|
||||||
// --- cover and floor traps (static, built once per arena) ---
|
// --- cover and floor traps (static, built once per arena) ---
|
||||||
@@ -1014,6 +1022,8 @@
|
|||||||
showIntro(builds, paints) {
|
showIntro(builds, paints) {
|
||||||
api.showArena(RC.Combat.create({ robots: builds.map(b => RC.stats(b)), seed: 3, arena: 'workshop' }), 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);
|
||||||
|
// compile every shader up front, otherwise the first seconds stutter while they are built
|
||||||
|
try { renderer.compile(arenaScene, pcam); } catch (e) { /* older three: just carry on */ }
|
||||||
},
|
},
|
||||||
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
|
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
|
||||||
showGarage(build, paint) {
|
showGarage(build, paint) {
|
||||||
@@ -1068,6 +1078,8 @@
|
|||||||
sparks.clear(); smoke.clear(); fire.clear(); clearDebris(); 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 = [];
|
||||||
|
for (const m of arena.mineMeshes) arenaScene.remove(m);
|
||||||
|
arena.mineMeshes = [];
|
||||||
},
|
},
|
||||||
events(list) {
|
events(list) {
|
||||||
for (const e of list) {
|
for (const e of list) {
|
||||||
@@ -1088,6 +1100,7 @@
|
|||||||
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 'mine_drop': burst(e.x, 0.12, e.z, 6, 2, [1, 0.8, 0.3]); break;
|
||||||
case 'broke':
|
case 'broke':
|
||||||
breakPart(robots[e.who], e.part);
|
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);
|
burst(e.x, 0.45, e.z, 22, 5, [1, 0.8, 0.4]); puff(e.x, e.z, 6);
|
||||||
@@ -1165,7 +1178,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- 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 = 5.2;
|
||||||
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);
|
||||||
function lightsOn(k) {
|
function lightsOn(k) {
|
||||||
const L = arena.lights;
|
const L = arena.lights;
|
||||||
@@ -1176,12 +1189,12 @@
|
|||||||
function introScript(dt) {
|
function introScript(dt) {
|
||||||
const t = introT, s = state;
|
const t = introT, s = state;
|
||||||
// floodlights: off, flicker, on
|
// floodlights: off, flicker, on
|
||||||
lightsOn(t < 1.2 ? 0 : t < 1.32 ? 1 : t < 1.5 ? 0.08 : t < 1.62 ? 0.8 : t < 1.85 ? 0.25 : 1);
|
lightsOn(t < 0.25 ? 0.12 : t < 0.4 ? 1 : t < 0.55 ? 0.15 : t < 0.7 ? 0.9 : t < 0.85 ? 0.3 : 1);
|
||||||
// camera path, then a slow orbit
|
// camera path, then a slow orbit
|
||||||
let ang, r, h, lx, lz;
|
let ang, r, h, lx, lz;
|
||||||
if (t < INTRO_END) {
|
if (t < INTRO_END) {
|
||||||
const e = ease(Math.min(1, t / INTRO_END));
|
const e = ease(Math.min(1, t / INTRO_END));
|
||||||
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(5, 20.5, e); h = lerp(0.8, 13.5, Math.pow(e, 1.4));
|
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(9, 20.5, e); h = lerp(2.4, 13.5, Math.pow(e, 1.4));
|
||||||
lx = lerp(RC.ARENA.pit.x, -0.6, e); lz = lerp(RC.ARENA.pit.z, -0.6, e);
|
lx = lerp(RC.ARENA.pit.x, -0.6, e); lz = lerp(RC.ARENA.pit.z, -0.6, e);
|
||||||
} else {
|
} else {
|
||||||
ang = Math.PI / 4 + (t - INTRO_END) * 0.05; r = 20.5; h = 13.5; lx = lz = 0;
|
ang = Math.PI / 4 + (t - INTRO_END) * 0.05; r = 20.5; h = 13.5; lx = lz = 0;
|
||||||
@@ -1191,13 +1204,13 @@
|
|||||||
// robots lowered in from above, landing with sparks
|
// robots lowered in from above, landing with sparks
|
||||||
s.t = t + 2; // trap timing: flames ignite once the lights are on
|
s.t = t + 2; // trap timing: flames ignite once the lights are on
|
||||||
s.robots.forEach((rb, i) => {
|
s.robots.forEach((rb, i) => {
|
||||||
const k = clamp((t - 2.6 - i * 0.35) / 1.6, 0, 1);
|
const k = clamp((t - 0.9 - i * 0.3) / 1.3, 0, 1);
|
||||||
const was = rb.y;
|
const was = rb.y;
|
||||||
rb.y = 7 * Math.pow(1 - k, 2); rb.vx = rb.vz = 0; rb.lifted = rb.y > 0 ? 1 : 0; // lifted: no tumbling
|
rb.y = 7 * Math.pow(1 - k, 2); rb.vx = rb.vz = 0; rb.lifted = rb.y > 0 ? 1 : 0; // lifted: no tumbling
|
||||||
if (was > 0 && rb.y === 0) { burst(rb.x, 0.2, rb.z, Math.round(40 * fxMul), 5, [1, 0.8, 0.4]); puff(rb.x, rb.z, 10); }
|
if (was > 0 && rb.y === 0) { burst(rb.x, 0.2, rb.z, Math.round(40 * fxMul), 5, [1, 0.8, 0.4]); puff(rb.x, rb.z, 10); }
|
||||||
rb.spin = t > 5.4 ? Math.min(1, (t - 5.4) * 0.8) : 0; // spinners rev up
|
rb.spin = t > 3.1 ? Math.min(1, (t - 3.1) * 1.1) : 0; // spinners rev up
|
||||||
rb.sawOn = t > 5.6;
|
rb.sawOn = t > 3.3;
|
||||||
rb.flameOn = t > 5.8 && t < 6.6 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
|
rb.flameOn = t > 3.5 && t < 4.3 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
|
||||||
rb.turretA = rb.a + Math.sin(t * 0.7 + i) * 0.4;
|
rb.turretA = rb.a + Math.sin(t * 0.7 + i) * 0.4;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1274,6 +1287,16 @@
|
|||||||
smoke.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.3, 0.9, (Math.random() - 0.5) * 0.3, 1.6, r.dead ? 0.12 : 0.35, r.dead ? 0.12 : 0.34, r.dead ? 0.12 : 0.33);
|
smoke.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.3, 0.9, (Math.random() - 0.5) * 0.3, 1.6, r.dead ? 0.12 : 0.35, r.dead ? 0.12 : 0.34, r.dead ? 0.12 : 0.33);
|
||||||
if (r.dead || hp < 0.2) fire.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.4, 0.8, (Math.random() - 0.5) * 0.4, 0.4, 1, 0.5, 0.1);
|
if (r.dead || hp < 0.2) fire.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.4, 0.8, (Math.random() - 0.5) * 0.4, 0.4, 1, 0.5, 0.1);
|
||||||
}
|
}
|
||||||
|
// minigun: glowing tracers flying out of the barrel so you can see where it shoots
|
||||||
|
if (r.gunOn && R.st.tower && R.st.tower.type === 'minigun') {
|
||||||
|
const ca = Math.cos(r.turretA), sa = Math.sin(r.turretA), y0 = r.y + R.top + 0.2;
|
||||||
|
for (let q = 0; q < 2; q++) {
|
||||||
|
const sp = 46 + Math.random() * 14, sprd = (Math.random() - 0.5) * 0.06;
|
||||||
|
sparks.spawn(r.x + ca * 0.62, y0, r.z + sa * 0.62,
|
||||||
|
(ca - sa * sprd) * sp, (Math.random() - 0.5) * 0.6, (sa + ca * sprd) * sp, 0.2, 1, 0.92, 0.55);
|
||||||
|
}
|
||||||
|
if (Math.random() < 0.5) smoke.spawn(r.x + ca * 0.6, y0, r.z + sa * 0.6, ca * 0.6, 0.5, sa * 0.6, 0.5, 0.42, 0.42, 0.42);
|
||||||
|
}
|
||||||
if (r.flameOn && Math.random() < 0.7) {
|
if (r.flameOn && Math.random() < 0.7) {
|
||||||
const a = r.turretA + (Math.random() - 0.5) * 0.5, v = 5 + Math.random() * 2;
|
const a = r.turretA + (Math.random() - 0.5) * 0.5, v = 5 + Math.random() * 2;
|
||||||
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);
|
||||||
@@ -1314,6 +1337,28 @@
|
|||||||
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
|
||||||
|
// mines lying on the floor: dark puck, the lamp blinks fast once it is armed
|
||||||
|
const mines = s.mines || [];
|
||||||
|
while (arena.mineMeshes.length < mines.length) {
|
||||||
|
const g = new T.Group();
|
||||||
|
const puck = new T.Mesh(new T.CylinderGeometry(0.3, 0.34, 0.11, 14), new T.MeshStandardMaterial({ color: 0x23262c, metalness: 0.6, roughness: 0.6 }));
|
||||||
|
puck.position.y = 0.055; puck.castShadow = true; g.add(puck);
|
||||||
|
const ring = new T.Mesh(new T.TorusGeometry(0.3, 0.03, 6, 18), new T.MeshStandardMaterial({ color: 0xf2b51c, roughness: 0.6 }));
|
||||||
|
ring.rotation.x = Math.PI / 2; ring.position.y = 0.1; g.add(ring);
|
||||||
|
const lamp = new T.Mesh(new T.SphereGeometry(0.06, 8, 6), new T.MeshStandardMaterial({ color: 0x661111, emissive: 0xff2010, emissiveIntensity: 1 }));
|
||||||
|
lamp.position.y = 0.15; g.add(lamp);
|
||||||
|
g.userData.lamp = lamp;
|
||||||
|
arenaScene.add(g); arena.mineMeshes.push(g);
|
||||||
|
}
|
||||||
|
arena.mineMeshes.forEach((g, i) => {
|
||||||
|
const mn = mines[i];
|
||||||
|
g.visible = !!mn;
|
||||||
|
if (!mn) return;
|
||||||
|
g.position.set(mn.x, 0.01, mn.z);
|
||||||
|
const armed = mn.arm <= 0;
|
||||||
|
const blink = armed ? (Math.sin(now / 90) > 0 ? 2.4 : 0.15) : 0.5;
|
||||||
|
g.userData.lamp.material.emissiveIntensity = blink;
|
||||||
|
});
|
||||||
while (arena.rocketMeshes.length < s.rockets.length) {
|
while (arena.rocketMeshes.length < s.rockets.length) {
|
||||||
const gr = new T.Group();
|
const gr = new T.Group();
|
||||||
const body = new T.Mesh(arena.rocketGeo, arena.rocketMat); gr.add(body);
|
const body = new T.Mesh(arena.rocketGeo, arena.rocketMat); gr.add(body);
|
||||||
|
|||||||
@@ -101,6 +101,10 @@ PROMPTS = [
|
|||||||
("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"),
|
||||||
|
|
||||||
|
("part_mines", f"robot gadget: stack of flat round steel land mines with yellow warning rings and a red lamp, {_STYLE}"),
|
||||||
|
# --- stronger batteries ---
|
||||||
|
("part_liion", f"chunky lithium ion battery brick with thick power cables and a charge gauge, {_STYLE}"),
|
||||||
|
("part_supercap", f"bank of large supercapacitors wired in a row on a steel frame, glowing blue, {_STYLE}"),
|
||||||
# --- new towers ---
|
# --- new towers ---
|
||||||
("part_zapper", f"robot turret: electric arc emitter with copper coils and crackling blue spark, {_STYLE}"),
|
("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_mortar", f"robot turret: short stubby mortar tube angled upwards on a base plate, {_STYLE}"),
|
||||||
|
|||||||
@@ -191,5 +191,32 @@ for (const id of ['crucible', 'colosseum', 'foundry', 'arena64']) {
|
|||||||
ok(worst === 0, `${A.shape} wall of ${id} keeps the robot inside`);
|
ok(worst === 0, `${A.shape} wall of ${id} keeps the robot inside`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mine layer: drop one, it arms, anyone driving over it gets launched - including the owner later on
|
||||||
|
{
|
||||||
|
const mk = () => {
|
||||||
|
const s = RC.Combat.create({ robots: [RC.stats({ ...RC.STARTER, gadget: 'mines' }), RC.stats(RC.STARTER)], seed: 5 });
|
||||||
|
s.robots[0].x = 0; s.robots[0].z = 0; s.robots[0].a = 0;
|
||||||
|
s.robots[1].x = 9; s.robots[1].z = 9;
|
||||||
|
return s;
|
||||||
|
};
|
||||||
|
let s = mk();
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
ok(s.mines.length === 1 && s.robots[0].gUses === 2, 'mine is dropped and costs a charge');
|
||||||
|
for (let i = 0; i < 120; i++) RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
ok(s.mines.length === 1 && s.mines[0].arm <= 0, 'it arms without blowing up the robot that laid it');
|
||||||
|
const b = s.robots[1], mn = s.mines[0], hp0 = b.hp, dealt0 = s.robots[0].dealt;
|
||||||
|
b.x = mn.x; b.z = mn.z; b.y = 0;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
ok(hp0 - b.hp > 10 && b.vy > 4 && s.mines.length === 0, 'driving over it hurts and throws the robot up');
|
||||||
|
ok(s.robots[0].dealt - dealt0 > 10, 'the damage counts for whoever laid the mine');
|
||||||
|
s = mk();
|
||||||
|
RC.Combat.step(s, 1 / 60, [{ fire3: true }, {}]);
|
||||||
|
for (let i = 0; i < 60 * 4; i++) RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
const a2 = s.robots[0], m2 = s.mines[0], h0 = a2.hp;
|
||||||
|
a2.x = m2.x; a2.z = m2.z; a2.y = 0;
|
||||||
|
RC.Combat.step(s, 1 / 60, [{}, {}]);
|
||||||
|
ok(h0 - a2.hp > 10, 'once the grace time is over your own mine gets you too');
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user