Revert "Point at them, then wind up: the lane comes from where the thumb lands"
This reverts commit 1798fc67b8.
This commit is contained in:
1 parent
1798fc67b8
commit
8ea749f380
4 files changed
+17
-45
No files matched your search
@@ -5,9 +5,9 @@
|
||||
import { cv } from './dom.js';
|
||||
import { audio, pock } from './audio.js';
|
||||
import { TUNE } from './config.js';
|
||||
import { G, P, score } from './state.js';
|
||||
import { G, score } from './state.js';
|
||||
import { keyPressed, dragServe, selectWeapon, serveToss, pullQuality, dismissModal } from './gameplay.js';
|
||||
import { rackHit, proj, W, H } from './render.js';
|
||||
import { rackHit } from './render.js';
|
||||
import { togglePanel } from './panel.js';
|
||||
|
||||
const keys = {};
|
||||
@@ -41,18 +41,8 @@ export function takeFlickAim(maxAgeMs = 450) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// POINT, THEN WIND UP. Where the thumb LANDS picks the lane — a ray from your man through the
|
||||
// touch — and the pull-back after that is power and nothing else, in whatever direction there is
|
||||
// room for. The lane used to come from the pull's own direction, which meant aiming up-court was
|
||||
// always a downward drag: every shot ended lower than it began, the next touch started where the
|
||||
// last one ended, and over a horde the thumb walked itself into the iOS bottom edge, where a pull
|
||||
// down is Reachability and the system takes the gesture. Now touch-down is dictated by where the
|
||||
// shamblers are, which is up-court, so the thumb is pulled UP the screen by the game itself.
|
||||
// The cost, and the thing to feel: the lane locks when the thumb lands. You can no longer sweep
|
||||
// the aim while drawn.
|
||||
//
|
||||
// the two-stage serve: a drag that STARTS at a serveable pretoss aims a visible reticle
|
||||
// (G.aim, drawn by render); release fires the serve there, easing back home cancels.
|
||||
// (G.aim, drawn by render); release fires the serve there, dragging back home cancels.
|
||||
// EVERY phase of splatter play, so the drag never silently turns into something else. The old
|
||||
// "drag walks the player" mode between shots was invisible state and read as a bug.
|
||||
const canAimServe = () =>
|
||||
@@ -64,18 +54,6 @@ const canAimServe = () =>
|
||||
let steerPX = null; // live absolute finger x (-1..1 across the canvas) — machine-gun steering reads it
|
||||
export const touchPX = () => steerPX;
|
||||
|
||||
// The lane: a unit vector in CANVAS space from your man's chest to the thumb. gameplay reads it as
|
||||
// the shot direction straight off (screen up = -z), which is the same contract the flick-swing has
|
||||
// always used — so nothing downstream of G.aim changes.
|
||||
function laneFrom(t, r) {
|
||||
const p = proj(P.x, 1.2, P.z); // chest height: where the shot actually leaves him
|
||||
const dx = (t.clientX - r.left) / r.width * W - p.x;
|
||||
const dy = (t.clientY - r.top) / r.height * H - p.y;
|
||||
const d = Math.hypot(dx, dy);
|
||||
if (d < 6) return { fx: 0, fy: -1 }; // thumb on top of him: no lane to read, so fire up-court
|
||||
return { fx: dx / d, fy: dy / d };
|
||||
}
|
||||
|
||||
// Restarting a run no longer reloads the page (see state.resetState), so this module's own state has
|
||||
// to be put back by hand: a key still held, or a half-finished drag, would otherwise be inherited by
|
||||
// the next run's very first frame.
|
||||
@@ -97,9 +75,8 @@ cv.addEventListener('touchstart', e => {
|
||||
if (!stick) {
|
||||
stick = { id: t.identifier, x0: t.clientX, y0: t.clientY, t0: performance.now(),
|
||||
moved: false, aimable: canAimServe() }; // context locked at touch start — a movement drag never morphs into a serve
|
||||
// the LANE is locked here too, from where the thumb landed. mag 0 aims at nothing —
|
||||
// pointing costs nothing, only the pull spends anything.
|
||||
if (stick.aimable) G.aim = { ...(stick.dir = laneFrom(t, r)), mag: 0 };
|
||||
// the reticle appears the moment the thumb lands, but mag 0 aims at nothing — you have to pull
|
||||
if (stick.aimable) G.aim = { fx: 0, fy: 0, mag: 0 };
|
||||
else steerPX = (t.clientX - r.left) / r.width * 2 - 1;
|
||||
}
|
||||
else keyPressed('Space');
|
||||
@@ -113,15 +90,15 @@ cv.addEventListener('touchmove', e => {
|
||||
if (t.identifier !== stick.id) continue;
|
||||
const dx = t.clientX - stick.x0, dy = t.clientY - stick.y0, dist = Math.hypot(dx, dy);
|
||||
if (dist > DEAD) stick.moved = true;
|
||||
if (stick.aimable) { // the lane is already locked (see laneFrom) — the drag is PURE POWER now,
|
||||
if (dist > DEAD) { // so pull back, sideways, wherever there is screen. Only the length counts.
|
||||
if (stick.aimable) { // slingshot: PULL BACK, launch forward — the shot is the inverse of the drag
|
||||
if (dist > DEAD) {
|
||||
if (!stick.tossed) { serveToss(); stick.tossed = true; } // the pull kicks off the toss animation
|
||||
G.aim = { ...stick.dir, mag: dist };
|
||||
G.aim = { fx: -dx / dist, fy: -dy / dist, mag: dist };
|
||||
// the moment the pull is strong enough to actually splatter, it clicks — you can feel
|
||||
// where the threshold is without watching the reticle
|
||||
const hot = pullQuality(dist) >= TUNE.zSplatQ;
|
||||
if (hot !== !!stick.hot) { stick.hot = hot; if (hot) pock(0.45, 1250); }
|
||||
} else G.aim = { ...stick.dir, mag: 0 };
|
||||
} else G.aim = { fx: 0, fy: 0, mag: 0 };
|
||||
continue;
|
||||
}
|
||||
const r = cv.getBoundingClientRect();
|
||||
|
||||
Reference in new issue
Block a user