// const canvas = document.getElementById('canvas'); // const ctx = canvas.getContext('2d'); // // let width = 500, // height = 800; // // const rectSize = width / 7, // ballRadius = 12, // powerUpRadius = 15, // ballVelocity = 15, // frameRate = 60; // // const sounds = { // }; // // let roundNumber = 0; // // const rects = []; // const powerUps = []; // let balls = []; // let ballCount = 1; // let remainingBalls; // let newBalls = 0; // let originX; // let newOriginX = 250; // const originY = 9 * rectSize; // let isMoving = false; // // let coinAngle = 0; // // let mousePos = null; // // function drawShootingLine() { // const dx = mousePos.x - originX; // const dy = originY - mousePos.y; // let angle = Math.atan(dy / dx); // let curX = originX; // let curY = originY; // // if (dx < 0) // angle += Math.PI; // // angle = Math.min(Math.max(angle, 0.05), Math.PI - 0.05); // // ctx.fillStyle = 'rgba(255, 255, 255, .5)'; // for (let i = 0; i < 10; i++) { // ctx.beginPath(); // ctx.arc(curX, curY, ballRadius, 0, 2 * Math.PI); // ctx.fill(); // // curX += ballRadius * 4 * Math.cos(angle); // curY -= ballRadius * 4 * Math.sin(angle); // } // } // // function update() { // balls.forEach(ball => { // ball.update(10); // }); // // coinAngle += .05; // // requestAnimationFrame(update); // } // // function draw() { // ctx.clearRect(0, 0, canvas.width, canvas.height); // // ctx.fillStyle = 'rgba(0,0,0,.15)'; // ctx.fillRect(0, originY + ballRadius, width, height - originX - ballRadius); // // rects.forEach(rect => rect.draw()); // // powerUps.forEach(powerUp => powerUp.draw()); // // if (originX !== null) { // if (!isMoving && mousePos !== null) { // drawShootingLine(); // } // // ctx.fillStyle = '#fff'; // ctx.beginPath(); // ctx.arc(originX, originY, ballRadius, 0, 2 * Math.PI); // ctx.fill(); // // if (remainingBalls > 0) { // ctx.fillText(`${remainingBalls}x`, originX, originY + 50); // } else { // originX = null; // } // } // if(newOriginX !== null) { // ctx.fillStyle = '#fff'; // ctx.beginPath(); // ctx.arc(newOriginX, originY, ballRadius, 0, 2 * Math.PI); // ctx.fill(); // } // // balls.forEach(ball => { // ball.draw(); // }); // // requestAnimationFrame(draw); // } // // onRoundEnd(); // update(); // draw(); // // canvas.addEventListener('mousemove', (e) => { // mousePos = cbRelMousePos(e); // }); // // canvas.addEventListener('click', (e) => { // mousePos = cbRelMousePos(e); // shoot(); // }); // // async function shoot() { // if (isMoving) // return; // // if (mousePos.y >= originY) // return; // // isMoving = true; // const dx = mousePos.x - originX, // dy = originY - mousePos.y; // let dir = Math.atan(dy / dx); // if (dx < 0) { // dir += Math.PI; // } // // dir = Math.min(Math.max(dir, 0.05), Math.PI - 0.05); // // for (let i = 0; i < ballCount; i++) { // balls.push(new Ball(originX, originY, ballVelocity, dir)); // remainingBalls--; // await sleep(100); // } // } // // function onRoundEnd() { // isMoving = false; // roundNumber++; // ballCount += newBalls; // newBalls = 0; // remainingBalls = ballCount; // originX = newOriginX; // newOriginX = null; // // rects.forEach(rect => { // moveObject(rect, 0, rectSize, 500); // // if(rect.y + 2 * rectSize >= originY) { // gameOver(); // } // }); // // powerUps.forEach(powerUp => { // moveObject(powerUp, 0, rectSize, 500); // // if(powerUp.cy + rectSize >= originY) { // setTimeout(() => { // powerUp.remove(); // }, 500); // } // }); // // const cols = width / rectSize; // const spawnBall = Math.random() < .5; // const ballPos = spawnBall ? Math.round(Math.random() * (width / rectSize - 1)) : null; // const spawnCoin = Math.random() < .33; // const coinPos = spawnCoin ? Math.round(Math.random() * (width / rectSize - 1)) : null; // for (let i = 0; i < cols; i++) { // if (spawnBall && i === ballPos) { // const powerUp = new PowerUpBall((i + .5) * rectSize, .5 * rectSize); // powerUps.push(powerUp); // // moveObject(powerUp, 0, rectSize, 500); // } else if (spawnCoin && i === coinPos) { // const powerUp = new PowerUpCoin((i + .5) * rectSize, .5 * rectSize); // powerUps.push(powerUp); // // moveObject(powerUp, 0, rectSize, 500); // } else { // if (Math.random() < .6) { // const number = Math.random() < .5 ? roundNumber : 2 * roundNumber; // const rect = new Rect(i * rectSize, 0, number); // rects.push(rect); // // moveObject(rect, 0, rectSize, 500); // } // } // } // // sounds.roundOver.play(); // } // // // function gameOver() { // } // //