Pumba & Voltina
Hey Voltina! Got a wild idea—let's throw a coding dance party! We'll prototype a tiny game in minutes, keep the code super clean, then celebrate with a victory dance—no messy spaghetti, just pure joy and efficient fun!
Sounds fun, but give me a concrete spec first. No vague “wild idea” – I’ll prototype a clean, minimal game, then we can dance if the code passes the lint.
Sure thing, Voltina! Here’s a crisp, no‑fuss spec for “Catch the Falling Stars”:
1. Title: Catch the Falling Stars
2. Goal: Catch 10 stars in 30 seconds.
3. Controls: Arrow keys move a basket left/right.
4. Gameplay: Stars fall from random x‑positions at 1 star/sec.
5. Scoring: +1 point per caught star, −1 for a miss.
6. End: Game ends when time’s up; display final score.
7. Tech: Use vanilla JavaScript, HTML5 canvas, and CSS.
8. Lint: Run eslint before the dance—no errors, just pure code joy!
Got it, no fluff. I’ll spin up a single‑file prototype, run eslint, and if it passes, we’ll dance. Just hit start.
All set! Fire up that file, crank the lint, and let’s see if the code can keep up with my dancing moves! If it passes, it’s a win—time to celebrate!
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Catch the Falling Stars</title><style>body{margin:0;font-family:sans-serif;background:#000;color:#fff}canvas{display:block;margin:auto;background:#111}</style></head><body><canvas id="gameCanvas" width="400" height="600"></canvas><script>const canvas=document.getElementById('gameCanvas');const ctx=canvas.getContext('2d');const basketWidth=60;const basketHeight=20;const starSize=15;const gameDuration=30000;const spawnInterval=1000;let basketX=(canvas.width-basketWidth)/2;let score=0;let stars=[];let lastSpawn=0;let startTime=0;let animationFrame;function drawBasket(){ctx.fillStyle='#ff0';ctx.fillRect(basketX,canvas.height-basketHeight-10,basketWidth,basketHeight);}function drawStars(){ctx.fillStyle='#0ff';stars.forEach(star=>{ctx.fillRect(star.x,star.y,starSize,starSize);});}function updateStars(delta){stars.forEach(star=>{star.y+=star.speed;});stars=stars.filter(star=>star.y<canvas.height);stars.forEach(star=>{if(star.y>canvas.height){score--;}});stars.forEach(star=>{if(star.y+starSize>=canvas.height-basketHeight-10&&star.x+starSize>=basketX&&star.x<=basketX+basketWidth){score++;stars=stars.filter(s=>s!==star);}});}function spawnStar(){stars.push({x:Math.random()*(canvas.width-starSize),y:-starSize,speed:2});}function loop(timestamp){if(!startTime){startTime=timestamp;lastSpawn=timestamp;}const delta=timestamp-lastSpawn;if(delta>spawnInterval){spawnStar();lastSpawn=timestamp;}updateStars(delta);ctx.clearRect(0,0,canvas.width,canvas.height);drawStars();drawBasket();ctx.fillStyle='#fff';ctx.font='20px sans-serif';ctx.fillText('Score:'+score,10,30);if(timestamp-startTime<gameDuration){animationFrame=requestAnimationFrame(loop);}else{ctx.fillText('Game Over',canvas.width/2-70,canvas.height/2);cancelAnimationFrame(animationFrame);}}window.addEventListener('keydown',e=>{if(e.key==='ArrowLeft'){basketX=Math.max(0,basketX-10);}else if(e.key==='ArrowRight'){basketX=Math.min(canvas.width-basketWidth,basketX+10);}});animationFrame=requestAnimationFrame(loop);</script></body></html>