01 Flip
You can't jump. You can only change which way is down. Slip between the walls as the corridor speeds up.
Controls Tap, click or any key to flip gravity
959 / 1024 bytes · 65 to spare
The 959 bytes that ship
for(_='e=_at^l=X||W,tVlet U);Unte=>{re),c.fill,Styl_0)"#t.stdown=Text(&&(_l[1],1.valu_M^h.max(0,Rect(",n o=[],r=l[0]random()"#e9e7df".connect(=i.c^e · TAP TO localStorage.flip1kUe,lV,f,i,n=32d=2,T=+WR=(e,X.06V)if(!i)turn;tOscill^or(fGain();t.typ_"squa"V.fquencye,f.gain.04Vf)i.destin^ionart(op(i.curntTime+l)};onkeyonpoirnn.pe^W(i=iWnew AudioCoxt,d?(r>40Wd>1)9Xt=1,f=d=R(660)):(t=-t,R(t>0?330:440)))},setIrval(()r++"rgba(1116,.35) 82a2a36 017n0i=d?2:2+r/900;d-1r%22,70-r/40|0)<1o.push([n,24+70*,<.5]dW(X-5,min(5,l+.45*t)e+=l,e>162162,X0e<101X0f+=i/1ff4f6d";for(Ul of o){d-1(-=it=l[2]?10:170-;V2,!d<68+12>60e<t+e+8>t(d=1,r=R(11.4T=T,0|f=T)}o=o.filter(_>e[0]>-12)d?:t>0?"#ffd23f":"#3fe0ff",d<26e,8,8dd>1?"FLIPSTART":"CRASHRETRY"664),(0|f)+" HI "+T622)}6)';G=/[-U-X^_]/.exec(_);)with(_.split(G))_=join(shift());eval(_)Readable source
// FLIP: tap / space flips gravity. Slip between the walls.
// Harness gives: a = 320x180 canvas, b = body, c = 2d context.
let W = 320, H = 180, P = 60, S = 8;
let y, v, g, walls = [], t = 0, score, dead = 2, best = +localStorage.flip1k || 0, au;
// short square-wave blip; AudioContext is created on the first input (needs a gesture)
let beep = (f, d = .06, o) => {
if (!au) return;
o = au.createOscillator();
let gn = au.createGain();
o.type = 'square';
o.frequency.value = f;
gn.gain.value = .04;
o.connect(gn).connect(au.destination);
o.start();
o.stop(au.currentTime + d);
};
let start = () => { y = H / 2; v = 0; g = 1; walls = []; t = 0; score = 0; dead = 0; };
onkeydown = onpointerdown = e => {
if (e.repeat) return;
au = au || new AudioContext;
if (dead) { if (t > 40 || dead > 1) start(), beep(660); }
else g = -g, beep(g > 0 ? 330 : 440);
};
setInterval(() => {
t++;
// motion-blur clear
c.fillStyle = 'rgba(11,11,16,.35)';
c.fillRect(0, 0, W, H);
// floor + ceiling
c.fillStyle = '#2a2a36';
c.fillRect(0, 0, W, 10);
c.fillRect(0, H - 10, W, 10);
// title: the corridor scrolls at base speed (attract mode); crash: everything freezes
let speed = dead ? 2 : 2 + t / 900;
if (dead - 1 && t % Math.max(22, 70 - t / 40 | 0) < 1) walls.push([W, 24 + Math.random() * 70, Math.random() < .5]);
if (!dead) {
v = Math.max(-5, Math.min(5, v + g * .45));
y += v;
if (y > H - 10 - S) y = H - 10 - S, v = 0;
if (y < 10) y = 10, v = 0;
score += speed / 10;
}
c.fillStyle = '#ff4f6d';
for (let w of walls) {
if (dead - 1) w[0] -= speed;
// [x, height, fromTop]
let wy = w[2] ? 10 : H - 10 - w[1];
c.fillRect(w[0], wy, 12, w[1]);
if (!dead && w[0] < P + S && w[0] + 12 > P && y < wy + w[1] && y + S > wy) {
dead = 1; t = 0; beep(110, .4);
best = Math.max(best, score | 0);
localStorage.flip1k = best;
}
}
walls = walls.filter(w => w[0] > -12);
c.fillStyle = dead ? '#e9e7df' : g > 0 ? '#ffd23f' : '#3fe0ff';
if (dead < 2) c.fillRect(P, y, S, S);
if (dead) c.fillText(dead > 1 ? 'FLIP · TAP TO START' : 'CRASH · TAP TO RETRY', 160, 64);
c.fillStyle = '#e9e7df';
c.fillText((score | 0) + ' HI ' + best, 160, 22);
}, 16);