Run details
- Model
- upstage/solar-mini-4-5
- Route
- OpenRouter API
- Served by
- Upstage
- Effort
- medium (OpenRouter default)
- Limits
- 60 min · 131,072 output tokens (model max)
- Date
- 25 Nov 2026
- Time
- 26 s
- Size
- 30 kB
- Tokens
- 125 in, 10,770 out
- List price
- <$0.001 at today's price ($0.01 in / $0.04 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
30 kB 1,116 lines Raw
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>Neon Breakout</title>
<style>
:root{
--bg1:#0a0a1a;
--bg2:#131333;
}
*{ box-sizing:border-box; }
html,body{
margin:0; padding:0; height:100%; overflow:hidden;
background: radial-gradient(circle at 50% 30%, #181842 0%, #07070f 65%, #04040a 100%);
font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
color:#e8f0ff;
touch-action: none;
user-select:none;
-webkit-user-select:none;
-webkit-tap-highlight-color: transparent;
}
#stage{
position:fixed; inset:0;
display:flex; align-items:center; justify-content:center;
padding: 12px;
}
canvas{
display:block;
border-radius:18px;
box-shadow:
0 0 60px rgba(90,120,255,.35),
0 0 120px rgba(200,60,255,.15),
inset 0 0 60px rgba(0,0,0,.7);
background: linear-gradient(180deg, rgba(20,20,50,.95) 0%, rgba(8,8,20,.97) 100%);
cursor: crosshair;
}
#hint{
position:fixed; left:0; right:0; bottom:8px;
text-align:center;
font-size:12px;
letter-spacing:1px;
color:rgba(200,215,255,.45);
pointer-events:none;
}
</style>
</head>
<body>
<div id="stage"><canvas id="game"></canvas></div>
<div id="hint">← → / A D / MOUSE to move · SPACE / CLICK to launch · P to pause</div>
<script>
(function(){
"use strict";
// ---------------------------------------------------------------- canvas
const W = 800, H = 600;
const canvas = document.getElementById('game');
const ctx = canvas.getContext('2d');
const dpr = Math.min(window.devicePixelRatio || 1, 2);
canvas.width = W * dpr;
canvas.height = H * dpr;
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
// ---------------------------------------------------------------- state
const BEST_KEY = 'neon-breakout-best';
let best = 0;
try { best = parseInt(localStorage.getItem(BEST_KEY) || '0', 10) || 0; } catch(e){ best = 0; }
const G = {
state: 'title', // title | play | paused | levelclear | levelstart | gameover
level: 1,
score: 0,
lives: 3,
time: 0,
shake: 0,
flash: 0,
levelTimer: 0,
levelTotal: 0,
combo: 0,
comboTimer: 0,
best: best,
touchTarget: null
};
// ---------------------------------------------------------------- objects
const paddle = { w:110, h:16, x:(W-110)/2, y:H-44, vx:0, speed:620 };
const balls = [];
const bricks = [];
const particles = [];
const floaters = [];
const BRICK = { cols: 11, rows: 5, w: 60, h: 24, top: 86, gap: 6, pad: 12 };
// left margin: center the brick field
BRICK.left = (W - (BRICK.cols * BRICK.w + (BRICK.cols - 1) * BRICK.gap)) / 2;
const ballDef = { r: 8, speed: 360 };
// ---------------------------------------------------------------- helpers
const clamp = (v,a,b)=> v<a?a:(v>b?b:v);
const rand = (a,b)=> a + Math.random()*(b-a);
const lerp = (a,b,t)=> a + (b-a)*t;
function roundRect(x,y,w,h,r){
r = Math.min(r, w/2, h/2);
ctx.beginPath();
ctx.moveTo(x+r,y);
ctx.arcTo(x+w,y,x+w,y+h,r);
ctx.arcTo(x+w,y+h,x,y+h,r);
ctx.arcTo(x,y+h,x,y,r);
ctx.arcTo(x,y,x+w,y,r);
ctx.closePath();
}
function hexToRgb(hex){
const n = parseInt(hex.slice(1),16);
return [(n>>16)&255, (n>>8)&255, n&255];
}
// ---------------------------------------------------------------- brick patterns
// each level uses a different pattern function
const patterns = [
function(c,r,rows){ return rows - r; }, // inverted triangle
function(c,r,rows){ return (c + r) % rows === 0 ? rows - r : rows - r - 1; },
function(c,r,rows){
if (r < 2) return rows - r;
return (c % 2 === 0) ? rows - r - 1 : rows - r;
},
function(c,r,rows){ return r === 0 ? rows : (c > 3 && c < 7 ? rows - 1 : rows - r - 2); },
function(c,r,rows){ return (r + c) % 2 === 0 ? rows : rows - 1; }
];
const COLORS = [
{name:'crimson', main:'#ff3b6b', rgb:[255,59,107]},
{name:'orange', main:'#ff9d2e', rgb:[255,157,46]},
{name:'gold', main:'#ffe04d', rgb:[255,224,77]},
{name:'mint', main:'#3ef2a6', rgb:[62,242,166]},
{name:'cyan', main:'#37e6ff', rgb:[55,230,255]},
{name:'violet', main:'#a46bff', rgb:[164,107,255]},
{name:'pink', main:'#ff6be5', rgb:[255,107,229]}
];
function levelRows(l){
return Math.min(3 + Math.floor((l-1)/1), 6); // 4,5,6,7 capped
}
function buildLevel(l){
bricks.length = 0;
const rows = levelRows(l);
const pat = patterns[(l-1) % patterns.length];
for (let r=0; r<rows; r++){
for (let c=0; c<BRICK.cols; c++){
const strength = pat(c, r, rows);
if (strength <= 0) continue;
const hp = 1 + Math.floor((strength - 1) / 2);
const ci = (l + c + r) % COLORS.length;
const col = COLORS[ci];
bricks.push({
x: BRICK.left + c*(BRICK.w + BRICK.gap),
y: BRICK.top + r*(BRICK.h + BRICK.gap),
w: BRICK.w, h: BRICK.h,
hp: hp, maxHp: hp,
color: col,
alive: true,
flash: 0,
glow: 0
});
}
}
G.levelTotal = bricks.length;
}
// ---------------------------------------------------------------- reset
function resetBall(){
balls.length = 0;
balls.push({
x: paddle.x + paddle.w/2,
y: paddle.y - ballDef.r - 1,
r: ballDef.r,
vx: 0, vy: 0,
speed: ballDef.speed,
stuck: true,
trail: []
});
}
function resetPaddle(){
paddle.x = (W - paddle.w)/2;
paddle.vx = 0;
}
function newGame(){
G.state = 'levelstart';
G.level = 1;
G.score = 0;
G.lives = 3;
G.time = 0;
G.shake = 0;
G.flash = 0;
G.combo = 0;
G.comboTimer = 0;
G.levelTimer = 0;
particles.length = 0;
floaters.length = 0;
buildLevel(1);
resetPaddle();
resetBall();
}
// ---------------------------------------------------------------- update
function updatePaddle(dt){
let dir = 0;
if (keys.has('ArrowLeft') || keys.has('a') || keys.has('A')) dir -= 1;
if (keys.has('ArrowRight') || keys.has('d') || keys.has('D')) dir += 1;
let target = null;
if (dir !== 0) target = null; // keyboard
if (mouseActive){
const mx = G.touchTarget !== null ? G.touchTarget : mouse.x;
// paddle centers on mouse
target = mx;
}
if (target !== null){
const center = paddle.x + paddle.w/2;
let nx = target - paddle.w/2;
nx = clamp(nx, 0, W - paddle.w);
// smooth follow
const diff = nx - paddle.x;
if (Math.abs(diff) > 0.5){
paddle.x = lerp(paddle.x, nx, 1 - Math.pow(0.0001, dt));
paddle.vx = diff / dt;
}
} else if (dir !== 0){
paddle.x += dir * paddle.speed * dt;
paddle.x = clamp(paddle.x, 0, W - paddle.w);
paddle.vx = dir * paddle.speed;
} else {
paddle.vx = lerp(paddle.vx, 0, 1 - Math.pow(0.0005, dt));
paddle.x += paddle.vx * dt;
paddle.x = clamp(paddle.x, 0, W - paddle.w);
paddle.vx = 0;
}
}
function updateBalls(dt){
for (let i=0;i<balls.length;i++){
const b = balls[i];
if (b.stuck){
b.x = paddle.x + paddle.w/2;
b.y = paddle.y - b.r - 1;
b.trail.length = 0;
continue;
}
// trail
b.trail.push({x:b.x, y:b.y, r:b.r});
if (b.trail.length > 8) b.trail.shift();
b.x += b.vx * dt;
b.y += b.vy * dt;
// walls
if (b.x - b.r < 0){ b.x = b.r; b.vx = Math.abs(b.vx); wallHit(b.x, b.y); }
if (b.x + b.r > W){ b.x = W - b.r; b.vx = -Math.abs(b.vx); wallHit(b.x, b.y); }
if (b.y - b.r < 0){ b.y = b.r; b.vy = Math.abs(b.vy); wallHit(b.x, b.y); }
// paddle
if (b.vy > 0 &&
b.y + b.r >= paddle.y &&
b.y - b.r <= paddle.y + paddle.h &&
b.x >= paddle.x - b.r &&
b.x <= paddle.x + paddle.w + b.r){
const rel = (b.x - (paddle.x + paddle.w/2)) / (paddle.w/2);
const ang = rel * (Math.PI/3); // up to 60deg
const sp = Math.hypot(b.vx, b.vy);
b.vx = sp * Math.sin(ang);
b.vy = -sp * Math.cos(ang);
b.y = paddle.y - b.r - 0.5;
paddleBounceSparks(b.x, b.y);
}
// bottom
if (b.y - b.r > H){
removeBall(i);
i--;
}
}
}
function removeBall(i){
balls.splice(i,1);
if (balls.length === 0){
loseLife();
}
}
function loseLife(){
G.lives--;
G.shake = 18;
G.flash = 0.35;
addFloatingText(W/2, H*0.4, '-1 LIFE', '#ff4d6d', 34);
burst(paddle.x + paddle.w/2, paddle.y - 10, 24, '#ff6b8a');
if (G.lives < 0){ G.lives = 0; }
if (G.lives <= 0){
G.state = 'gameover';
if (G.score > G.best){
G.best = G.score;
try { localStorage.setItem(BEST_KEY, String(G.best)); } catch(e){}
}
} else {
resetBall();
G.combo = 0;
G.comboTimer = 0;
}
}
function updateBricks(dt){
for (const b of bricks){
if (b.flash > 0) b.flash = Math.max(0, b.flash - dt*6);
if (b.glow > 0) b.glow = Math.max(0, b.glow - dt*3);
}
}
function ballBrickCollisions(b){
if (b.stuck) return;
let hit = false;
for (const br of bricks){
if (!br.alive) continue;
if (b.x + b.r > br.x && b.x - b.r < br.x + br.w &&
b.y + b.r > br.y && b.y - b.r < br.y + br.h){
// determine overlap axis
const oL = (b.x + b.r) - br.x;
const oR = (br.x + br.w) - (b.x - b.r);
const oT = (b.y + b.r) - br.y;
const oB = (br.y + br.h) - (b.y - b.r);
const minH = Math.min(oL, oR);
const minV = Math.min(oT, oB);
if (minH < minV){
b.vx *= -1;
if (oL < oR) b.x -= oL + 0.5; else b.x += oR + 0.5;
} else {
b.vy *= -1;
if (oT < oB) b.y -= oT + 0.5; else b.y += oB + 0.5;
}
hitBrick(br, b);
hit = true;
break;
}
}
return hit;
}
function hitBrick(br, b){
br.hp--;
br.flash = 1;
br.glow = 1;
// scoring with combo
G.combo++;
G.comboTimer = 2.2;
const comboMult = 1 + Math.floor((G.combo-1) * 0.15);
const base = br.maxHp * 10;
const gained = base * comboMult;
G.score += gained;
const color = br.color;
burst(br.x + br.w/2, br.y + br.h/2, 8, color.main);
if (br.hp <= 0){
br.alive = false;
G.flash = Math.max(G.flash, 0.12);
// bigger burst + floating text
burst(br.x + br.w/2, br.y + br.h/2, 18, color.main);
burst(br.x + br.w/2, br.y + br.h/2, 10, '#ffffff');
addFloatingText(br.x + br.w/2, br.y + br.h/2, '+' + gained, color.main, 16 + Math.min(comboMult,4)*2);
if (G.combo >= 3){
addFloatingText(br.x + br.w/2, br.y + br.h/2 - 20, 'x' + comboMult, '#ffe04d', 14);
}
// maybe drop a special? skip
} else {
// damaged
burst(br.x + br.w/2, br.y + br.h/2, 4, color.main);
}
G.shake = Math.max(G.shake, 3.5);
G.time = 0;
}
function addFloatingText(x,y,text,color,size){
floaters.push({x,y,text,color,size,size0:size, life:1, maxLife:1});
}
function burst(x,y,n,color){
for (let i=0;i<n;i++){
const a = Math.random()*Math.PI*2;
const sp = rand(40, 320);
const life = rand(0.35, 0.9);
particles.push({
x, y,
vx: Math.cos(a)*sp,
vy: Math.sin(a)*sp - 60,
r: rand(1.5, 4),
life, maxLife: life,
color: color || '#fff'
});
}
}
// ---------------------------------------------------------------- background
let stars = [];
for (let i=0;i<120;i++){
stars.push({
x: Math.random()*W,
y: Math.random()*H,
r: Math.random()*1.6 + 0.3,
a: Math.random()*0.6 + 0.15,
tw: Math.random()*Math.PI*2
});
}
function drawBackground(dt){
// subtle moving gradient
const t = G.time;
const g = ctx.createLinearGradient(0,0,0,H);
g.addColorStop(0, '#0c0c22');
g.addColorStop(0.55, '#080818');
g.addColorStop(1, '#050510');
ctx.fillStyle = g;
ctx.fillRect(0,0,W,H);
// nebula blobs
ctx.save();
ctx.globalCompositeOperation = 'lighter';
for (let i=0;i<5;i++){
const cx = W*(0.5 + 0.42*Math.sin(t*0.15 + i*1.7));
const cy = H*(0.5 + 0.35*Math.cos(t*0.11 + i*2.3));
const rr = 220 + 60*Math.sin(t*0.3 + i);
const grd = ctx.createRadialGradient(cx,cy,0,cx,cy,rr);
const hue = [220,280,260,320,200][i];
grd.addColorStop(0, 'rgba(' + (hue%255) + ',80,255,0.06)');
grd.addColorStop(1, 'rgba(0,0,0,0)');
ctx.fillStyle = grd;
ctx.beginPath(); ctx.arc(cx,cy,rr,0,Math.PI*2); ctx.fill();
}
ctx.restore();
// stars
for (const s of stars){
const a = s.a * (0.6 + 0.4*Math.sin(t*1.6 + s.tw));
ctx.fillStyle = 'rgba(200,220,255,' + a.toFixed(3) + ')';
ctx.beginPath();
ctx.arc(s.x, s.y, s.r, 0, Math.PI*2);
ctx.fill();
}
// subtle grid lines at bottom for depth
ctx.save();
ctx.globalAlpha = 0.06;
ctx.strokeStyle = '#4a6bff';
ctx.lineWidth = 1;
ctx.beginPath();
for (let x=0;x<W;x+=40){ ctx.moveTo(x,H); ctx.lineTo(x,H); }
ctx.stroke();
ctx.restore();
}
// ---------------------------------------------------------------- draw
function drawBricks(){
for (const br of bricks){
if (!br.alive) continue;
const x = br.x, y = br.y, w = br.w, h = br.h;
const r = 6;
// glow
const alpha = 0.25 + 0.35*br.glow;
ctx.save();
ctx.globalAlpha = alpha;
ctx.shadowColor = br.color.main;
ctx.shadowBlur = 18 + 20*br.glow;
ctx.fillStyle = br.color.main;
roundRect(x, y, w, h, r);
ctx.fill();
ctx.restore();
// body
const g = ctx.createLinearGradient(x, y, x, y+h);
g.addColorStop(0, br.color.main);
g.addColorStop(1, 'rgba(' + br.color.rgb.join(',') + ',0.55)');
ctx.fillStyle = g;
roundRect(x, y, w, h, r);
ctx.fill();
// inner highlight
ctx.save();
ctx.clip();
const hi = ctx.createLinearGradient(x, y, x, y+h*0.6);
hi.addColorStop(0, 'rgba(255,255,255,0.35)');
hi.addColorStop(1, 'rgba(255,255,255,0)');
ctx.fillStyle = hi;
ctx.fillRect(x, y, w, h*0.7);
// damage darkening
const hpFrac = br.hp / br.maxHp;
if (hpFrac < 1){
ctx.fillStyle = 'rgba(0,0,0,' + ((1-hpFrac)*0.55) + ')';
ctx.fillRect(x, y, w, h);
}
ctx.restore();
// border
ctx.strokeStyle = 'rgba(255,255,255,' + (0.15 + 0.25*br.flash) + ')';
ctx.lineWidth = 1.5;
roundRect(x, y, w, h, r);
ctx.stroke();
// flash overlay
if (br.flash > 0){
ctx.fillStyle = 'rgba(255,255,255,' + (br.flash*0.85) + ')';
roundRect(x, y, w, h, r);
ctx.fill();
}
// hp pips
if (br.maxHp > 1){
for (let i=0;i<br.maxHp;i++){
const px = x + 6 + i*8;
const py = y + h - 6;
ctx.fillStyle = i < br.hp ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.4)';
ctx.beginPath();
ctx.arc(px, py, 2.2, 0, Math.PI*2);
ctx.fill();
}
}
}
}
function drawPaddle(){
const x = paddle.x, y = paddle.y, w = paddle.w, h = paddle.h;
// glow
ctx.save();
ctx.shadowColor = '#5ad1ff';
ctx.shadowBlur = 24;
ctx.fillStyle = '#5ad1ff';
roundRect(x, y, w, h, h/2);
ctx.fill();
ctx.restore();
const g = ctx.createLinearGradient(x, y, x, y+h);
g.addColorStop(0, '#d9fbff');
g.addColorStop(0.5, '#5ad1ff');
g.addColorStop(1, '#2a6fd6');
ctx.fillStyle = g;
roundRect(x, y, w, h, h/2);
ctx.fill();
// inner shine
ctx.save();
ctx.clip();
ctx.fillStyle = 'rgba(255,255,255,0.45)';
roundRect(x + 6, y + 2, w - 12, 4, 2);
ctx.fill();
ctx.restore();
// speed streak effect
if (Math.abs(paddle.vx) > 200){
const a = Math.min(0.25, Math.abs(paddle.vx)/3000);
ctx.save();
ctx.globalAlpha = a;
ctx.strokeStyle = '#9be8ff';
ctx.lineWidth = 2;
ctx.beginPath();
if (paddle.vx > 0){
ctx.moveTo(x + 10, y + h/2); ctx.lineTo(x - 20, y + h/2);
} else {
ctx.moveTo(x + w - 10, y + h/2); ctx.lineTo(x + w + 20, y + h/2);
}
ctx.stroke();
ctx.restore();
}
}
function drawBall(b){
// trail
for (let i=0;i<b.trail.length;i++){
const t = b.trail[i];
const k = (i+1)/b.trail.length;
ctx.save();
ctx.globalAlpha = k*0.35;
ctx.fillStyle = 'rgba(160,220,255,' + (k*0.5) + ')';
ctx.beginPath();
ctx.arc(t.x, t.y, t.r*0.6*k, 0, Math.PI*2);
ctx.fill();
ctx.restore();
}
const x = b.x, y = b.y, r = b.r;
ctx.save();
ctx.shadowColor = '#7fdcff';
ctx.shadowBlur = 26;
ctx.fillStyle = '#dff6ff';
ctx.beginPath();
ctx.arc(x, y, r*1.15, 0, Math.PI*2);
ctx.fill();
ctx.restore();
const g = ctx.createRadialGradient(x - r*0.35, y - r*0.35, r*0.1, x, y, r);
g.addColorStop(0, '#ffffff');
g.addColorStop(0.5, '#a8ecff');
g.addColorStop(1, '#2e86e0');
ctx.fillStyle = g;
ctx.beginPath();
ctx.arc(x, y, r, 0, Math.PI*2);
ctx.fill();
// specular
ctx.fillStyle = 'rgba(255,255,255,0.9)';
ctx.beginPath();
ctx.arc(x - r*0.35, y - r*0.35, r*0.28, 0, Math.PI*2);
ctx.fill();
}
function drawParticles(dt){
for (const p of particles){
p.x += p.vx*dt;
p.y += p.vy*dt;
p.vy += 700*dt;
p.vx *= (1 - 1.6*dt);
p.life -= dt;
}
for (const p of particles){
const k = Math.max(0, p.life / p.maxLife);
ctx.save();
ctx.globalAlpha = k;
ctx.fillStyle = p.color;
ctx.shadowColor = p.color;
ctx.shadowBlur = 8;
ctx.beginPath();
ctx.arc(p.x, p.y, p.r * (0.3 + 0.7*k), 0, Math.PI*2);
ctx.fill();
ctx.restore();
}
}
function drawFloaters(dt){
for (const f of floaters){
f.life -= dt;
f.y -= 40*dt;
const s = f.size0 * (1 + (1-f.life)*0.6);
ctx.save();
ctx.globalAlpha = Math.min(1, f.life*2.5);
ctx.font = 'bold ' + s + 'px ui-monospace, monospace';
ctx.textAlign = 'center';
ctx.fillStyle = f.color;
ctx.shadowColor = f.color;
ctx.shadowBlur = 12;
ctx.fillText(f.text, f.x, f.y);
ctx.restore();
}
}
function drawHUD(){
ctx.save();
ctx.font = 'bold 20px ui-monospace, monospace';
ctx.textAlign = 'left';
ctx.textBaseline = 'top';
// score
ctx.fillStyle = 'rgba(220,240,255,0.95)';
ctx.shadowColor = '#4a8cff';
ctx.shadowBlur = 14;
ctx.fillText('SCORE ' + G.score, 20, 18);
// best
ctx.font = '13px ui-monospace, monospace';
ctx.fillStyle = 'rgba(160,190,255,0.75)';
ctx.shadowBlur = 0;
ctx.fillText('BEST ' + Math.max(G.best, G.score), 20, 46);
// level
ctx.textAlign = 'center';
ctx.font = 'bold 18px ui-monospace, monospace';
ctx.fillStyle = 'rgba(200,230,255,0.9)';
ctx.shadowColor = '#a46bff';
ctx.shadowBlur = 12;
ctx.fillText('LEVEL ' + G.level, W/2, 18);
// lives (paddle icons)
ctx.textAlign = 'right';
ctx.font = 'bold 16px ui-monospace, monospace';
ctx.fillStyle = 'rgba(220,240,255,0.9)';
ctx.shadowColor = '#5ad1ff';
ctx.shadowBlur = 10;
ctx.fillText('LIVES', W - 20 - 40, 20);
for (let i=0;i<G.lives;i++){
const px = W - 20 - 40 - (i+1)*22;
const py = 30;
ctx.save();
ctx.shadowColor = '#5ad1ff';
ctx.shadowBlur = 12;
ctx.fillStyle = 'rgba(120,220,255,0.9)';
roundRect(px - 8, py - 4, 16, 8, 4);
ctx.fill();
ctx.restore();
}
ctx.restore();
}
function overlayText(title, sub, color, alpha){
ctx.save();
ctx.globalAlpha = alpha;
ctx.textAlign = 'center';
ctx.font = 'bold 46px ui-monospace, monospace';
ctx.fillStyle = color || '#fff';
ctx.shadowColor = color || '#fff';
ctx.shadowBlur = 26;
ctx.fillText(title, W/2, H/2 - 20);
if (sub){
ctx.font = '17px ui-monospace, monospace';
ctx.fillStyle = 'rgba(220,235,255,0.85)';
ctx.shadowBlur = 0;
ctx.fillText(sub, W/2, H/2 + 22);
}
ctx.restore();
}
function drawTitleScreen(){
// dark veil
ctx.save();
ctx.fillStyle = 'rgba(5,5,15,0.55)';
ctx.fillRect(0,0,W,H);
ctx.restore();
ctx.save();
ctx.textAlign = 'center';
const t = performance.now()/1000;
const pulse = 1 + 0.03*Math.sin(t*2.4);
ctx.save();
ctx.translate(W/2, H/2 - 90);
ctx.scale(pulse, pulse);
ctx.font = 'bold 74px ui-monospace, monospace';
ctx.fillStyle = '#eaf4ff';
ctx.shadowColor = '#4a8cff';
ctx.shadowBlur = 40;
ctx.fillText('NEON', -120, 0);
ctx.fillStyle = '#d9b8ff';
ctx.shadowColor = '#a46bff';
ctx.fillText('BREAK', 92, 0);
ctx.restore();
ctx.font = '18px ui-monospace, monospace';
ctx.fillStyle = 'rgba(180,210,255,0.8)';
ctx.shadowBlur = 0;
ctx.fillText('Shatter every brick. Survive the wave.', W/2, H/2 - 10);
// blinking prompt
const a = 0.55 + 0.45*Math.sin(t*3.2);
ctx.globalAlpha = a;
ctx.font = 'bold 22px ui-monospace, monospace';
ctx.fillStyle = '#ffe04d';
ctx.shadowColor = '#ffe04d';
ctx.shadowBlur = 20;
ctx.fillText('PRESS SPACE TO START', W/2, H/2 + 70);
ctx.globalAlpha = 1;
// controls
ctx.font = '14px ui-monospace, monospace';
ctx.fillStyle = 'rgba(150,180,230,0.65)';
ctx.fillText('← → / A D / MOUSE • SPACE / CLICK • P pause', W/2, H/2 + 110);
if (G.best > 0){
ctx.fillStyle = 'rgba(120,255,200,0.7)';
ctx.fillText('BEST: ' + G.best, W/2, H/2 + 142);
}
ctx.restore();
}
function drawPauseOverlay(){
ctx.save();
ctx.fillStyle = 'rgba(5,5,15,0.6)';
ctx.fillRect(0,0,W,H);
ctx.restore();
overlayText('PAUSED', 'press P to resume', '#9be8ff', 0.95);
}
function drawGameOver(){
ctx.save();
ctx.fillStyle = 'rgba(20,0,10,0.65)';
ctx.fillRect(0,0,W,H);
ctx.restore();
ctx.save();
ctx.textAlign = 'center';
const t = performance.now()/1000;
ctx.font = 'bold 54px ui-monospace, monospace';
ctx.fillStyle = '#ff4d6d';
ctx.shadowColor = '#ff2e5c';
ctx.shadowBlur = 34;
ctx.fillText('GAME OVER', W/2, H/2 - 70);
ctx.font = 'bold 26px ui-monospace, monospace';
ctx.fillStyle = '#eaf4ff';
ctx.shadowColor = '#4a8cff';
ctx.fillText('SCORE ' + G.score, W/2, H/2 - 10);
ctx.font = '17px ui-monospace, monospace';
ctx.fillStyle = 'rgba(180,210,255,0.85)';
ctx.shadowBlur = 0;
ctx.fillText('LEVEL REACHED ' + G.level, W/2, H/2 + 26);
if (G.score >= G.best && G.score > 0){
const a = 0.55 + 0.45*Math.sin(t*4);
ctx.globalAlpha = a;
ctx.font = 'bold 18px ui-monospace, monospace';
ctx.fillStyle = '#ffe04d';
ctx.shadowColor = '#ffe04d';
ctx.shadowBlur = 18;
ctx.fillText('NEW BEST!', W/2, H/2 + 66);
ctx.globalAlpha = 1;
}
ctx.globalAlpha = 0.55 + 0.45*Math.sin(t*3);
ctx.font = 'bold 20px ui-monospace, monospace';
ctx.fillStyle = '#7fffc4';
ctx.shadowColor = '#7fffc4';
ctx.fillText('PRESS SPACE TO RETRY', W/2, H/2 + 124);
ctx.restore();
}
function drawLevelStart(){
ctx.save();
ctx.fillStyle = 'rgba(5,5,15,0.45)';
ctx.fillRect(0,0,W,H);
ctx.restore();
ctx.save();
ctx.textAlign = 'center';
const a = 0.6 + 0.4*Math.sin(G.time*4);
ctx.globalAlpha = a;
ctx.font = 'bold 44px ui-monospace, monospace';
ctx.fillStyle = '#9be8ff';
ctx.shadowColor = '#5ad1ff';
ctx.shadowBlur = 30;
ctx.fillText('LEVEL ' + G.level, W/2, H/2);
ctx.font = '16px ui-monospace, monospace';
ctx.fillStyle = 'rgba(200,230,255,0.8)';
ctx.shadowBlur = 0;
ctx.fillText('get ready...', W/2, H/2 + 40);
ctx.restore();
}
function drawLevelClear(){
ctx.save();
ctx.fillStyle = 'rgba(5,20,25,0.45)';
ctx.fillRect(0,0,W,H);
ctx.restore();
ctx.save();
ctx.textAlign = 'center';
ctx.font = 'bold 46px ui-monospace, monospace';
ctx.fillStyle = '#7fffc4';
ctx.shadowColor = '#3ef2a6';
ctx.shadowBlur = 30;
ctx.fillText('LEVEL ' + G.level + ' CLEAR!', W/2, H/2 - 10);
ctx.font = '20px ui-monospace, monospace';
ctx.fillStyle = 'rgba(200,235,255,0.9)';
ctx.shadowBlur = 0;
ctx.fillText('SCORE BONUS +' + (G.levelTotal * 25), W/2, H/2 + 36);
ctx.restore();
}
// ---------------------------------------------------------------- main update
function update(dt){
G.time += dt;
// decay effects
if (G.shake > 0) G.shake = Math.max(0, G.shake - dt*60);
if (G.flash > 0) G.flash = Math.max(0, G.flash - dt*1.4);
if (G.combo > 0){
G.comboTimer -= dt;
if (G.comboTimer <= 0){
G.combo = 0;
}
}
updatePaddle(dt);
if (G.state === 'play'){
updateBalls(dt);
updateBricks(dt);
// collisions can only occur in play
} else if (G.state === 'levelstart'){
updatePaddle(dt);
updateBricks(dt);
} else if (G.state === 'levelclear'){
G.levelTimer += dt;
updatePaddle(dt);
updateBricks(dt);
if (G.levelTimer > 1.8){
G.level++;
G.state = 'levelstart';
G.levelTimer = 0;
buildLevel(G.level);
resetBall();
resetPaddle();
}
}
// particles always
for (let i=particles.length-1;i>=0;i--){
const p = particles[i];
p.x += p.vx*dt;
p.y += p.vy*dt;
p.vy += 720*dt;
p.vx *= (1 - 1.8*dt);
p.life -= dt;
if (p.life <= 0) particles.splice(i,1);
}
for (let i=floaters.length-1;i>=0;i--){
const f = floaters[i];
f.life -= dt;
f.y -= 46*dt;
if (f.life <= 0) floaters.splice(i,1);
}
}
// ---------------------------------------------------------------- render
function render(){
ctx.save();
// screen shake
if (G.shake > 0.5){
const s = G.shake;
ctx.translate(rand(-s,s)*0.5, rand(-s,s)*0.5);
}
drawBackground(0.016);
drawBricks();
drawPaddle();
for (const b of balls) drawBall(b);
drawParticles();
drawFloaters();
ctx.restore();
// flash
if (G.flash > 0.01){
ctx.save();
ctx.globalAlpha = G.flash*0.5;
ctx.fillStyle = '#9be8ff';
ctx.fillRect(0,0,W,H);
ctx.restore();
}
// HUD
drawHUD();
// overlays
if (G.state === 'title') drawTitleScreen();
else if (G.state === 'paused') drawPauseOverlay();
else if (G.state === 'gameover') drawGameOver();
else if (G.state === 'levelstart') drawLevelStart();
else if (G.state === 'levelclear') drawLevelClear();
}
// ---------------------------------------------------------------- loop
let lastT = performance.now();
function loop(now){
let dt = (now - lastT) / 1000;
lastT = now;
if (dt > 0.05) dt = 0.05;
if (dt < 0) dt = 0;
update(dt);
render();
requestAnimationFrame(loop);
}
// ---------------------------------------------------------------- input
const keys = new Set();
window.addEventListener('keydown', (e)=>{
const k = e.key;
if (k === ' ' || k === 'ArrowLeft' || k === 'ArrowRight' || k === 'ArrowUp' || k === 'ArrowDown' || k === 'p' || k === 'P' || k === 'a' || k === 'A' || k === 'd' || k === 'D'){
e.preventDefault();
}
keys.add(k);
if (k === ' ' || k === 'Enter'){
if (G.state === 'title') startGame();
else if (G.state === 'play') launch();
else if (G.state === 'gameover') startGame();
else if (G.state === 'levelstart') { /* ignore */ }
}
if (k === 'p' || k === 'P'){
if (G.state === 'play') G.state = 'paused';
else if (G.state === 'paused') G.state = 'play';
}
});
window.addEventListener('keyup', (e)=>{
keys.delete(e.key);
});
function pointerPos(e){
const r = canvas.getBoundingClientRect();
return {
x: (e.clientX - r.left) * (W / r.width),
y: (e.clientY - r.top) * (H / r.height)
};
}
const mouse = { x: W/2, y: 0 };
let mouseActive = false;
canvas.addEventListener('mousemove', (e)=>{
const p = pointerPos(e);
mouse.x = p.x;
mouse.y = p.y;
mouseActive = true;
});
canvas.addEventListener('mouseleave', ()=>{
mouseActive = false;
});
canvas.addEventListener('mousedown', (e)=>{
const p = pointerPos(e);
mouse.x = p.x;
mouse.y = p.y;
mouseActive = true;
if (G.state === 'title') startGame();
else if (G.state === 'play') launch();
else if (G.state === 'gameover') startGame();
else if (G.state === 'paused') G.state = 'play';
});
canvas.addEventListener('touchstart', (e)=>{
e.preventDefault();
const t0 = e.touches[0];
if (!t0) return;
const p = pointerPos(t0);
G.touchTarget = p.x;
mouse.x = p.x;
mouse.y = p.y;
mouseActive = true;
if (G.state === 'title') startGame();
else if (G.state === 'play') launch();
else if (G.state === 'gameover') startGame();
}, {passive:false});
canvas.addEventListener('touchmove', (e)=>{
e.preventDefault();
const t0 = e.touches[0];
if (!t0) return;
const p = pointerPos(t0);
G.touchTarget = p.x;
mouse.x = p.x;
mouse.y = p.y;
}, {passive:false});
canvas.addEventListener('touchend', (e)=>{
e.preventDefault();
G.touchTarget = null;
mouseActive = false;
}, {passive:false});
// ---------------------------------------------------------------- game actions
function startGame(){
newGame();
G.state = 'levelstart';
G.levelTimer = 0;
}
function launch(){
for (const b of balls){
if (b.stuck){
b.stuck = false;
const ang = rand(-0.35, 0.35) - Math.PI/2;
// random slight bias
const bias = (paddle.x + paddle.w/2) / W - 0.5;
const baseAng = -Math.PI/2 + bias*0.6 + ang;
b.vx = Math.cos(baseAng) * ballDef.speed;
b.vy = Math.sin(baseAng) * ballDef.speed;
if (Math.abs(b.vx) < 30) b.vx = 30 * (b.vx >= 0 ? 1 : -1);
G.combo = 0;
G.comboTimer = 0;
break;
}
}
}
// ---------------------------------------------------------------- init
buildLevel(1);
resetPaddle();
resetBall();
// physics tuning: balls fall off the bottom -> lose life, respawn
requestAnimationFrame(function loop0(t){
lastT = t;
requestAnimationFrame(loop);
});
})();
</script>
</body>
</html>Compare
Other runs



- Solar Mini 4.5, Logo: Not run yet
- 153words