Run details
- Model
- poolside/laguna-s-2.1
- Route
- OpenRouter API
- Served by
- Poolside
- Effort
- model default
- Limits
- 60 min · 131,072 output tokens (model max)
- Date
- 24 Oct 2026
- Time
- 74 s
- Size
- 24 kB
- Tokens
- 119 in, 7,073 out (265 thinking)
- List price
- $0.001 at today's price ($0.09 in / $0.18 out per M)
- Paid
- $0.001
Prompt
Make a Breakout game I can play right now with the keyboard or the mouse. Give it several levels, a score and some juice. It must be one complete, self-contained HTML file: inline all CSS and JavaScript, and make no network requests of any kind (no CDNs, web fonts or remote images). Reply with the file in a single ```html code block.
Source
24 kB 715 lines Raw
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Breakout Game</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
overflow: hidden;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Courier New', monospace;
color: white;
}
.game-container {
position: relative;
width: 800px;
max-width: 95vw;
}
.game-ui {
display: flex;
justify-content: space-between;
margin-bottom: 20px;
padding: 15px;
background: rgba(0, 0, 0, 0.3);
border-radius: 10px;
backdrop-filter: blur(5px);
}
.score-panel {
text-align: center;
}
.score-value {
font-size: 2.5rem;
font-weight: bold;
color: #f9ca24;
text-shadow: 0 0 10px rgba(249, 202, 36, 0.7);
}
.level-panel {
text-align: center;
}
.level-value {
font-size: 2.5rem;
font-weight: bold;
color: #eb4d4b;
text-shadow: 0 0 10px rgba(235, 77, 75, 0.7);
}
.lives-panel {
text-align: center;
}
.lives-value {
font-size: 2.5rem;
font-weight: bold;
color: #2ecc71;
text-shadow: 0 0 10px rgba(46, 204, 113, 0.7);
}
.game-canvas {
background: #000;
border-radius: 10px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
display: block;
}
.game-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
pointer-events: none;
}
.message {
font-size: 3rem;
font-weight: bold;
padding: 20px 40px;
border-radius: 10px;
background: rgba(0, 0, 0, 0.7);
text-align: center;
pointer-events: none;
text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
.instructions {
margin-top: 20px;
font-size: 1.2rem;
color: #bdc3c7;
text-align: center;
max-width: 90%;
pointer-events: none;
}
/* Particle styles */
.particle {
position: absolute;
border-radius: 50%;
pointer-events: none;
}
/* Screen shake animation */
@keyframes shake {
0%, 100% { transform: translate(0); }
20% { transform: translate(-5px, 5px); }
40% { transform: translate(5px, -5px); }
60% { transform: translate(-5px, -5px); }
80% { transform: translate(5px, 5px); }
}
.shake {
animation: shake 0.5s ease-in-out;
}
</style>
</head>
<body>
<div class="game-container">
<div class="game-ui">
<div class="score-panel">
<div>SCORE</div>
<div class="score-value" id="score">0</div>
</div>
<div class="level-panel">
<div>LEVEL</div>
<div class="level-value" id="level">1</div>
</div>
<div class="lives-panel">
<div>LIVES</div>
<div class="lives-value" id="lives">3</div>
</div>
</div>
<canvas class="game-canvas" id="gameCanvas" width="800" height="500"></canvas>
<div class="game-overlay" id="gameOverlay"></div>
<div class="instructions">
Move mouse left/right to control paddle | Arrow keys also work | Break all bricks to advance
</div>
</div>
<script>
// Game elements
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const scoreElement = document.getElementById('score');
const levelElement = document.getElementById('level');
const livesElement = document.getElementById('lives');
const overlay = document.getElementById('gameOverlay');
const container = document.querySelector('.game-container');
// Game state
let score = 0;
let level = 1;
let lives = 3;
let gameState = 'playing'; // 'playing', 'levelComplete', 'gameOver', 'victory'
let particles = [];
// Paddle properties
const paddle = {
x: canvas.width / 2 - 60,
y: canvas.height - 20,
width: 120,
height: 15,
dx: 0,
speed: 10
};
// Ball properties
const ball = {
x: canvas.width / 2,
y: canvas.height / 2,
radius: 10,
speed: 5,
dx: 0,
dy: 0,
started: false
};
// Bricks
let bricks = [];
const brickRows = 8;
const brickCols = 10;
const brickWidth = 70;
const brickHeight = 20;
const brickPadding = 10;
const brickOffsetX = 75;
const brickOffsetY = 50;
// Colors for different levels
const levelColors = [
['#e74c3c', '#e67e22', '#f1c40f', '#2ecc71', '#3498db', '#9b59b6', '#e74c3c', '#e67e22'],
['#3498db', '#2ecc71', '#f1c40f', '#e67e22', '#e74c3c', '#9b59b6', '#3498db', '#2ecc71'],
['#9b59b6', '#3498db', '#2ecc71', '#f1c40f', '#e67e22', '#e74c3c', '#9b59b6', '#3498db'],
['#f1c40f', '#e67e22', '#e74c3c', '#9b59b6', '#3498db', '#2ecc71', '#f1c40f', '#e67e22'],
['#2ecc71', '#3498db', '#9b59b6', '#f1c40f', '#e67e22', '#e74c3c', '#2ecc71', '#3498db']
];
// Initialize the game
function init() {
// Reset game state
score = 0;
level = 1;
lives = 3;
gameState = 'playing';
particles = [];
// Reset paddle
paddle.x = canvas.width / 2 - 60;
paddle.width = 120;
paddle.speed = 8;
// Reset ball
ball.x = canvas.width / 2;
ball.y = canvas.height / 2;
ball.speed = 5;
ball.dx = 0;
ball.dy = 0;
ball.started = false;
// Create bricks
createBricks();
// Update UI
updateUI();
// Hide overlay
overlay.innerHTML = '';
overlay.style.display = 'none';
// Start game loop
requestAnimationFrame(gameLoop);
// Add event listeners
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener('mouseleave', () => {
paddle.dx = 0;
});
document.addEventListener('keydown', keyDown);
document.addEventListener('keyup', keyUp);
canvas.addEventListener('click', () => {
if (!ball.started && gameState === 'playing') {
ball.dx = 5;
ball.dy = -5;
ball.started = true;
}
});
}
// Create bricks for current level
function createBricks() {
bricks = [];
const colors = levelColors[(level - 1) % levelColors.length];
for (let r = 0; r < brickRows; r++) {
bricks[r] = [];
for (let c = 0; c < brickCols; c++) {
const brickX = c * (brickWidth + brickPadding) + brickOffsetX;
const brickY = r * (brickHeight + brickPadding) + brickOffsetY;
bricks[r][c] = {
x: brickX,
y: brickY,
width: brickWidth,
height: brickHeight,
visible: true,
color: colors[r]
};
}
}
// Make some bricks indestructible in higher levels
if (level >= 3) {
for (let i = 0; i < level; i++) {
const r = Math.floor(Math.random() * (brickRows - 2)) + 2;
const c = Math.floor(Math.random() * brickCols);
if (bricks[r][c]) {
bricks[r][c].indestructible = true;
bricks[r][c].color = '#bdc3c7';
}
}
}
}
// Draw the paddle
function drawPaddle() {
ctx.fillStyle = '#ecf0f1';
ctx.shadowColor = 'rgba(255, 255, 255, 0.5)';
ctx.shadowBlur = 15;
ctx.fillRect(paddle.x, paddle.y, paddle.width, paddle.height);
ctx.shadowBlur = 0;
// Add some gradient effect
const gradient = ctx.createLinearGradient(paddle.x, paddle.y, paddle.x, paddle.y + paddle.height);
gradient.addColorStop(0, '#ecf0f1');
gradient.addColorStop(1, '#bdc3c7');
ctx.fillStyle = gradient;
ctx.fillRect(paddle.x, paddle.y, paddle.width, paddle.height);
// Add border
ctx.strokeStyle = '#ffffff';
ctx.lineWidth = 2;
ctx.strokeRect(paddle.x, paddle.y, paddle.width, paddle.height);
}
// Draw the ball
function drawBall() {
const gradient = ctx.createRadialGradient(
ball.x - ball.radius/3, ball.y - ball.radius/3, 1,
ball.x, ball.y, ball.radius
);
gradient.addColorStop(0, '#ffffff');
gradient.addColorStop(0.5, '#3498db');
gradient.addColorStop(1, '#2980b9');
ctx.fillStyle = gradient;
ctx.shadowColor = 'rgba(52, 152, 219, 0.7)';
ctx.shadowBlur = 15;
ctx.beginPath();
ctx.arc(ball.x, ball.y, ball.radius, 0, Math.PI * 2);
ctx.fill();
ctx.shadowBlur = 0;
// Add highlight
ctx.fillStyle = '#ffffff';
ctx.beginPath();
ctx.arc(ball.x - ball.radius/4, ball.y - ball.radius/4, ball.radius/4, 0, Math.PI * 2);
ctx.fill();
}
// Draw bricks
function drawBricks() {
for (let r = 0; r < brickRows; r++) {
for (let c = 0; c < brickCols; c++) {
if (bricks[r][c].visible) {
const b = bricks[r][c];
ctx.fillStyle = b.color;
// Add glow for indestructible bricks
if (b.indestructible) {
ctx.shadowColor = b.color;
ctx.shadowBlur = 10;
}
ctx.fillRect(b.x, b.y, b.width, b.height);
ctx.strokeStyle = '#000';
ctx.lineWidth = 1;
ctx.strokeRect(b.x, b.y, b.width, b.height);
ctx.shadowBlur = 0;
// Add gradient
const gradient = ctx.createLinearGradient(b.x, b.y, b.x, b.y + b.height);
gradient.addColorStop(0, b.color);
gradient.addColorStop(1, adjustBrightness(b.color, -30));
ctx.fillStyle = gradient;
ctx.fillRect(b.x, b.y, b.width, b.height);
}
}
}
}
// Helper function to adjust brightness of a color
function adjustBrightness(hex, percent) {
const R = parseInt(hex.substring(1, 3), 16);
const G = parseInt(hex.substring(3, 5), 16);
const B = parseInt(hex.substring(5, 7), 16);
const newR = Math.min(255, Math.max(0, R + percent));
const newG = Math.min(255, Math.max(0, G + percent));
const newB = Math.min(255, Math.max(0, B + percent));
return `#${newR.toString(16).padStart(2, '0')}${newG.toString(16).padStart(2, '0')}${newB.toString(16).padStart(2, '0')}`;
}
// Draw particles
function drawParticles() {
for (let i = 0; i < particles.length; i++) {
const p = particles[i];
p.x += p.dx;
p.y += p.dy;
p.dy += 0.1; // Gravity
p.life--;
if (p.life <= 0) {
particles.splice(i, 1);
i--;
continue;
}
ctx.fillStyle = p.color;
ctx.globalAlpha = p.life / 30;
ctx.fillRect(p.x, p.y, p.size, p.size);
}
ctx.globalAlpha = 1;
}
// Create explosion particles
function createExplosion(x, y, color) {
for (let i = 0; i < 20; i++) {
particles.push({
x: x,
y: y,
dx: (Math.random() - 0.5) * 4,
dy: (Math.random() - 0.5) * 4 - 2,
life: 30,
size: Math.random() * 4 + 2,
color: color
});
}
}
// Update game objects
function update() {
if (gameState !== 'playing') return;
// Move paddle
paddle.x += paddle.dx;
// Boundary collision
if (paddle.x < 0) {
paddle.x = 0;
} else if (paddle.x + paddle.width > canvas.width) {
paddle.x = canvas.width - paddle.width;
}
// Move ball if started
if (ball.started) {
ball.x += ball.dx;
ball.y += ball.dy;
// Wall collision (left and right)
if (ball.x + ball.radius > canvas.width || ball.x - ball.radius < 0) {
ball.dx *= -1;
playSound(200, 0.1);
}
// Top collision
if (ball.y - ball.radius < 0) {
ball.dy *= -1;
playSound(200, 0.1);
}
// Bottom miss
if (ball.y + ball.radius > canvas.height) {
lives--;
updateUI();
if (lives <= 0) {
gameState = 'gameOver';
showOverlay('Game Over', 'Click to restart');
playSound(100, 0.5);
} else {
resetBall();
playSound(150, 0.2);
}
}
// Paddle collision
if (ball.y + ball.radius > paddle.y &&
ball.x > paddle.x &&
ball.x < paddle.x + paddle.width) {
ball.y = paddle.y - ball.radius;
ball.dy *= -1;
// Add angle based on where hit
const hitPos = (ball.x - paddle.x) / paddle.width - 0.5;
ball.dx = hitPos * 10;
playSound(300, 0.1);
// Screen shake effect for harder hits
if (Math.abs(hitPos) > 0.4) {
screenShake();
}
}
// Brick collision
for (let r = 0; r < brickRows; r++) {
for (let c = 0; c < brickCols; c++) {
const b = bricks[r][c];
if (b.visible && !b.indestructible) {
// Check all sides for collision
if (ball.x + ball.radius > b.x &&
ball.x - ball.radius < b.x + b.width &&
ball.y + ball.radius > b.y &&
ball.y - ball.radius < b.y + b.height) {
b.visible = false;
// Determine which side was hit
const distLeft = Math.abs(ball.x - (b.x + b.width));
const distRight = Math.abs(ball.x - b.x);
const distTop = Math.abs(ball.y - (b.y + b.height));
const distBottom = Math.abs(ball.y - b.y);
const minDist = Math.min(distLeft, distRight, distTop, distBottom);
if (minDist === distLeft || minDist === distRight) {
ball.dx *= -1;
} else {
ball.dy *= -1;
}
// Add score
score += 10;
updateUI();
// Create explosion particles
createExplosion(ball.x, ball.y, b.color);
// Play sound
playSound(440, 0.1);
// Check if level is complete
checkLevelComplete();
break;
}
}
}
}
}
}
// Check if all bricks are destroyed
function checkLevelComplete() {
for (let r = 0; r < brickRows; r++) {
for (let c = 0; c < brickCols; c++) {
if (bricks[r][c].visible && !bricks[r][c].indestructible) {
return;
}
}
}
// Level complete!
level++;
gameState = 'levelComplete';
// Show overlay with bonus points
const bonus = 100 * level;
score += bonus;
// Increase difficulty
ball.speed += 1;
if (paddle.width > 80) {
paddle.width -= 10;
}
// Update UI
updateUI();
// Show level complete message
showOverlay(`Level ${level - 1} Complete!`, `Bonus: +${bonus} points<br>Click to continue`);
playSound(880, 0.3);
}
// Reset ball position
function resetBall() {
ball.x = paddle.x + paddle.width / 2;
ball.y = paddle.y - ball.radius - 5;
ball.dx = 0;
ball.dy = 0;
ball.started = false;
}
// Update UI elements
function updateUI() {
scoreElement.textContent = score;
levelElement.textContent = level;
livesElement.textContent = lives;
}
// Show overlay message
function showOverlay(message, subMessage) {
overlay.innerHTML = `
<div class="message">
<div style="font-size: 3rem; margin-bottom: 20px;">${message}</div>
<div style="font-size: 1.5rem; color: #bdc3c7;">${subMessage.includes('Click') ? subMessage : subMessage}</div>
</div>
`;
overlay.style.display = 'flex';
}
// Screen shake effect
function screenShake() {
container.classList.add('shake');
setTimeout(() => {
container.classList.remove('shake');
}, 500);
}
// Play sound effect using Web Audio API
function playSound(frequency, duration) {
try {
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
oscillator.frequency.value = frequency;
oscillator.type = 'sine';
gainNode.gain.setValueAtTime(0.01, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.001, audioContext.currentTime + duration);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + duration);
} catch (e) {
// Audio context might not be available
}
}
// Event listeners
function mouseMove(e) {
const rect = canvas.getBoundingClientRect();
const mouseX = e.clientX - rect.left;
paddle.x = mouseX - paddle.width / 2;
// Boundary check
if (paddle.x < 0) {
paddle.x = 0;
} else if (paddle.x + paddle.width > canvas.width) {
paddle.x = canvas.width - paddle.width;
}
}
function keyDown(e) {
if (gameState !== 'playing') return;
if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A') {
paddle.dx = -paddle.speed;
} else if (e.key === 'ArrowRight' || e.key === 'd' || e.key === 'D') {
paddle.dx = paddle.speed;
} else if (e.key === ' ' && !ball.started) {
ball.dx = 5;
ball.dy = -5;
ball.started = true;
}
}
function keyUp(e) {
if (e.key === 'ArrowLeft' || e.key === 'a' || e.key === 'A' ||
e.key === 'ArrowRight' || e.key === 'd' || e.key === 'D') {
paddle.dx = 0;
}
}
// Game loop
function gameLoop() {
// Clear canvas with gradient
const gradient = ctx.createLinearGradient(0, 0, 0, canvas.height);
gradient.addColorStop(0, '#1a1a2e');
gradient.addColorStop(1, '#16213e');
ctx.fillStyle = gradient;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Update game objects
update();
// Draw everything
drawBricks();
drawPaddle();
drawBall();
drawParticles();
// Continue game loop
requestAnimationFrame(gameLoop);
}
// Handle clicks on overlay
overlay.addEventListener('click', () => {
if (gameState === 'gameOver') {
init();
} else if (gameState === 'levelComplete') {
gameState = 'playing';
createBricks();
resetBall();
overlay.style.display = 'none';
}
});
// Also handle keyboard for overlay
document.addEventListener('keydown', (e) => {
if (gameState === 'gameOver' || gameState === 'levelComplete') {
if (e.key === ' ' || e.key === 'Enter') {
overlay.click();
}
}
});
// Start the game
init();
</script>
</body>
</html>

