• Updated 19 Nov, 14:26 UTC
  • Next run 20 Nov, 05:17 UTCNext 20 Nov 05:17
  • Last 7 days: 9 new models · 69 runs7 d: 9 models · 69 runs
Playable Breakout

Motif 3Motif Technologies

Network offOpen alone (new tab)

Run details

Model
motif-technologies/motif-3
Route
OpenRouter API, one user message
Served by
KT
Effort
the model's default
Limits
60 min · 235,929 output tokens (the model's limit)
Date
17 Nov 2026
Time
52 s
Size
16 kB
Tokens
72 in, 6,382 out (1,772 of them thinking)
List price
$0.008 at today's price ($0.30 in / $1.20 out per M)
Paid
$0.008

Raw files: output · meta.json

Exact 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

16 kB 504 lines Raw

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Breakout</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            background: #222;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            overflow: hidden;
            font-family: Arial, sans-serif;
            color: #fff;
        }
        #score {
            position: absolute;
            top: 20px;
            font-size: 24px;
            font-weight: bold;
            pointer-events: none;
        }
        canvas {
            background: #1a1a1a;
            border: 2px solid #555;
            display: block;
        }
        #overlay {
            position: absolute;
            top: 0; left: 0; width: 100%; height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: rgba(0,0,0,0.8);
            z-index: 10;
        }
        #overlay h1 { font-size: 48px; margin-bottom: 10px; }
        #overlay p { font-size: 24px; }
    </style>
</head>
<body>
    <div id="score">Score: 0</div>
    <canvas id="game" width="800" height="600"></canvas>
    <div id="overlay">
        <h1 id="title">Breakout</h1>
        <p id="message">Press SPACE or Click to Start</p>
    </div>

    <script>
        const canvas = document.getElementById('game');
        const ctx = canvas.getContext('2d');
        const scoreEl = document.getElementById('score');
        const overlay = document.getElementById('overlay');
        const titleEl = document.getElementById('title');
        const messageEl = document.getElementById('message');

        const W = canvas.width;
        const H = canvas.height;

        // Game constants
        const PADDLE_W = 100;
        const PADDLE_H = 16;
        const PADDLE_Y = H - 40;
        const BALL_R = 8;
        const BRICK_W = 75;
        const BRICK_H = 20;
        const BRICK_GAP = 2;
        const BRICK_OFFSET_TOP = 50;
        const BRICK_OFFSET_LEFT = (W - (BRICK_W * 7 + BRICK_GAP * 6)) / 2; // adjust for 7 cols

        // Levels: each level has a grid of bricks (true = present)
        const levels = [
            // Level 1: 5 rows, 7 cols
            { grid: Array(5).fill(null).map(() => Array(7).fill(true)), speed: 1.0 },
            // Level 2: 6 rows, 8 cols, with some missing
            { grid: [
                [true, true, true, true, true, true, true, true],
                [true, true, false, true, true, false, true, true],
                [true, true, true, true, true, true, true, true],
                [true, false, true, false, true, false, true, false],
                [true, true, true, true, true, true, true, true],
                [true, true, false, true, true, false, true, true]
            ], speed: 1.2 },
            // Level 3: 7 rows, 8 cols, denser
            { grid: [
                [true, true, true, true, true, true, true, true],
                [true, true, true, false, false, true, true, true],
                [true, true, false, false, false, false, true, true],
                [true, false, false, false, false, false, false, true],
                [true, true, false, false, false, false, true, true],
                [true, true, true, false, false, true, true, true],
                [true, true, true, true, true, true, true, true]
            ], speed: 1.5 }
        ];

        // Brick colors per row (from top)
        const brickColors = ['#e74c3c', '#e67e22', '#f1c40f', '#2ecc71', '#3498db', '#9b59b6', '#34495e'];

        // Game state
        let state = 'menu'; // menu, play, gameover
        let score = 0;
        let lives = 3;
        let level = 0;
        let paddleX = 0;
        let ballX = 0, ballY = 0;
        let ballVX = 0, ballVY = 0;
        let bricks = [];
        let particles = [];
        let shake = 0;
        let trail = [];
        let lastTime = 0;

        // Audio context
        let audioCtx = null;
        function ensureAudio() {
            if (!audioCtx) {
                audioCtx = new (window.AudioContext || window.webkitAudioContext)();
            }
            if (audioCtx.state === 'suspended') {
                audioCtx.resume();
            }
        }

        function playSound(freq, dur, type = 'square', vol = 0.1) {
            if (!audioCtx) return;
            const osc = audioCtx.createOscillator();
            const gain = audioCtx.createGain();
            osc.type = type;
            osc.frequency.value = freq;
            gain.gain.value = vol;
            osc.connect(gain);
            gain.connect(audioCtx.destination);
            osc.start();
            setTimeout(() => {
                osc.stop();
            }, dur * 1000);
        }

        function bounceSound() {
            playSound(440, 0.1, 'square', 0.05);
        }

        function brickSound() {
            playSound(600, 0.15, 'square', 0.1);
        }

        function levelCompleteSound() {
            playSound(523, 0.15, 'square', 0.1);
            playSound(659, 0.15, 'square', 0.1);
            playSound(784, 0.2, 'square', 0.1);
        }

        function gameOverSound() {
            playSound(200, 0.3, 'sawtooth', 0.2);
            setTimeout(() => playSound(150, 0.3, 'sawtooth', 0.2), 200);
        }

        // Initialize bricks for current level
        function initLevel() {
            bricks = [];
            const grid = levels[level].grid;
            for (let r = 0; r < grid.length; r++) {
                for (let c = 0; c < grid[r].length; c++) {
                    if (grid[r][c]) {
                        const x = BRICK_OFFSET_LEFT + c * (BRICK_W + BRICK_GAP);
                        const y = BRICK_OFFSET_TOP + r * (BRICK_H + BRICK_GAP);
                        const color = brickColors[r % brickColors.length];
                        bricks.push({ x, y, w: BRICK_W, h: BRICK_H, color, hit: false });
                    }
                }
            }
        }

        function resetBall() {
            ballX = W / 2;
            ballY = PADDLE_Y - 20;
            ballVX = (Math.random() > 0.5 ? 1 : -1) * 5 * levels[level].speed;
            ballVY = -5 * levels[level].speed;
            trail = [];
        }

        function resetPaddle() {
            paddleX = (W - PADDLE_W) / 2;
        }

        function startGame() {
            score = 0;
            lives = 3;
            level = 0;
            state = 'play';
            initLevel();
            resetPaddle();
            resetBall();
            overlay.style.display = 'none';
        }

        function checkLevelComplete() {
            return bricks.every(b => b.hit);
        }

        function nextLevel() {
            level++;
            if (level >= levels.length) {
                // Victory? Or loop? For simplicity, restart from level 0
                level = 0;
                alert("You win! Starting again.");
            }
            initLevel();
            resetPaddle();
            resetBall();
            levelCompleteSound();
        }

        function addParticles(x, y, color, count = 8) {
            for (let i = 0; i < count; i++) {
                const angle = Math.random() * Math.PI * 2;
                const speed = 2 + Math.random() * 4;
                particles.push({
                    x, y,
                    vx: Math.cos(angle) * speed,
                    vy: Math.sin(angle) * speed,
                    color,
                    life: 1,
                    maxLife: 1
                });
            }
        }

        function update() {
            // Input
            let dx = 0;
            if (keys['ArrowLeft']) dx -= 1;
            if (keys['ArrowRight']) dx += 1;
            paddleX += dx * 8;
            paddleX = Math.max(0, Math.min(W - PADDLE_W, paddleX));

            if (mouseActive) {
                paddleX = mouseX - PADDLE_W / 2;
                paddleX = Math.max(0, Math.min(W - PADDLE_W, paddleX));
            }

            // Ball movement
            ballX += ballVX;
            ballY += ballVY;

            // Wall collisions
            if (ballX - BALL_R < 0 || ballX + BALL_R > W) {
                ballVX = -ballVX;
                ballX = Math.max(BALL_R, Math.min(W - BALL_R, ballX));
                shake = 5;
                bounceSound();
            }
            if (ballY - BALL_R < 0) {
                ballVY = -ballVY;
                ballY = BALL_R;
                shake = 5;
                bounceSound();
            }

            // Paddle collision
            if (ballY + BALL_R >= PADDLE_Y && ballY <= PADDLE_Y + PADDLE_H &&
                ballX >= paddleX && ballX <= paddleX + PADDLE_W) {
                // Calculate hit point (-1 to 1)
                const hitPos = (ballX - (paddleX + PADDLE_W/2)) / (PADDLE_W/2);
                ballVX = hitPos * 6 * levels[level].speed;
                ballVY = -Math.abs(ballVY) * 1.05; // speed up slightly
                ballY = PADDLE_Y - BALL_R;
                shake = 5;
                bounceSound();
            }

            // Bottom - lose life
            if (ballY - BALL_R > H) {
                lives--;
                shake = 10;
                gameOverSound(); // short, not full game over sound
                if (lives <= 0) {
                    state = 'gameover';
                    overlay.style.display = 'flex';
                    titleEl.innerText = 'Game Over';
                    messageEl.innerText = `Final Score: ${score} | Press SPACE to Restart`;
                    gameOverSound();
                } else {
                    resetPaddle();
                    resetBall();
                }
            }

            // Brick collisions
            for (let b of bricks) {
                if (b.hit) continue;
                if (ballX + BALL_R > b.x && ballX - BALL_R < b.x + b.w &&
                    ballY + BALL_R > b.y && ballY - BALL_R < b.y + b.h) {
                    b.hit = true;
                    ballVY = -ballVY;
                    ballY = b.y - BALL_R; // adjust
                    score += 10 * (level + 1);
                    scoreEl.innerText = `Score: ${score}`;
                    shake = 8;
                    brickSound();
                    addParticles(b.x + b.w/2, b.y + b.h/2, b.color, 10);
                    if (checkLevelComplete()) {
                        nextLevel();
                    }
                    break; // only one brick per frame
                }
            }

            // Update particles
            for (let i = particles.length - 1; i >= 0; i--) {
                const p = particles[i];
                p.x += p.vx;
                p.y += p.vy;
                p.vy += 0.2; // gravity
                p.life -= 0.02;
                if (p.life <= 0) {
                    particles.splice(i, 1);
                }
            }

            // Update shake
            if (shake > 0) {
                shake *= 0.9;
                if (shake < 0.5) shake = 0;
            }

            // Trail
            trail.unshift({x: ballX, y: ballY});
            if (trail.length > 10) trail.pop();
        }

        function draw() {
            ctx.save();
            if (shake > 0) {
                const sx = (Math.random() - 0.5) * shake * 2;
                const sy = (Math.random() - 0.5) * shake * 2;
                ctx.translate(sx, sy);
            }

            // Clear
            ctx.fillStyle = '#1a1a1a';
            ctx.fillRect(0, 0, W, H);

            // Paddle
            const paddleGradient = ctx.createLinearGradient(paddleX, PADDLE_Y, paddleX + PADDLE_W, PADDLE_Y);
            paddleGradient.addColorStop(0, '#3498db');
            paddleGradient.addColorStop(1, '#2ecc71');
            ctx.fillStyle = paddleGradient;
            ctx.beginPath();
            ctx.roundRect(paddleX, PADDLE_Y, PADDLE_W, PADDLE_H, 8);
            ctx.fill();
            ctx.strokeStyle = '#fff';
            ctx.lineWidth = 2;
            ctx.stroke();

            // Ball with trail
            for (let i = 0; i < trail.length; i++) {
                const t = trail[i];
                const alpha = (1 - i / trail.length) * 0.5;
                ctx.fillStyle = `rgba(255, 255, 255, ${alpha})`;
                ctx.beginPath();
                ctx.arc(t.x, t.y, BALL_R * (1 - i / trail.length * 0.5), 0, Math.PI * 2);
                ctx.fill();
            }
            ctx.fillStyle = '#fff';
            ctx.beginPath();
            ctx.arc(ballX, ballY, BALL_R, 0, Math.PI * 2);
            ctx.fill();
            ctx.strokeStyle = '#fff';
            ctx.lineWidth = 2;
            ctx.stroke();

            // Bricks
            for (let b of bricks) {
                if (b.hit) continue;
                ctx.fillStyle = b.color;
                ctx.fillRect(b.x, b.y, b.w, b.h);
                ctx.strokeStyle = '#fff';
                ctx.lineWidth = 1;
                ctx.strokeRect(b.x, b.y, b.w, b.h);
            }

            // Particles
            for (let p of particles) {
                ctx.fillStyle = p.color;
                ctx.globalAlpha = p.life;
                ctx.beginPath();
                ctx.arc(p.x, p.y, 4, 0, Math.PI * 2);
                ctx.fill();
            }
            ctx.globalAlpha = 1;

            // UI overlay (score, lives) - drawn without shake
            ctx.restore();
            ctx.save();
            ctx.fillStyle = '#fff';
            ctx.font = '20px Arial';
            ctx.fillText(`Score: ${score}`, 20, 30);
            ctx.fillText(`Lives: ${lives}`, W - 100, 30);
            ctx.fillText(`Level: ${level + 1}`, W/2 - 50, 30);
            ctx.restore();
        }

        // Input handling
        const keys = {};
        let mouseActive = false;
        let mouseX = 0;

        document.addEventListener('keydown', (e) => {
            keys[e.code] = true;
            ensureAudio();
            if (e.code === 'Space') {
                if (state === 'menu') {
                    startGame();
                } else if (state === 'gameover') {
                    startGame();
                }
            }
            if (e.code === 'Enter' && state === 'menu') {
                startGame();
            }
        });

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

        canvas.addEventListener('mousemove', (e) => {
            mouseActive = true;
            mouseX = e.clientX - canvas.getBoundingClientRect().left;
        });

        canvas.addEventListener('mousedown', (e) => {
            ensureAudio();
            if (state === 'menu' || state === 'gameover') {
                startGame();
            }
        });

        // Game loop
        function loop(timestamp) {
            if (state === 'play') {
                update();
                draw();
            } else {
                draw();
            }
            requestAnimationFrame(loop);
        }

        // Initial draw for menu
        function drawMenu() {
            ctx.fillStyle = '#1a1a1a';
            ctx.fillRect(0, 0, W, H);
            // Draw some bricks? No, just background
            ctx.fillStyle = '#fff';
            ctx.font = '40px Arial';
            ctx.fillText('Breakout', W/2 - 80, H/2 - 40);
            ctx.font = '24px Arial';
            ctx.fillText('Press SPACE or Click to Start', W/2 - 150, H/2 + 20);
        }

        function drawGameOver() {
            ctx.fillStyle = '#1a1a1a';
            ctx.fillRect(0, 0, W, H);
            ctx.fillStyle = '#fff';
            ctx.font = '40px Arial';
            ctx.fillText('Game Over', W/2 - 100, H/2 - 40);
            ctx.font = '24px Arial';
            ctx.fillText(`Final Score: ${score}`, W/2 - 100, H/2 + 20);
            ctx.fillText('Press SPACE to Restart', W/2 - 150, H/2 + 60);
        }

        // Override draw for states
        const originalDraw = draw;
        function drawState() {
            if (state === 'menu') drawMenu();
            else if (state === 'gameover') drawGameOver();
            else originalDraw();
        }

        // Override loop to use state-specific draw
        function loopState(timestamp) {
            if (state === 'play') {
                update();
                drawState();
            } else {
                drawState();
            }
            requestAnimationFrame(loopState);
        }

        // Initialize
        resetPaddle();
        resetBall();
        requestAnimationFrame(loopState);
    </script>
</body>
</html>

Compare with

Motif 3: other attempts