The game gets a shell: it buzzes in your hand, never turns sideways, and a swipe walks you back
A Capacitor iOS project (`npm run ios`), and the first three bullets of LATER item 2 built. The web
build is untouched and stays primary: every line here degrades to a no-op in a browser.
- HAPTICS ride the sound map, as the plan said they would: six call sites, all of them places an
sfx already fires — your racket contact, the serve strike, `killZombie` (the one funnel every
weapon routes through), `explode`, `hurtPlayer`, `killPlayer`, the weapon swap. The restraint
rule lives in `haptics.js`, not at the call sites: a minimum gap per kind, so a bomb that kills
twelve bodies is felt twice and the machine gun is a metronome rather than one long rumble.
Pinned by a test. Untested on hardware — the simulator has no Taptic Engine.
- The plugin is reached through the INJECTED bridge, `Capacitor.nativePromise('Haptics', ...)`.
`Capacitor.Plugins.Haptics` reads like the zero-dependency answer and is silently empty without
@capacitor/core's registerPlugin — it would have fallen through to the web path inside the app
and looked exactly like a phone with haptics switched off. No package JS ships.
- PORTRAIT is enforced where it can be: one orientation in Info.plist, so the app never rotates.
That retires landscape as a surface rather than fixing it (OPEN 6). The web half is best-effort —
`orientation` in both manifests and one guarded `screen.orientation.lock()`.
- SWIPE LEFT GOES BACK. The gesture finds the screen's one visible chevron and clicks it, so the
shape of the wizard stays in the handlers that already own it. Not passive on purpose: a swipe
inside a poster card also fires that card's click, and preventDefault is what stops the screen
answering forward in the frame the chevron walked it back.
- The app has no server behind it, so `config.API` and one branch in `net.js` point the shell at the
live host by name. Consequence: the app always talks to PROD, never staging.
`node test.js` green (105) over four seeds; builds, launches and reaches the native plugin on the
iOS 26.5 simulator; swipe-back walks the whole wizard in the browser pane.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5eb6846e3
commit
d71a26831a
35 files changed
+2124
-11
No files matched your search
+39
-1
@@ -12,6 +12,7 @@ import { fitViewport, render, proj, RES, SPRV, LOAD, SPR, drawLook } from './ren
|
||||
import { voice, ambient, menuMusic, menuDuck } from './audio.js';
|
||||
import { zombies, spawnZombie, spawnRacketZombie, spawnMachine, spawnChapterBoss, piles, gore, parts, pellets, extras, shots, pops, explode, hurtPlayer, killPlayer , spawnBarrel } from './zombies.js';
|
||||
import { cv } from './dom.js';
|
||||
import { haptic } from './haptics.js';
|
||||
import * as stats from './stats.js';
|
||||
import './input.js';
|
||||
|
||||
@@ -45,6 +46,14 @@ function frame(now) {
|
||||
update(dt); render();
|
||||
}
|
||||
|
||||
// PORTRAIT ONLY, from 2026-08-20. The app enforces it where it can actually be enforced — the
|
||||
// shell's Info.plist lists one supported orientation, so an iPhone running the store build simply
|
||||
// never rotates. This line is the WEB half of the same decision and is best-effort by nature:
|
||||
// Chrome/Android honours a lock once the page is installed or fullscreen, and iOS Safari has no
|
||||
// Screen Orientation lock at all, so the browser build keeps doing whatever landscape does today
|
||||
// (PROJECT.md OPEN 6 — landscape is untested, not a surface). Nothing downstream may assume it took.
|
||||
try { screen.orientation?.lock?.('portrait')?.catch(() => {}); } catch {}
|
||||
|
||||
fitViewport();
|
||||
// iOS PWA cold start. Launched from the homescreen, WebKit resolves the viewport AND every env()
|
||||
// safe-area inset once, against a provisional geometry, and never revisits them until the geometry
|
||||
@@ -528,6 +537,35 @@ document.getElementById('sBack').addEventListener('click', () => {
|
||||
});
|
||||
document.getElementById('bsBack').addEventListener('click', () => go('secret'));
|
||||
|
||||
// SWIPE TO GO BACK. Every screen but the splash wears exactly one chevron in its header (.hdr in
|
||||
// index.html) and that button ALREADY knows where back is for its own screen — the wizard's shape
|
||||
// lives in the handlers above and nowhere else. So the gesture finds the one visible chevron and
|
||||
// clicks it, rather than keeping a second map that would drift the first time a stage is added.
|
||||
// A screen with no chevron (splash, newbest) has nowhere to go and the swipe is simply ignored.
|
||||
// Touch only: a trackpad two-finger scroll is not a swipe and must not navigate.
|
||||
const SWIPE_MIN = 60; // px of travel before it counts — a tap that slides is not a swipe
|
||||
let swipe = null;
|
||||
intro.addEventListener('touchstart', e => {
|
||||
swipe = e.touches.length === 1 ? { x: e.touches[0].clientX, y: e.touches[0].clientY } : null;
|
||||
}, { passive: true });
|
||||
intro.addEventListener('touchend', e => {
|
||||
const from = swipe; swipe = null;
|
||||
if (!from || e.touches.length) return;
|
||||
const t = e.changedTouches[0];
|
||||
const dx = t.clientX - from.x, dy = t.clientY - from.y;
|
||||
// leftward, and clearly horizontal: the stats and board screens scroll vertically under the finger
|
||||
if (dx > -SWIPE_MIN || Math.abs(dy) > Math.abs(dx) * 0.7) return;
|
||||
const back = [...intro.querySelectorAll('.chev')].find(b => b.offsetParent); // the one on screen
|
||||
if (!back) return;
|
||||
// NOT passive, and this is why: a swipe that starts and ends inside one of the big poster cards
|
||||
// still produces that card's click, which would answer the screen forward in the same frame the
|
||||
// chevron walked it back. preventDefault on touchend cancels the compatibility mouse events, so
|
||||
// the gesture means one thing only.
|
||||
e.preventDefault();
|
||||
haptic('select');
|
||||
back.click();
|
||||
});
|
||||
|
||||
// ---- THE BACK ROOM: five taps in the TOP-LEFT CORNER of the splash (#hot, an invisible box in
|
||||
// index.html), and nothing on the screen says so. It replaces the triple-tap on the in-play
|
||||
// scoreboard, which sat on top of the miss-log tap and which the testteam kept opening by accident.
|
||||
@@ -639,7 +677,7 @@ const tick = setInterval(function watchLoad() {
|
||||
// real buttons now. This is the gesture the autoplay policy is waiting for, which is why the theme
|
||||
// is not started at boot. menuMusic itself is a no-op once the bed exists (loopBed's beds.has
|
||||
// guard), so coming back from a run picks up the track already playing rather than restarting it.
|
||||
intro.addEventListener('pointerdown', () => menuMusic());
|
||||
intro.addEventListener('pointerdown', e => { menuMusic(); if (e.target.closest('button')) haptic('select'); });
|
||||
// which build am I looking at? Push = deploy and the browser cannot see git, so the served file's
|
||||
// own timestamp IS the version marker — it changes on every deploy, with nothing to remember to bump.
|
||||
// Match it against `git log -1 --format=%cd` when a phone looks suspiciously out of date.
|
||||
|
||||
Reference in new issue
Block a user