MIT-licensed original update function retained unchanged, with a minimal standalone Canvas compatibility layer, a new responsive interface and local records. The original uses crisp-game-lib. This edition uses geometric polygon collision tests in place of pixel collision tests and a seeded local random generator; the frame rate, droplet coalescence, accelerating falls, blade angles, scoring and loss rule are retained. Sound is newly synthesized locally. Source collection observed at 9 stars on November 5, 2026; last repository push June 12, 2024.
Pinned upstream source · App metadata
MIT License Copyright (c) 2021 ABA Games Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
title = "WIPER";
description = `
[Tap] Swing
`;
characters = [];
options = {
theme: "dark",
isPlayingBgm: true,
isReplayEnabled: true,
seed: 8,
};
/** @type {{pos: Vector, size: number}[]} */
let rains;
let nextRainTicks;
let wiperAngle;
let wiperVa;
function update() {
if (!ticks) {
rains = [];
nextRainTicks = 0;
wiperAngle = (-PI / 5) * 4;
wiperVa = 1;
}
wiperAngle += wiperVa * 0.05 * sqrt(difficulty);
if (
(wiperAngle > -PI / 5 && wiperVa > 0) ||
(wiperAngle < (-PI / 5) * 4 && wiperVa < 0)
) {
play("hit");
wiperVa *= -1;
}
let ta = wiperVa > 0 ? -PI / 5 : (-PI / 5) * 4;
if (wiperAngle > -PI / 3) {
ta = (-PI / 5) * 4;
}
if (wiperAngle < (-PI / 3) * 2) {
ta = -PI / 5;
}
color("light_black");
bar(50, 110, 36, 2, ta, -0.7);
if (input.isJustPressed) {
play("select");
wiperAngle = ta;
wiperVa *= -1;
}
color("black");
bar(50, 110, 36, 6, wiperAngle, -0.7);
nextRainTicks--;
if (nextRainTicks < 0) {
rains.push({ pos: vec(rnd(10, 90), rnd(20)), size: 2 });
nextRainTicks = 10 / difficulty;
}
remove(rains, (r) => {
color("transparent");
let isRemoved = box(r.pos, sqrt(r.size) * 2).isColliding.rect.black;
let isAbsorbed = false;
rains.forEach((or) => {
if (
r.pos.y > or.pos.y &&
r.pos.distanceTo(or.pos) < sqrt(r.size + or.size) * 2
) {
or.size += r.size;
or.pos.x = (or.pos.x + r.pos.x) / 2;
isAbsorbed = true;
}
});
if (isAbsorbed) {
play("laser");
return true;
}
r.pos.y += sqrt(r.size - 1.9) * 0.3 * sqrt(difficulty);
color("cyan");
if (isRemoved || box(r.pos, sqrt(r.size)).isColliding.rect.black) {
play("powerUp");
addScore(ceil(r.size - 1), r.pos);
return true;
}
if (r.pos.y > 99) {
play("explosion");
color("red");
text("X", r.pos.x, 97);
end();
}
});
}
/* Minimal Canvas compatibility layer for ABA Games' MIT-licensed WIPER.
Only the drawing, collision, vector, random and score APIs used by that game.
Geometry uses convex polygon intersection rather than engine pixel tests. */
var title,description,characters,options;
var ticks=0,difficulty=1,score=0,input={isJustPressed:false};
const PI=Math.PI,sqrt=Math.sqrt,ceil=Math.ceil;
const canvas=document.getElementById('game'),ctx=canvas.getContext('2d');
let ink='black',shapes=[],rngState=8,clearedCount=0;
let active=false,paused=false,ended=false,soundOn=false,audioContext;
let flash=0,particles=[],pendingSweep=false,shake=0;
const palette={black:'#eef5d8',light_black:'#56828a',cyan:'#95e7e4',red:'#ffb19d',transparent:'transparent'};
function vec(x=0,y=0){return {x,y,distanceTo(p){return Math.hypot(this.x-p.x,this.y-p.y)}}}
function rnd(lo=1,hi){if(hi===undefined){hi=lo;lo=0}rngState=(Math.imul(rngState,1664525)+1013904223)>>>0;return lo+(rngState/4294967296)*(hi-lo)}
function color(c){ink=c}
function intersects(a,b){for(const poly of [a,b]){for(let i=0;i<poly.length;i++){let p=poly[i],q=poly[(i+1)%poly.length],ax=-(q.y-p.y),ay=q.x-p.x;let ap=a.map(v=>v.x*ax+v.y*ay),bp=b.map(v=>v.x*ax+v.y*ay);if(Math.max(...ap)<Math.min(...bp)||Math.max(...bp)<Math.min(...ap))return false}}return true}
function shape(poly){let hits={};for(const s of shapes){if(intersects(poly,s.poly))hits[s.color]=true}if(ink!=='transparent'){ctx.fillStyle=palette[ink]||ink;ctx.beginPath();poly.forEach((p,i)=>i?ctx.lineTo(p.x,p.y):ctx.moveTo(p.x,p.y));ctx.closePath();ctx.fill();shapes.push({poly,color:ink})}return {isColliding:{rect:hits}}}
function box(p,w){let h=w;return shape([{x:p.x-w/2,y:p.y-h/2},{x:p.x+w/2,y:p.y-h/2},{x:p.x+w/2,y:p.y+h/2},{x:p.x-w/2,y:p.y+h/2}])}
function bar(x,y,len,width,angle,center=0.5){const ux=Math.cos(angle),uy=Math.sin(angle),vx=-uy,vy=ux;const a={x:x-ux*len*center,y:y-uy*len*center},b={x:x+ux*len*(1-center),y:y+uy*len*(1-center)};return shape([{x:a.x+vx*width/2,y:a.y+vy*width/2},{x:b.x+vx*width/2,y:b.y+vy*width/2},{x:b.x-vx*width/2,y:b.y-vy*width/2},{x:a.x-vx*width/2,y:a.y-vy*width/2}])}
function text(s,x,y){ctx.fillStyle=palette[ink]||ink;ctx.font='5px system-ui';ctx.textAlign='center';ctx.fillText(s,x,y)}
function remove(arr,predicate){let keep=[];for(let i=0;i<arr.length;i++){if(!predicate(arr[i],i))keep.push(arr[i])}arr.splice(0,arr.length,...keep)}
function addScore(n,p){score+=n;clearedCount++;flash=5;for(let i=0;i<5;i++)particles.push({x:p.x,y:p.y,vx:(i-2)*.16,vy:-.2-Math.abs(i-2)*.03,life:22})}
function play(type){if(type==='select')shake=3;if(!soundOn)return;try{audioContext??=new (window.AudioContext||window.webkitAudioContext)();if(audioContext.state==='suspended')audioContext.resume();const osc=audioContext.createOscillator(),g=audioContext.createGain(),now=audioContext.currentTime;osc.type='sine';osc.frequency.setValueAtTime(({select:350,hit:130,laser:220,powerUp:650,explosion:80})[type]||300,now);g.gain.setValueAtTime(.035,now);g.gain.exponentialRampToValueAtTime(.001,now+.09);osc.connect(g);g.connect(audioContext.destination);osc.start();osc.stop(now+.1)}catch{soundOn=false}}
function end(){if(!ended){active=false;ended=true;onGameEnd()}}
function drawBackground(){ctx.setTransform(6,0,0,6,0,0);ctx.fillStyle='#15343e';ctx.fillRect(0,0,100,100);ctx.strokeStyle='#2c525b';ctx.lineWidth=.15;for(let x=10;x<100;x+=10){ctx.beginPath();ctx.moveTo(x,0);ctx.lineTo(x,100);ctx.stroke()}for(let y=10;y<100;y+=10){ctx.beginPath();ctx.moveTo(0,y);ctx.lineTo(100,y);ctx.stroke()}ctx.fillStyle='#a6d3d3';ctx.globalAlpha=.13;for(let i=0;i<16;i++){const x=(i*31.7)%100,y=(i*17.3+ticks*.015)%100;ctx.fillRect(x,y,.13,3)}ctx.globalAlpha=1;ctx.strokeStyle='#d7c791';ctx.lineWidth=.35;ctx.beginPath();ctx.moveTo(1,99);ctx.lineTo(99,99);ctx.stroke()}
let previous=0,accumulator=0;
function frame(now){const dt=previous?Math.min(now-previous,100):0;previous=now;if(active&&!paused){accumulator+=dt;let count=0;while(accumulator>=1000/60&&active&&count++<6){shapes=[];drawBackground();input.isJustPressed=pendingSweep;pendingSweep=false;difficulty=1+ticks/3600;update();input.isJustPressed=false;ticks++;accumulator-=1000/60;for(const p of particles){p.x+=p.vx;p.y+=p.vy;p.life--;ctx.globalAlpha=p.life/22;ctx.fillStyle='#c4ffea';ctx.fillRect(p.x,p.y,.4,.4)}ctx.globalAlpha=1;particles=particles.filter(p=>p.life>0);if(flash>0)flash--;if(shake>0)shake--;updateHud()}}requestAnimationFrame(frame)}
window.addEventListener('error',e=>{document.getElementById('status').textContent='Something interrupted the rain. Reload to restart.'});
Object.defineProperty(window,'rainkeeperState',{get(){return {ticks,score,cleared:clearedCount,active,paused,ended,difficulty,angle:typeof wiperAngle==='undefined'?null:wiperAngle,dropCount:typeof rains==='undefined'?0:rains.length,drops:typeof rains==='undefined'?[]:rains.map(r=>({x:r.pos.x,y:r.pos.y,size:r.size}))}}});
const $=id=>document.getElementById(id);
let record=0,runs=0;
try{const s=JSON.parse(localStorage.getItem('rainkeeper-v1')||'{}');record=Number(s.best)||0;runs=Number(s.runs)||0;soundOn=!!s.sound}catch{}
function save(){try{localStorage.setItem('rainkeeper-v1',JSON.stringify({best:record,runs,sound:soundOn}))}catch{}}
function updateHud(){$('score').textContent=Math.floor(score);$('cleared').textContent=clearedCount;$('best').textContent=Math.max(record,Math.floor(score))}
function overlay(heading,message,button,overline){$('overlay').hidden=false;$('heading').textContent=heading;$('message').textContent=message;$('start').textContent=button;$('overline').textContent=overline}
function startGame(){ticks=0;score=0;clearedCount=0;rngState=8;rains=[];particles=[];accumulator=0;pendingSweep=false;ended=false;paused=false;active=true;$('overlay').hidden=true;document.body.classList.remove('paused');for(const id of ['sweep','pause','restart'])$(id).disabled=false;$('pause').textContent='Pause';$('status').textContent='Tap to sweep. Keep every drop above the gold line.';updateHud();canvas.focus({preventScroll:true})}
function onGameEnd(){record=Math.max(record,Math.floor(score));runs++;save();updateHud();$('sweep').disabled=true;$('pause').disabled=true;overlay('The rain got through.',`${Math.floor(score)} points · ${clearedCount} drops cleared. Your best is ${record}.`,'Try again','STORM '+String(runs).padStart(2,'0')+' COMPLETE');$('status').textContent='A drop crossed the bottom. Ready for another storm?'}
function togglePause(){if(!active)return;paused=!paused;pendingSweep=false;accumulator=0;$('pause').textContent=paused?'Resume':'Pause';document.body.classList.toggle('paused',paused);$('sweep').disabled=paused;if(paused){overlay('A quiet moment.','The storm will wait for you.','Resume the rain','PAUSED');$('status').textContent='Paused. Press P or Resume to continue.'}else{$('overlay').hidden=true;$('status').textContent='Tap to sweep. Keep every drop above the gold line.';canvas.focus({preventScroll:true})}}
function sweep(){if(active&&!paused){pendingSweep=true}}
$('start').addEventListener('click',()=>paused?togglePause():startGame());$('sweep').addEventListener('pointerdown',e=>{if(e.button===0){e.preventDefault();sweep()}});$('sweep').addEventListener('click',e=>{if(e.detail===0)sweep()});canvas.addEventListener('pointerdown',e=>{if(e.button===0){e.preventDefault();canvas.focus({preventScroll:true});sweep()}});$('restart').addEventListener('click',startGame);$('pause').addEventListener('click',togglePause);
function renderSound(){$('sound').textContent=soundOn?'Sound on':'Sound off';$('sound').setAttribute('aria-pressed',String(soundOn))}
$('sound').addEventListener('click',()=>{soundOn=!soundOn;renderSound();save();if(soundOn)play('powerUp')});
document.addEventListener('keydown',e=>{if(e.repeat)return;if(e.key.toLowerCase()==='p'){e.preventDefault();togglePause();return}if(e.key===' '||e.key==='Enter'){if(e.target.tagName==='BUTTON'||e.target.tagName==='A')return;e.preventDefault();if(!active)startGame();else if(paused)togglePause();else sweep()}});
document.addEventListener('visibilitychange',()=>{if(document.hidden&&active&&!paused)togglePause()});
updateHud();renderSound();drawBackground();requestAnimationFrame(frame);
*{box-sizing:border-box}body{margin:0;background:#10252e;color:#eaf3eb;font-family:system-ui,-apple-system,sans-serif;background-image:radial-gradient(ellipse at 80% 20%,#234b5544,transparent 65%)}main{max-width:1080px;margin:auto;padding:30px 36px}header{display:flex;justify-content:space-between;align-items:center;gap:12px}.brand{font-weight:750;font-size:14px;letter-spacing:3px;color:inherit;text-decoration:none}.brand span{display:block;font-size:10px;letter-spacing:2px;color:#98b8ba;margin-top:6px}button{border:1px solid #7392935c;background:#203f48;color:#eef6eb;border-radius:9px;padding:12px 18px;font:600 14px system-ui;cursor:pointer;touch-action:manipulation}button:hover:not(:disabled){background:#365b61}button:focus-visible,a:focus-visible,canvas:focus-visible{outline:3px solid #ffdc9b;outline-offset:4px}button:disabled{opacity:.36;cursor:default}.intro{float:left;width:43%;padding-top:88px}.eyebrow{font-size:10px;letter-spacing:2.5px;color:#a5cbca}h1{font-family:Georgia,serif;font-size:52px;line-height:1.09;font-weight:400;letter-spacing:-2px;margin:24px 0}h1 em{color:#b4e6d3;font-weight:400}.intro>p:last-child{color:#b6ccca;line-height:1.8;font-size:14px}.cabinet{margin:45px 0 0 auto;width:51%;background:#0a1b23;padding:16px;border:1px solid #6c929659;border-radius:20px;box-shadow:0 30px 70px #0003}.metrics{display:flex;justify-content:space-around;padding:3px 0 16px}.metrics div{display:grid;text-align:center;gap:5px}.metrics span{font-size:9px;letter-spacing:2px;color:#8daeb3}.metrics strong{font-size:24px;font-weight:500;font-variant-numeric:tabular-nums}.glass{position:relative;border:1px solid #66919955;border-radius:8px;overflow:hidden;background:#15343e;aspect-ratio:1}canvas{display:block;width:100%;height:100%;touch-action:none}.glass-label{position:absolute;bottom:9px;left:14px;font:8px system-ui;letter-spacing:2px;opacity:.45;pointer-events:none}#overlay{position:absolute;inset:0;background:#102933ed;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:20px}#overlay[hidden]{display:none}#overline{font-size:9px;letter-spacing:2px;color:#b5dcce}h2{font:36px Georgia,serif;font-weight:400;margin:14px 0}#message{font-size:13px;color:#bfd3cf;line-height:1.7}#start{margin:12px 0;background:#c9e9d4;color:#153e3c;padding:15px 28px;border:0}#start:hover{background:#e6f5df}.small{font-size:8px;letter-spacing:2px;color:#97b5b8}.controls{display:flex;gap:8px;margin-top:13px}.controls button{padding:12px 10px;font-size:12px}.controls #sweep{flex:1;background:#355c5e}kbd{font:8px system-ui;margin-left:12px;color:#bbd2c8;border:1px solid #729b95;padding:2px 4px;border-radius:3px}#status{color:#9ebbbd;font-size:11px;text-align:center;min-height:16px;margin:12px 0 0}.guide{clear:both;display:grid;grid-template-columns:repeat(3,1fr);gap:40px;padding-top:65px}.guide span{font-size:10px;color:#8caeac;letter-spacing:2px}.guide h3{font:22px Georgia,serif;margin:12px 0}.guide p{color:#a7c0bf;font-size:12px;line-height:1.8}footer{display:flex;align-items:center;justify-content:space-between;gap:20px;border-top:1px solid #95b4ad2a;margin-top:40px;padding-top:20px;font-size:10px;line-height:1.7;color:#8caeac}a{color:#bddacb}body.paused canvas{filter:blur(3px)}@media(max-width:740px){main{padding:20px 16px}.intro{float:none;width:auto;text-align:center;padding-top:28px}h1{font-size:39px;margin:16px 0}.intro>p:last-child{font-size:12px;margin-bottom:0}.cabinet{width:min(100%,470px);margin:26px auto 0;padding:12px}.guide{gap:15px;padding-top:35px}.guide h3{font-size:17px}.guide p{font-size:11px}.brand{font-size:11px;letter-spacing:2px}.brand span{font-size:8px}header button{font-size:11px;padding:9px 12px}.desktop{display:none}h2{font-size:32px}.metrics strong{font-size:22px}footer{margin-top:25px}.controls button{padding:12px 8px}}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto}}