Skip to content

Commit 94ddae4

Browse files
authored
Merge pull request #360: Midnight Ops Mac key layout and new actions
Midnight Ops: Mac trackpad key layout, slide, prone, melee, grenades, map
2 parents 8d0af45 + a107c36 commit 94ddae4

12 files changed

Lines changed: 241 additions & 50 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎e63334287a3deaa3/ironveil/es.js‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎e63334287a3deaa3/ironveil/index.html‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
.h-ammo .pips{display:flex;justify-content:flex-end;gap:2px;margin-top:5px}.h-ammo .pips i{width:3px;height:9px;background:var(--ink)}.h-ammo .pips i.off{background:var(--faint)}
108108
.h-ammo small{display:block;font-family:var(--f-type);font-size:10px;letter-spacing:.2em;color:var(--dim);margin-top:5px}
109109
.h-mark{position:absolute;left:0;top:0;display:flex;flex-direction:column;align-items:center;gap:2px;font-family:var(--f-type);font-size:10px;letter-spacing:.1em;color:var(--brass);will-change:transform}
110+
.h-mark.ping{color:#9fd3ff}.h-mark.ping i{border-color:#9fd3ff;border-radius:50%;transform:none}
111+
#h-status{position:absolute;right:var(--gr);top:50%;transform:translateY(-50%);width:min(280px,70vw);background:var(--solid);border:1px solid var(--line);border-left:3px solid var(--brass);padding:14px 18px;opacity:0;transition:opacity .12s}#h-status.on{opacity:1}
112+
#h-status h3{font-family:var(--f-stencil);font-weight:800;font-size:20px;letter-spacing:.06em;margin:0 0 8px;text-transform:uppercase}#h-status dl{display:grid;grid-template-columns:1fr auto;gap:5px 14px;margin:0;font-family:var(--f-type);font-size:13px}#h-status dt{color:var(--dim)}#h-status dd{margin:0;text-align:right}
113+
#h-map{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);display:none;background:rgba(222,212,186,.95);padding:10px;box-shadow:0 10px 40px rgba(0,0,0,.6)}#h-map.on{display:block}#h-map canvas{display:block;width:min(70vh,82vw);height:min(70vh,82vw)}#h-map p{margin:6px 0 0;font-family:var(--f-type);font-size:12px;color:#3a3326;text-align:center;text-shadow:none}
114+
.h-ammo #h-nd{color:var(--ink)}
110115
.h-mark i{width:11px;height:11px;border:1.5px solid var(--brass);transform:rotate(45deg);margin:3px}.h-mark.exit i{background:var(--brass)}.h-mark.opt{color:var(--dim)}.h-mark.opt i{border-style:dashed;border-color:var(--dim)}.h-mark b{font-family:var(--f-stencil);font-size:13px}
111116
#radio{position:absolute;left:50%;bottom:calc(var(--gb) + 74px);transform:translateX(-50%);width:min(640px,76vw);text-align:center;opacity:0;transition:opacity .3s;text-shadow:var(--shadow);pointer-events:none}
112117
#radio.on{opacity:1}#radio b{font-family:var(--f-ui);font-weight:700;font-size:13px;letter-spacing:.2em;color:var(--brass);text-transform:uppercase;margin-right:8px}
@@ -126,6 +131,7 @@
126131
#t-crouch{right:calc(var(--gr) + 178px);bottom:calc(var(--gb) + 22px)}
127132
#t-use{left:50%;margin-left:-44px;width:88px;top:calc(62% + 44px);border-radius:8px;height:44px;display:none;border-color:var(--brass);color:var(--brass)}
128133
#t-use.show{display:block}
134+
#t-nade{right:calc(var(--gr) + 178px);bottom:calc(var(--gb) + 100px)}
129135
#t-pause{right:var(--gr);top:var(--gt);width:42px;height:42px;border-radius:6px;font-size:16px}
130136
body.touch .h-ammo{bottom:auto;top:calc(var(--gt) + 50px)}body.touch .h-ammo b{font-size:34px}body.touch .h-ammo .pips{display:none}
131137
body.touch .h-hp{bottom:auto;top:calc(var(--gt) + 64px)}body.touch #radio{bottom:auto;top:calc(var(--gt) + 110px)}
@@ -144,7 +150,7 @@
144150
.btn{font-family:var(--f-ui);font-weight:700;font-size:17px;letter-spacing:.22em;text-transform:uppercase;padding:13px 26px 12px;border:1.5px solid var(--line);background:var(--plate);color:var(--ink);min-height:48px;transition:background .15s,border-color .15s,color .15s}
145151
.btn:hover{border-color:var(--ink)}.btn.go{background:var(--brass);border-color:var(--brass);color:#14110a}.btn.go:hover{background:var(--brass-hot)}
146152
.t-foot{font-family:var(--f-type);font-size:11px;letter-spacing:.06em;color:var(--dim);margin-top:18px;max-width:34em;line-height:1.5}
147-
.t-keys{position:absolute;right:var(--gr);bottom:calc(var(--gb) + 26px);display:grid;grid-template-columns:repeat(2,auto);gap:5px 22px;font-family:var(--f-type);font-size:11px;letter-spacing:.12em;color:var(--dim);text-transform:uppercase}
153+
.t-keys{position:absolute;right:var(--gr);bottom:calc(var(--gb) + 26px);display:grid;grid-template-columns:repeat(3,auto);gap:5px 22px;font-family:var(--f-type);font-size:11px;letter-spacing:.12em;color:var(--dim);text-transform:uppercase}
148154
.t-keys kbd,.ctl kbd{font-family:var(--f-type);font-size:10px;border:1px solid var(--line);padding:1px 5px 0;margin-right:6px;color:var(--ink)}
149155
body.touch .t-keys{display:none}
150156
.card-wrap{align-items:center;justify-content:center;background:rgba(9,11,13,.72);padding:20px}
@@ -182,6 +188,7 @@
182188
.h-clock{left:auto;right:var(--gr);top:calc(var(--gt) + 134px);font-size:15px;text-align:right}
183189
}
184190
@media (max-height:460px){
191+
#t-nade{right:calc(var(--gr) + 250px);bottom:calc(var(--gb) + 70px);width:50px;height:50px}
185192
.h-obj{max-width:calc(28vw - 20px)}.h-obj b{font-size:15px}.h-clock{top:calc(var(--gt) + 84px);font-size:16px}
186193
.t-logo{font-size:clamp(40px,15vh,90px)}.t-rule{margin:8px 0}.t-btns{margin-top:10px}.t-foot{display:none}.t-line{font-size:13px}
187194
#t-jump{bottom:calc(var(--gb) + 14px);right:calc(var(--gr) + 112px)}#t-fire{bottom:calc(var(--gb) + 60px)}#t-aim{right:calc(var(--gr) + 112px);bottom:calc(var(--gb) + 82px)}#t-reload{right:calc(var(--gr) + 186px);bottom:calc(var(--gb) + 46px)}#t-crouch{right:calc(var(--gr) + 250px);bottom:calc(var(--gb) + 6px);width:50px;height:50px}
@@ -209,8 +216,11 @@
209216
<div class="h-prompt" id="h-prompt"><span><kbd>E</kbd><em id="h-pt" style="font-style:normal"></em></span><u><s id="h-pb"></s></u></div>
210217
<div class="h-msg" id="h-msg"></div>
211218
<div class="h-hp" id="h-hp"><small id="h-hpl"></small><u><s id="h-hpb"></s></u></div>
212-
<div class="h-ammo"><b id="h-am">30</b><em id="h-ar">/ 150</em><div class="pips" id="h-pips"></div><small id="h-wn"></small></div>
219+
<div class="h-ammo"><b id="h-am">30</b><em id="h-ar">/ 150</em><div class="pips" id="h-pips"></div><small id="h-wn"></small><small id="h-nd"></small></div>
213220
<div id="marks"></div>
221+
<div class="h-mark ping" id="h-ping" style="display:none"><b>V</b><i></i><span></span></div>
222+
<div id="h-status"><h3 id="hs-t"></h3><dl id="hs-l"></dl></div>
223+
<div id="h-map"><canvas id="h-mapc"></canvas><p id="h-mapk"></p></div>
214224
</div>
215225
<div id="radio" data-noi18n><b id="r-who"></b><span id="r-txt"></span></div>
216226

@@ -222,6 +232,7 @@
222232
<button class="tb" id="t-reload" data-no-ad-refresh>Load</button>
223233
<button class="tb" id="t-crouch" data-no-ad-refresh>Duck</button>
224234
<button class="tb" id="t-use" data-no-ad-refresh>Hold</button>
235+
<button class="tb" id="t-nade" data-no-ad-refresh>Nade</button>
225236
<button class="tb" id="t-pause" data-no-ad-refresh aria-label="Pause">II</button>
226237
</div>
227238

@@ -234,7 +245,7 @@ <h1 class="t-logo" id="logo">Midnight Ops</h1>
234245
<p class="t-line" id="t-line"></p>
235246
<div class="t-btns"><button class="btn go" id="b-deploy">Deploy</button><button class="btn" id="b-missions">Missions</button><button class="btn" id="b-settings">Settings</button><button class="btn" id="b-controls">Controls</button><a class="btn" href="/e63334287a3deaa3/" style="text-decoration:none;display:inline-flex;align-items:center">Back</a></div>
236247
<p class="t-foot">Every stone, weapon and sound is made in your browser as the game starts. More missions are on the way.</p>
237-
<div class="t-keys"><span><kbd>W A S D</kbd>Move</span><span><kbd>Mouse</kbd>Look</span><span><kbd>Left</kbd>Fire</span><span><kbd>Right</kbd>Aim</span><span><kbd>R</kbd>Reload</span><span><kbd>E</kbd>Plant charge</span><span><kbd>Shift</kbd>Sprint</span><span><kbd>C</kbd>Crouch</span><span><kbd>Space</kbd>Jump</span><span><kbd>Esc</kbd>Pause</span></div>
248+
<div class="t-keys" id="t-keys"></div>
238249
</div>
239250

240251
<div class="screen card-wrap" id="missions"><div class="card wide">
@@ -274,14 +285,16 @@ <h2>Settings</h2>
274285
<label class="row"><span>Volume</span><input type="range" id="s-vol" min="0" max="1" step="0.05"></label>
275286
<label class="row"><span>Invert look up and down</span><input type="checkbox" id="s-inv"></label>
276287
<label class="row"><span>Blood effects</span><input type="checkbox" id="s-blood"></label>
288+
<label class="row"><span>Keys</span><select id="s-keys"><option value="mac">Mac: Shift aims, Control sprints</option><option value="classic">Classic: Shift sprints, right click aims</option></select></label>
289+
<label class="row"><span>Automatic reload</span><input type="checkbox" id="s-auto"></label>
277290
<div class="row"><span>Language</span><span data-lang-toggle></span></div>
278291
<p style="margin-top:12px">A change to Graphics takes effect when the page is opened again.</p>
279292
<div class="t-btns"><button class="btn go" id="b-sclose">Done</button></div>
280293
</div></div>
281294

282295
<div class="screen card-wrap" id="controls"><div class="card">
283296
<h2>Controls</h2>
284-
<div class="ctl"><b><kbd>W A S D</kbd></b><span>Move</span><b><kbd>Mouse</kbd></b><span>Look (arrow keys also work)</span><b><kbd>Left click</kbd></b><span>Fire</span><b><kbd>Right click</kbd></b><span>Aim down the sights</span><b><kbd>R</kbd></b><span>Reload</span><b><kbd>E</kbd></b><span>Hold to plant a charge on a gun</span><b><kbd>Shift</kbd></b><span>Sprint</span><b><kbd>C</kbd></b><span>Crouch (harder to see and to hit)</span><b><kbd>Space</kbd></b><span>Jump</span><b><kbd>Esc</kbd></b><span>Pause</span></div>
297+
<div class="ctl" id="ctl-list"></div>
285298
<p>On a phone or tablet: drag the left side of the screen to move, drag the right side to look, and use the buttons on the right. Push the move stick far forward to sprint.</p>
286299
<div class="t-btns"><button class="btn go" id="b-cclose">Done</button></div>
287300
</div></div>
@@ -295,7 +308,7 @@ <h2>Controls</h2>
295308
<script>
296309
if (window.IV_LOCKED) { document.getElementById('app').remove(); document.getElementById('locked').style.display = 'flex'; }
297310
else {
298-
var files = ['/lib/three/r187/three.min.js', '../autores.js', 'js/core.js', 'js/geo.js', 'js/tex.js', 'js/render.js', 'js/sky.js', 'js/ground.js', 'js/phys.js', 'js/props.js', 'js/missions.js', 'js/maps/hamlet.js', 'js/maps/compound.js', 'js/level.js', 'js/fx.js', 'js/audio.js', 'js/input.js', 'js/player.js', 'js/gunmodel.js', 'js/weapon.js', 'js/enemy.js', 'js/hud.js', 'js/mission.js', 'js/main.js'];
311+
var files = ['/lib/three/r187/three.min.js', '../autores.js', 'js/core.js', 'js/geo.js', 'js/tex.js', 'js/render.js', 'js/sky.js', 'js/ground.js', 'js/phys.js', 'js/props.js', 'js/missions.js', 'js/maps/hamlet.js', 'js/maps/compound.js', 'js/level.js', 'js/fx.js', 'js/actions.js', 'js/audio.js', 'js/input.js', 'js/player.js', 'js/gunmodel.js', 'js/weapon.js', 'js/enemy.js', 'js/hud.js', 'js/mission.js', 'js/main.js'];
299312
for (var i = 0; i < files.length; i++) document.write('<script src="' + files[i] + '"><\/script>');
300313
}
301314
</script>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* Midnight Ops: grenades (G) and pings (V).
2+
A grenade is thrown along the view, bounces off walls and the ground (ray cast each step, the velocity reflected
3+
and damped), and goes off 3.2 s after the throw: it kills or wounds soldiers within 7 m that it can "see", hurts
4+
you within 6 m, and the bang brings everyone nearby. Two per life; ammunition pouches sometimes hold one more.
5+
A ping marks whatever you are looking at for 10 seconds. */
6+
(function () {
7+
'use strict';
8+
const MO = window.MO, AC = MO.actions = { live: [], ping: null };
9+
const FUSE = 3.2, MAX = 4, hit = {}, v = new THREE.Vector3();
10+
let pool = [];
11+
12+
AC.init = () => {
13+
const S = MO.R.scene;
14+
for (let i = 0; i < MAX; i++) { // the grenade: a ridged olive body, a fuse top and its lever
15+
const b = new MO.Builder();
16+
b.add(MO.lathe([[0, -0.055], [0.022, -0.052], [0.03, -0.04], [0.031, 0.02], [0.026, 0.04], [0.014, 0.05], [0, 0.05]], 12), 'paint_olive');
17+
for (let k = 0; k < 4; k++) b.add(new THREE.TorusGeometry(0.031, 0.004, 4, 12), 'paint_olive', MO.xf(0, -0.035 + k * 0.018, 0, Math.PI / 2, 0, 0), 0.8);
18+
b.cyl('steel_dark', 0.009, 0.009, 0.025, 0, 0.06, 0, { seg: 8 }); b.box('steel_dark', 0.012, 0.06, 0.006, 0.016, 0.045, 0, { rz: -0.25, ch: 0 });
19+
const g = new THREE.Group(); b.build(g, { ao: false, dynamic: true }); g.visible = false; S.add(g);
20+
pool.push({ g: g, on: false, p: new THREE.Vector3(), v: new THREE.Vector3(), w: new THREE.Vector3(), t: 0, bounces: 0 });
21+
}
22+
};
23+
AC.reset = () => { for (const n of pool) { n.on = false; n.g.visible = false; } AC.ping = null; MO.hud && MO.hud.ping(null); };
24+
25+
AC.throwNade = () => {
26+
const W = MO.weapon, P = MO.player, A = MO.audio;
27+
if (W.nades <= 0) { MO.hud.msg(MO.T('No grenades left')); return; }
28+
const n = pool.find((q) => !q.on); if (!n) return;
29+
W.nades--; W.throwKick(); A && A.play('cloth', { vol: 0.9 }); A && A.play('bolt', { vol: 0.4, pitch: 1.6 });
30+
const cam = MO.R.camera; cam.getWorldDirection(v);
31+
n.on = true; n.t = FUSE; n.bounces = 0; n.p.copy(cam.position).addScaledVector(v, 0.5); n.p.y -= 0.12;
32+
const up = MO.clamp(0.25 - v.y * 0.3, 0.05, 0.35);
33+
n.v.copy(v).multiplyScalar(13).add(P.vel); n.v.y += 13 * up; n.w.set(Math.random() * 12 - 6, Math.random() * 12 - 6, Math.random() * 12 - 6);
34+
n.g.position.copy(n.p); n.g.visible = true;
35+
};
36+
function blast(n) {
37+
const P = MO.player, x = n.p.x, y = Math.max(0.15, n.p.y), z = n.p.z;
38+
MO.fx.explosion(x, y - 0.3, z, 0.8); MO.audio && MO.audio.play('explosion', { x: x, y: y, z: z, vol: 1 });
39+
for (const s of MO.enemies.list) { if (!s.alive) continue; const d = Math.hypot(s.x - x, s.z - z); if (d > 7) continue;
40+
if (!MO.phys.los(x, y + 0.3, z, s.x, 1.0, s.z)) continue; s.hit(Math.round(260 * Math.pow(1 - d / 7, 1.2)) + 10, false, s.x - x, s.z - z); }
41+
const dp = Math.hypot(P.pos.x - x, P.pos.z - z); if (dp < 6 && MO.phys.los(x, y + 0.3, z, P.pos.x, P.pos.y + 1, P.pos.z)) P.damage(Math.round(95 * (1 - dp / 6)), x, z);
42+
MO.emit('shot', x, z); MO.enemies.shout(x, z, 35, P.pos.x, P.pos.z);
43+
}
44+
AC.update = (dt) => {
45+
const I = MO.input, P = MO.player;
46+
if (I.nadeP && P.alive && !MO.R.hideWeapon && !MO.weapon.reloading && (MO.mission.state === 'play')) AC.throwNade();
47+
if (I.pingP && P.alive) { const cam = MO.R.camera; cam.getWorldDirection(v);
48+
const d = MO.phys.ray(cam.position.x, cam.position.y, cam.position.z, v.x, v.y, v.z, 160, hit, true) ? hit.t : 70; // nothing in the way: mark a spot in the distance
49+
AC.ping = { x: cam.position.x + v.x * d, y: Math.max(0.3, cam.position.y + v.y * d + 0.3), z: cam.position.z + v.z * d, t: 10 }; MO.hud.ping(AC.ping); MO.audio && MO.audio.play('ui_click', { vol: 0.5 }); }
50+
if (AC.ping) { AC.ping.t -= dt; if (AC.ping.t <= 0) { AC.ping = null; MO.hud.ping(null); } }
51+
for (const n of pool) { if (!n.on) continue;
52+
n.t -= dt;
53+
const steps = 3, h = dt / steps;
54+
for (let s = 0; s < steps; s++) {
55+
n.v.y -= 9.8 * h; const sp = n.v.length(), d = sp * h;
56+
if (d > 1e-5 && MO.phys.ray(n.p.x, n.p.y, n.p.z, n.v.x / sp, n.v.y / sp, n.v.z / sp, d + 0.04, hit, true)) {
57+
n.p.set(hit.x + hit.nx * 0.045, Math.max(0.045, hit.y + hit.ny * 0.045), hit.z + hit.nz * 0.045);
58+
const vn = n.v.x * hit.nx + n.v.y * hit.ny + n.v.z * hit.nz; n.v.x -= 1.4 * vn * hit.nx; n.v.y -= 1.4 * vn * hit.ny; n.v.z -= 1.4 * vn * hit.nz; n.v.multiplyScalar(0.62); n.w.multiplyScalar(0.6); if (hit.ny > 0.7) { n.v.x *= 0.45; n.v.z *= 0.45; } // the ground grips: it doesn't skid far
59+
if (n.bounces++ < 3 && sp > 2) MO.audio && MO.audio.play('shell', { x: n.p.x, y: n.p.y, z: n.p.z, vol: 0.9, pitch: 0.55 });
60+
} else n.p.addScaledVector(n.v, h);
61+
if (n.p.y < 0.05) { n.p.y = 0.045; if (n.v.y < 0) n.v.y *= -0.3; n.v.x *= 0.82; n.v.z *= 0.82; }
62+
}
63+
n.g.position.copy(n.p); n.g.rotation.x += n.w.x * dt; n.g.rotation.y += n.w.y * dt; n.g.rotation.z += n.w.z * dt;
64+
if (n.t <= 0) { n.on = false; n.g.visible = false; blast(n); }
65+
}
66+
};
67+
})();

‎e63334287a3deaa3/ironveil/js/core.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
// ---- settings and save. localStorage 'ironveil:save' = {v: 2, settings, missions: {id: {done, grade, best}}}
3838
const KEY = 'ironveil:save';
39-
const DEF = { quality: 'auto', sens: 1, invertY: false, vol: 0.8, fov: 74, blood: true };
39+
const DEF = { quality: 'auto', sens: 1, invertY: false, vol: 0.8, fov: 74, blood: true, keys: /Mac/i.test(navigator.platform || navigator.userAgent) ? 'mac' : 'classic', autoReload: true };
4040
const S = MO.save = { v: 2, settings: Object.assign({}, DEF), missions: {} };
4141
try {
4242
const j = JSON.parse(localStorage.getItem(KEY) || 'null');

0 commit comments

Comments
 (0)