• Updated 3 Dec, 05:00 UTC
  • Next run 4 Dec, 05:17 UTCNext 4 Dec 05:17
  • Last 7 days: 4 new models · 73 runs7 d: 4 models · 73 runs
Playable Breakout

Flint 1.1Recursive

Network offOpen alone (new tab)

Run details

Model
recursive/flint-v1.1:free
Route
OpenRouter API
Served by
Recursive
Effort
model default
Limits
60 min · 235,929 output tokens (model max)
Date
2 Dec 2026
Time
3 min 4 s
Size
11 kB
Tokens
79 in, 20,884 out (15,840 thinking)
List price
free at today's price (free route)
Paid
$0 (free route)

Raw: output · meta.json

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

11 kB 468 lines Raw

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Breakout</title>
<style>
  body { margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #0b0e14; color: #e0e0e0; font-family: system-ui, sans-serif; }
  #game { text-align: center; }
  h1 { margin: 0 0 10px; font-size: 28px; letter-spacing: 2px; }
  #hud { margin-bottom: 10px; font-size: 16px; }
  canvas { display: block; margin: 0 auto; background: #111; border: 2px solid #333; border-radius: 8px; box-shadow: 0 0 30px rgba(0,0,0,0.8); }
  p { margin-top: 10px; font-size: 14px; color: #aaa; }
</style>
</head>
<body>
<div id="game">
  <h1>Breakout</h1>
  <div id="hud">Score: <span id="score">0</span> | Lives: <span id="lives">3</span> | Level: <span id="level">1</span></div>
  <canvas id="gameCanvas" width="800" height="600"></canvas>
  <p>Move mouse or use ←/→ / A/D. Press Space to launch.</p>
</div>
<script>
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const scoreEl = document.getElementById('score');
const livesEl = document.getElementById('lives');
const levelEl = document.getElementById('level');

const W = canvas.width;
const H = canvas.height;
const PADDLE_W = 110;
const PADDLE_H = 16;
const BALL_R = 12;
const BRICK_W = 70;
const BRICK_H = 24;
const MAX_SPEED = 12;

let paddle = { x: W / 2, y: H - 70, w: PADDLE_W, h: PADDLE_H, speed: 8 };
let ball = { x: W / 2, y: H - 100, vx: 0, vy: 0, r: BALL_R };
let keys = {};
let mouseX = null;
let state = 'ready'; // ready, playing, gameover
let score = 0;
let lives = 3;
let levelIndex = 0;
let bricks = [];
let particles = [];
let shake = 0;
let audioCtx = null;

const LEVELS = [
  [
    "111111",
    "111111",
    "111111",
    "111111",
    "111111"
  ],
  [
    "112211",
    "112211",
    "222111",
    "221111",
    "111222"
  ],
  [
    "1.1.1",
    "1.1.1",
    "1.1.1",
    "1.1.1",
    "1.1.1"
  ],
  [
    "2222",
    "2222",
    "1111",
    "1111",
    "1111"
  ],
  [
    "1122",
    "1122",
    "2211",
    "2211",
    "1111"
  ]
];

function clamp(v, min, max) {
  return Math.max(min, Math.min(max, v));
}

function updateScore() {
  scoreEl.textContent = score;
}

function updateLives() {
  livesEl.textContent = lives;
}

function updateLevel() {
  levelEl.textContent = levelIndex + 1;
}

function initAudio() {
  if (!audioCtx) {
    const AudioContext = window.AudioContext || window.webkitAudioContext;
    if (AudioContext) audioCtx = new AudioContext();
  }
}

function tone(freq, dur, type, vol) {
  if (!audioCtx) return;
  const osc = audioCtx.createOscillator();
  const gain = audioCtx.createGain();
  osc.type = type;
  osc.frequency.value = freq;
  gain.gain.setValueAtTime(vol, audioCtx.currentTime);
  gain.gain.exponentialRampToValueAtTime(0.001, audioCtx.currentTime + dur);
  osc.connect(gain);
  gain.connect(audioCtx.destination);
  osc.start();
  osc.stop(audioCtx.currentTime + dur);
}

function playSound(name) {
  if (!audioCtx) return;
  switch (name) {
    case 'paddle': tone(300, 0.08, 'square', 0.15); break;
    case 'wall': tone(200, 0.05, 'sawtooth', 0.1); break;
    case 'launch': tone(600, 0.1, 'sine', 0.2); break;
    case 'break': tone(900, 0.2, 'sine', 0.3); break;
  }
}

function loadLevel() {
  bricks = [];
  const rows = LEVELS[levelIndex] || [];
  for (let r = 0; r < rows.length; r++) {
    const row = rows[r];
    for (let c = 0; c < row.length; c++) {
      const ch = row[c];
      if (ch === '.') continue;
      const x = c * BRICK_W;
      const y = r * BRICK_H;
      if (ch === '1') {
        bricks.push({ x, y, w: BRICK_W, h: BRICK_H, hp: 1, points: 10, type: 'normal', color: '#ff6b6b' });
      } else if (ch === '2') {
        bricks.push({ x, y, w: BRICK_W, h: BRICK_H, hp: 2, points: 20, type: 'strong', color: '#4ecdc4' });
      }
    }
  }
  updateLevel();
}

function resetBallToPaddle() {
  ball.x = paddle.x;
  ball.y = paddle.y - ball.r - 1;
  ball.vx = 0;
  ball.vy = 0;
}

function launchBall() {
  if (state !== 'ready') return;
  state = 'playing';
  ball.vx = (Math.random() > 0.5 ? -1 : 1) * 5;
  ball.vy = -6;
  playSound('launch');
}

function spawnParticles(x, y, colors, count) {
  for (let i = 0; i < count; i++) {
    const angle = Math.random() * Math.PI * 2;
    const speed = 2 + Math.random() * 5;
    const life = 15 + Math.random() * 20;
    particles.push({
      x, y,
      vx: Math.cos(angle) * speed,
      vy: Math.sin(angle) * speed - 2,
      life,
      maxLife: life,
      size: 2 + Math.random() * 3,
      color: colors[Math.floor(Math.random() * colors.length)]
    });
  }
}

function updateParticles() {
  for (let i = particles.length - 1; i >= 0; i--) {
    const p = particles[i];
    p.x += p.vx;
    p.y += p.vy;
    p.vy += 0.1;
    p.life--;
    if (p.life <= 0) particles.splice(i, 1);
  }
}

function increaseBallSpeed() {
  const speed = Math.hypot(ball.vx, ball.vy);
  if (speed === 0) return;
  const newSpeed = Math.min(speed * 1.05, MAX_SPEED);
  if (newSpeed <= speed) return;
  ball.vx = ball.vx / speed * newSpeed;
  ball.vy = ball.vy / speed * newSpeed;
}

function collide(ball, brick) {
  const ballLeft = ball.x - ball.r;
  const ballRight = ball.x + ball.r;
  const ballTop = ball.y - ball.r;
  const ballBottom = ball.y + ball.r;
  const brickLeft = brick.x;
  const brickRight = brick.x + brick.w;
  const brickTop = brick.y;
  const brickBottom = brick.y + brick.h;

  if (ballRight > brickLeft && ballLeft < brickRight && ballBottom > brickTop && ballTop < brickBottom) {
    const overlapLeft = ballRight - brickLeft;
    const overlapRight = brickRight - ballLeft;
    const overlapTop = ballBottom - brickTop;
    const overlapBottom = brickBottom - ballTop;
    const minOverlapX = Math.min(overlapLeft, overlapRight);
    const minOverlapY = Math.min(overlapTop, overlapBottom);

    if (minOverlapX < minOverlapY) {
      if (ball.vx > 0) ball.x = brickLeft - ball.r - 0.01;
      else ball.x = brickRight + ball.r + 0.01;
      ball.vx = -ball.vx;
    } else {
      if (ball.vy > 0) ball.y = brickTop - ball.r - 0.01;
      else ball.y = brickBottom + ball.r + 0.01;
      ball.vy = -ball.vy;
    }
    return true;
  }
  return false;
}

function destroyBrick(index) {
  const brick = bricks[index];
  bricks.splice(index, 1);
  score += brick.points;
  updateScore();
  spawnParticles(brick.x + brick.w / 2, brick.y + brick.h / 2, [brick.color], 12);
  shake = Math.max(shake, 8);
  playSound('break');
}

function updateBall() {
  ball.x += ball.vx;
  ball.y += ball.vy;

  if (ball.y - ball.r < 0) {
    ball.y = ball.r;
    ball.vy = -ball.vy;
    playSound('wall');
  }
  if (ball.x - ball.r < 0) {
    ball.x = ball.r;
    ball.vx = -ball.vx;
    playSound('wall');
  }
  if (ball.x + ball.r > W) {
    ball.x = W - ball.r;
    ball.vx = -ball.vx;
    playSound('wall');
  }

  if (ball.y + ball.r > paddle.y && ball.y - ball.r < paddle.y + paddle.h && ball.x + ball.r > paddle.x && ball.x - ball.r < paddle.x + paddle.w) {
    if (ball.vy > 0) ball.vy = -ball.vy;
    increaseBallSpeed();
    ball.y = paddle.y - ball.r - 1;
    playSound('paddle');
  }

  for (let i = bricks.length - 1; i >= 0; i--) {
    const brick = bricks[i];
    if (brick.hp > 0 && collide(ball, brick)) {
      if (brick.hp > 1) {
        brick.hp--;
        spawnParticles(brick.x + brick.w / 2, brick.y + brick.h / 2, [brick.color], 6);
      } else {
        destroyBrick(i);
      }
      break;
    }
  }

  if (bricks.length === 0) {
    levelIndex++;
    if (levelIndex >= LEVELS.length) levelIndex = 0;
    loadLevel();
    state = 'ready';
    return;
  }

  if (ball.y - ball.r > H) {
    lives--;
    updateLives();
    if (lives <= 0) {
      state = 'gameover';
      return;
    }
    resetBallToPaddle();
    state = 'ready';
    return;
  }
}

function handleInput() {
  if (keys['ArrowLeft'] || keys['KeyA']) paddle.x -= paddle.speed;
  if (keys['ArrowRight'] || keys['KeyD']) paddle.x += paddle.speed;

  if (!(keys['ArrowLeft'] || keys['KeyA'] || keys['ArrowRight'] || keys['KeyD'])) {
    if (mouseX != null) {
      paddle.x = mouseX - paddle.w / 2;
    }
  }

  paddle.x = clamp(paddle.x, paddle.w / 2, W - paddle.w / 2);
}

function update() {
  handleInput();
  updateParticles();

  if (shake > 0) shake--;

  if (state === 'ready') {
    ball.x = paddle.x;
    ball.y = paddle.y - ball.r - 1;
    ball.vx = 0;
    ball.vy = 0;
    return;
  }

  if (state === 'playing') {
    updateBall();
  }
}

function draw() {
  ctx.save();

  if (shake > 0) {
    ctx.translate((Math.random() - 0.5) * shake, (Math.random() - 0.5) * shake);
  }

  ctx.fillStyle = '#111';
  ctx.fillRect(-10, -10, W + 20, H + 20);

  for (const brick of bricks) {
    if (brick.hp <= 0) continue;
    ctx.fillStyle = brick.color;
    ctx.fillRect(brick.x, brick.y, brick.w, brick.h);
    ctx.strokeStyle = 'rgba(255,255,255,0.4)';
    ctx.strokeRect(brick.x, brick.y, brick.w, brick.h);
    if (brick.type === 'strong') {
      ctx.fillStyle = 'rgba(255,255,255,0.3)';
      ctx.fillRect(brick.x, brick.y, brick.w, brick.h / 2);
    }
  }

  ctx.save();
  ctx.shadowColor = '#4ecdc4';
  ctx.shadowBlur = 12;
  ctx.fillStyle = '#4ecdc4';
  ctx.fillRect(paddle.x, paddle.y, paddle.w, paddle.h);
  ctx.restore();

  ctx.save();
  ctx.shadowColor = '#ffffff';
  ctx.shadowBlur = 15;
  ctx.beginPath();
  ctx.arc(ball.x, ball.y, ball.r, 0, Math.PI * 2);
  ctx.fillStyle = '#ffffff';
  ctx.fill();
  ctx.restore();

  for (const p of particles) {
    ctx.globalAlpha = Math.max(0, p.life / p.maxLife);
    ctx.fillStyle = p.color;
    ctx.fillRect(p.x - p.size / 2, p.y - p.size / 2, p.size, p.size);
  }

  ctx.restore();
}

function gameLoop() {
  update();
  draw();
  requestAnimationFrame(gameLoop);
}

window.addEventListener('keydown', (e) => {
  if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys[e.code] = true;
  if (e.code === 'ArrowRight' || e.code === 'KeyD') keys[e.code] = true;

  if (e.code === 'Space') {
    e.preventDefault();
    initAudio();
    if (state === 'ready') launchBall();
    else if (state === 'gameover') {
      score = 0;
      lives = 3;
      levelIndex = 0;
      loadLevel();
      state = 'ready';
      resetBallToPaddle();
      updateScore();
      updateLives();
      updateLevel();
    }
  }

  if (e.code === 'Enter' && state === 'gameover') {
    score = 0;
    lives = 3;
    levelIndex = 0;
    loadLevel();
    state = 'ready';
    resetBallToPaddle();
    updateScore();
    updateLives();
    updateLevel();
  }
});

window.addEventListener('keyup', (e) => {
  keys[e.code] = false;
});

window.addEventListener('mousemove', (e) => {
  const rect = canvas.getBoundingClientRect();
  const x = e.clientX - rect.left;
  if (x >= 0 && x <= W) {
    mouseX = x;
    paddle.x = x - paddle.w / 2;
    paddle.x = clamp(paddle.x, paddle.w / 2, W - paddle.w / 2);
  }
});

canvas.addEventListener('mousedown', (e) => {
  initAudio();
  if (state === 'ready') launchBall();
  else if (state === 'gameover') {
    score = 0;
    lives = 3;
    levelIndex = 0;
    loadLevel();
    state = 'ready';
    resetBallToPaddle();
    updateScore();
    updateLives();
    updateLevel();
  }
});

loadLevel();
resetBallToPaddle();
updateScore();
updateLives();
updateLevel();
gameLoop();
</script>
</body>
</html>

Compare

Other runs