Run details
- Model
- tencent/hy4-flash
- Route
- OpenRouter API, one user message
- Served by
- Tencent
- Effort
- the model's default
- Limits
- 60 min · 65,536 output tokens (the model's limit)
- Date
- 17 Nov 2026
- Time
- 65 s
- Size
- 16 kB
- Tokens
- 97 in, 17,712 out (12,048 of them thinking)
- List price
- $0.002 at today's price ($0.035 in / $0.141 out per M)
- Paid
- $0.002
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 570 lines Raw
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Neon Breakout</title>
<style>
:root {
--neon-cyan: #00ffff;
--neon-pink: #ff00ff;
--bg-color: #050510;
}
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background-color: var(--bg-color);
overflow: hidden;
font-family: 'Courier New', Courier, monospace;
color: white;
user-select: none;
-webkit-user-select: none;
}
/* Retro CRT Scanlines */
body::after {
content: "";
position: absolute;
top: 0; left: 0; width: 100vw; height: 100vh;
background: repeating-linear-gradient(0deg, rgba(0,0,0,0.15), rgba(0,0,0,0.15) 1px, transparent 1px, transparent 2px);
pointer-events: none;
z-index: 10;
}
canvas {
display: block;
width: 100%;
height: 100%;
}
#ui {
position: absolute;
top: 0; left: 0; width: 100%; height: 100%;
pointer-events: none;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 5;
}
#hud {
position: absolute;
top: 20px; left: 30px; right: 30px;
display: flex;
justify-content: space-between;
font-size: 24px;
font-weight: bold;
text-shadow: 0 0 10px var(--neon-cyan);
color: #fff;
z-index: 5;
}
.screen {
text-align: center;
background: rgba(5, 5, 16, 0.8);
padding: 40px;
border: 2px solid var(--neon-cyan);
box-shadow: 0 0 20px var(--neon-cyan), inset 0 0 20px var(--neon-cyan);
border-radius: 10px;
}
h1 {
font-size: 56px;
margin: 0 0 20px 0;
text-shadow: 0 0 15px var(--neon-pink), 0 0 30px var(--neon-pink);
color: #fff;
letter-spacing: 4px;
}
p {
font-size: 20px;
margin: 10px 0;
text-shadow: 0 0 10px var(--neon-cyan);
color: #ddd;
}
.blink {
animation: blinker 1s linear infinite;
color: #fff;
font-weight: bold;
}
@keyframes blinker {
50% { opacity: 0; }
}
.hidden { display: none !important; }
</style>
</head>
<body>
<div id="hud">
<div id="scoreDisplay">SCORE: 0</div>
<div id="levelDisplay">LEVEL: 1</div>
<div id="livesDisplay">LIVES: 3</div>
</div>
<div id="ui">
<div id="startScreen" class="screen">
<h1>NEON BREAKOUT</h1>
<p>Use Mouse, Touch, or Arrows (A/D) to move</p>
<p>Click or Press SPACE to launch ball</p>
<p class="blink" style="margin-top: 30px; color: var(--neon-cyan);">CLICK OR PRESS SPACE TO START</p>
</div>
<div id="gameOverScreen" class="screen hidden">
<h1 style="text-shadow: 0 0 15px #ff0000, 0 0 30px #ff0000; border-color: #ff0000;">GAME OVER</h1>
<p>Final Score: <span id="finalScore" style="color: var(--neon-cyan); font-weight: bold;"></span></p>
<p class="blink" style="margin-top: 30px; color: var(--neon-cyan);">CLICK OR PRESS SPACE TO RESTART</p>
</div>
<div id="levelClearScreen" class="screen hidden">
<h1 style="text-shadow: 0 0 15px #00ff00, 0 0 30px #00ff00;">LEVEL CLEAR</h1>
<p class="blink" style="margin-top: 30px; color: var(--neon-cyan);">CLICK OR PRESS SPACE TO CONTINUE</p>
</div>
</div>
<canvas id="gameCanvas"></canvas>
<script>
// --- Setup & Resolution ---
const canvas = document.getElementById('gameCanvas');
const ctx = canvas.getContext('2d');
const LOGICAL_W = 800;
const LOGICAL_H = 600;
let scale = 1, offsetX = 0, offsetY = 0;
function resize() {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
scale = Math.min(canvas.width / LOGICAL_W, canvas.height / LOGICAL_H);
offsetX = (canvas.width - LOGICAL_W * scale) / 2;
offsetY = (canvas.height - LOGICAL_H * scale) / 2;
}
window.addEventListener('resize', resize);
resize();
// --- Audio System ---
let audioCtx;
function initAudio() {
if (!audioCtx) audioCtx = new (window.AudioContext || window.webkitAudioContext)();
if (audioCtx.state === 'suspended') audioCtx.resume();
}
function playTone(freq, type, duration, vol=0.1) {
if (!audioCtx) return;
const osc = audioCtx.createOscillator();
const gain = audioCtx.createGain();
osc.type = type;
osc.frequency.setValueAtTime(freq, audioCtx.currentTime);
gain.gain.setValueAtTime(vol, audioCtx.currentTime);
gain.gain.exponentialRampToValueAtTime(0.01, audioCtx.currentTime + duration);
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime + duration);
return osc;
}
function playSound(type) {
if (!audioCtx) return;
if (type === 'paddle') {
let osc = playTone(400, 'square', 0.1);
osc.frequency.exponentialRampToValueAtTime(200, audioCtx.currentTime + 0.1);
} else if (type === 'brick') {
let osc = playTone(800, 'sine', 0.1);
osc.frequency.exponentialRampToValueAtTime(400, audioCtx.currentTime + 0.1);
} else if (type === 'wall') {
playTone(200, 'triangle', 0.05, 0.05);
} else if (type === 'lose') {
let osc = playTone(200, 'sawtooth', 0.5, 0.2);
osc.frequency.exponentialRampToValueAtTime(50, audioCtx.currentTime + 0.5);
} else if (type === 'win') {
playTone(400, 'sine', 0.1);
setTimeout(() => playTone(600, 'sine', 0.1), 100);
setTimeout(() => playTone(800, 'sine', 0.2), 200);
}
}
// --- Game State ---
const STATE = { START: 0, PLAYING: 1, GAMEOVER: 2, LEVELCLEAR: 3 };
let currentState = STATE.START;
let score = 0, lives = 3, level = 1;
let bricks = [], particles = [], floatingTexts = [];
let shake = 0;
// UI Elements
const scoreDisplay = document.getElementById('scoreDisplay');
const levelDisplay = document.getElementById('levelDisplay');
const livesDisplay = document.getElementById('livesDisplay');
const startScreen = document.getElementById('startScreen');
const gameOverScreen = document.getElementById('gameOverScreen');
const levelClearScreen = document.getElementById('levelClearScreen');
const finalScore = document.getElementById('finalScore');
function updateHUD() {
scoreDisplay.innerText = `SCORE: ${score}`;
levelDisplay.innerText = `LEVEL: ${level}`;
livesDisplay.innerText = `LIVES: ${lives}`;
}
// --- Input ---
let keys = { left: false, right: false };
let mouseX = null;
let usingMouse = false;
function getLogicalX(clientX) { return (clientX - offsetX) / scale; }
window.addEventListener('keydown', e => {
if (e.code === 'ArrowLeft' || e.code === 'KeyA') { keys.left = true; usingMouse = false; }
if (e.code === 'ArrowRight' || e.code === 'KeyD') { keys.right = true; usingMouse = false; }
if (e.code === 'Space') handleAction();
});
window.addEventListener('keyup', e => {
if (e.code === 'ArrowLeft' || e.code === 'KeyA') keys.left = false;
if (e.code === 'ArrowRight' || e.code === 'KeyD') keys.right = false;
});
window.addEventListener('mousemove', e => {
mouseX = getLogicalX(e.clientX);
usingMouse = true;
});
window.addEventListener('mousedown', () => handleAction());
window.addEventListener('touchstart', e => {
mouseX = getLogicalX(e.touches[0].clientX);
usingMouse = true;
handleAction();
}, { passive: false });
window.addEventListener('touchmove', e => {
mouseX = getLogicalX(e.touches[0].clientX);
usingMouse = true;
}, { passive: false });
function handleAction() {
initAudio();
if (currentState === STATE.START) {
startGame();
} else if (currentState === STATE.GAMEOVER) {
score = 0; lives = 3; level = 1;
startGame();
} else if (currentState === STATE.LEVELCLEAR) {
level++;
startLevel();
} else if (currentState === STATE.PLAYING && ball.stuck) {
ball.stuck = false;
ball.vy = -ball.speed;
ball.vx = (Math.random() - 0.5) * ball.speed * 0.5;
}
}
// --- Entities ---
const paddle = {
w: 120, h: 15, x: 0, y: LOGICAL_H - 50, vx: 0, speed: 700, squish: 1,
update(dt) {
if (keys.left) this.vx = -this.speed;
else if (keys.right) this.vx = this.speed;
else if (usingMouse && mouseX !== null) {
let target = mouseX - this.w / 2;
this.vx = (target - this.x) * 15;
} else {
this.vx = 0;
}
this.x += this.vx * dt;
this.x = Math.max(10, Math.min(LOGICAL_W - this.w - 10, this.x));
this.squish += (1 - this.squish) * 10 * dt;
},
draw(ctx) {
ctx.save();
ctx.translate(this.x + this.w/2, this.y + this.h/2);
ctx.scale(this.squish, 2 - this.squish);
ctx.shadowBlur = 20;
ctx.shadowColor = '#00ffff';
ctx.fillStyle = '#ffffff';
ctx.fillRect(-this.w/2, -this.h/2, this.w, this.h);
ctx.restore();
}
};
const ball = {
x: 0, y: 0, r: 8, vx: 0, vy: 0, speed: 350, stuck: true,
trail: [],
reset() {
this.x = paddle.x + paddle.w/2;
this.y = paddle.y - this.r - 1;
this.vx = 0; this.vy = 0;
this.stuck = true;
this.trail = [];
},
update(dt) {
if (this.stuck) {
this.x = paddle.x + paddle.w/2;
this.y = paddle.y - this.r - 1;
return;
}
let prevX = this.x;
let prevY = this.y;
this.x += this.vx * dt;
this.y += this.vy * dt;
// Trail
this.trail.push({x: this.x, y: this.y});
if(this.trail.length > 8) this.trail.shift();
// Walls
if (this.x - this.r < 10) { this.x = 10 + this.r; this.vx *= -1; playSound('wall'); }
if (this.x + this.r > LOGICAL_W - 10) { this.x = LOGICAL_W - 10 - this.r; this.vx *= -1; playSound('wall'); }
if (this.y - this.r < 10) { this.y = 10 + this.r; this.vy *= -1; playSound('wall'); }
// Prevent boring horizontal loops
if (Math.abs(this.vy) < this.speed * 0.2) {
this.vy = (this.vy > 0 ? 1 : -1) * this.speed * 0.2;
let signVx = Math.sign(this.vx) || 1;
this.vx = Math.sqrt(this.speed*this.speed - this.vy*this.vy) * signVx;
}
// Bottom (Lose Life)
if (this.y + this.r > LOGICAL_H) {
lives--;
playSound('lose');
updateHUD();
if (lives <= 0) {
currentState = STATE.GAMEOVER;
gameOverScreen.classList.remove('hidden');
finalScore.innerText = score;
} else {
this.reset();
}
}
// Paddle Collision
if (this.vy > 0 && circleRectCollide(this.x, this.y, this.r, paddle.x, paddle.y, paddle.w, paddle.h)) {
if (prevY + this.r <= paddle.y + 10) {
this.y = paddle.y - this.r - 0.1;
let hitFactor = (this.x - (paddle.x + paddle.w/2)) / (paddle.w/2);
let angle = hitFactor * (Math.PI / 3);
this.speed = Math.min(this.speed + 8, 800);
this.vx = this.speed * Math.sin(angle);
this.vy = -this.speed * Math.cos(angle);
paddle.squish = 0.6;
shake = 8;
playSound('paddle');
}
}
// Brick Collision
for (let b of bricks) {
if (!b.active) continue;
if (circleRectCollide(this.x, this.y, this.r, b.x, b.y, b.w, b.h)) {
b.active = false;
score += 10 * level;
updateHUD();
playSound('brick');
shake = 5;
spawnParticles(b.x + b.w/2, b.y + b.h/2, b.color);
spawnFloatingText(b.x + b.w/2, b.y + b.h/2, `+${10 * level}`);
// Resolve reflection based on prev position
if (prevY + this.r <= b.y) {
this.vy *= -1; this.y = b.y - this.r - 0.1;
} else if (prevY - this.r >= b.y + b.h) {
this.vy *= -1; this.y = b.y + b.h + this.r + 0.1;
} else if (prevX + this.r <= b.x) {
this.vx *= -1; this.x = b.x - this.r - 0.1;
} else if (prevX - this.r >= b.x + b.w) {
this.vx *= -1; this.x = b.x + b.w + this.r + 0.1;
} else {
this.vy *= -1; // Fallback
}
if (bricks.every(br => !br.active)) {
currentState = STATE.LEVELCLEAR;
levelClearScreen.classList.remove('hidden');
playSound('win');
}
break;
}
}
},
draw(ctx) {
ctx.save();
ctx.globalCompositeOperation = 'lighter';
for(let i=0; i<this.trail.length; i++) {
let p = this.trail[i];
ctx.globalAlpha = (i+1)/this.trail.length * 0.4;
ctx.fillStyle = '#00ffff';
ctx.beginPath();
ctx.arc(p.x, p.y, this.r * (i+1)/this.trail.length, 0, Math.PI*2);
ctx.fill();
}
ctx.restore();
ctx.save();
ctx.shadowBlur = 20;
ctx.shadowColor = '#00ffff';
ctx.fillStyle = '#ffffff';
ctx.beginPath();
ctx.arc(this.x, this.y, this.r, 0, Math.PI*2);
ctx.fill();
ctx.restore();
}
};
function circleRectCollide(cx, cy, r, rx, ry, rw, rh) {
let testX = cx, testY = cy;
if (cx < rx) testX = rx; else if (cx > rx + rw) testX = rx + rw;
if (cy < ry) testY = ry; else if (cy > ry + rh) testY = ry + rh;
let distX = cx - testX, distY = cy - testY;
return (distX*distX + distY*distY) <= r*r;
}
// --- Juice Effects ---
function spawnParticles(x, y, color) {
for(let i=0; i<15; i++) {
particles.push({
x: x, y: y,
vx: (Math.random()-0.5)*400,
vy: (Math.random()-0.5)*400,
life: 1.0,
color: color,
size: Math.random()*4 + 2
});
}
}
function spawnFloatingText(x, y, text) {
floatingTexts.push({x, y, text, life: 1.0});
}
const levelColors = ['#ff0055', '#ffaa00', '#00ffaa', '#00ffff', '#5555ff', '#ff00ff'];
function initLevel() {
bricks = [];
let cols = 11, rows = 6;
let bw = (LOGICAL_W - 60) / cols;
let bh = 30;
let startX = 30, startY = 90;
for(let r=0; r<rows; r++) {
for(let c=0; c<cols; c++) {
let active = false;
switch(level) {
case 1: active = true; break;
case 2: active = (c >= r && c < cols - r); break;
case 3: active = ((r+c)%2 === 0); break;
case 4: active = (r===0 || r===rows-1 || c===0 || c===cols-1 || r===Math.floor(rows/2)); break;
case 5:
let midC = Math.floor(cols/2), midR = Math.floor(rows/2);
active = (Math.abs(c - midC) + Math.abs(r - midR) <= 3); break;
default: active = Math.random() > 0.3; break;
}
if(active) {
bricks.push({
x: startX + c * bw + 2, y: startY + r * bh + 2,
w: bw - 4, h: bh - 4, active: true,
color: levelColors[r % levelColors.length]
});
}
}
}
ball.speed = 350 + (level * 20);
ball.reset();
updateHUD();
}
function startGame() {
startScreen.classList.add('hidden');
gameOverScreen.classList.add('hidden');
levelClearScreen.classList.add('hidden');
currentState = STATE.PLAYING;
initLevel();
}
function startLevel() {
levelClearScreen.classList.add('hidden');
currentState = STATE.PLAYING;
initLevel();
}
// --- Main Loop ---
let lastTime = 0;
function loop(timestamp) {
if (!lastTime) lastTime = timestamp;
let dt = (timestamp - lastTime) / 1000;
lastTime = timestamp;
if (dt > 0.05) dt = 0.05; // Cap dt to prevent tunneling
// Update
paddle.update(dt);
ball.update(dt);
for(let i = particles.length - 1; i >= 0; i--) {
let p = particles[i];
p.x += p.vx * dt; p.y += p.vy * dt;
p.vy += 800 * dt; // Gravity
p.life -= dt * 2;
if(p.life <= 0) particles.splice(i, 1);
}
for(let i = floatingTexts.length - 1; i >= 0; i--) {
floatingTexts[i].y -= 50 * dt;
floatingTexts[i].life -= dt * 1.5;
if(floatingTexts[i].life <= 0) floatingTexts.splice(i, 1);
}
// Draw
ctx.fillStyle = '#050510';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.save();
ctx.translate(offsetX, offsetY);
ctx.scale(scale, scale);
if (shake > 0) {
ctx.translate((Math.random()-0.5)*shake, (Math.random()-0.5)*shake);
shake *= 0.9;
if(shake < 0.5) shake = 0;
}
// Border
ctx.strokeStyle = '#1a1a3a';
ctx.lineWidth = 4;
ctx.strokeRect(5, 5, LOGICAL_W - 10, LOGICAL_H - 10);
// Bricks
for(let b of bricks) {
if(!b.active) continue;
ctx.save();
ctx.shadowBlur = 15;
ctx.shadowColor = b.color;
ctx.fillStyle = b.color;
ctx.fillRect(b.x, b.y, b.w, b.h);
// Inner highlight
ctx.fillStyle = 'rgba(255,255,255,0.4)';
ctx.fillRect(b.x, b.y, b.w, 4);
ctx.restore();
}
paddle.draw(ctx);
ball.draw(ctx);
// Particles
ctx.save();
ctx.globalCompositeOperation = 'lighter';
for(let p of particles) {
ctx.globalAlpha = Math.max(0, p.life);
ctx.fillStyle = p.color;
ctx.shadowBlur = 10;
ctx.shadowColor = p.color;
ctx.beginPath();
ctx.arc(p.x, p.y, p.size * p.life, 0, Math.PI*2);
ctx.fill();
}
ctx.restore();
// Floating text
ctx.font = 'bold 18px Courier New';
ctx.textAlign = 'center';
for(let ft of floatingTexts) {
ctx.fillStyle = `rgba(255, 255, 255, ${Math.max(0, ft.life)})`;
ctx.fillText(ft.text, ft.x, ft.y);
}
ctx.restore();
requestAnimationFrame(loop);
}
// Initialize idle state layout
initLevel();
requestAnimationFrame(loop);
</script>
</body>
</html>

