1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1" />
6 <title>Neon Breakout Tests</title>
7 <style>
8 body { background:#080812; color:#dff; font-family:monospace; padding:24px; }
9 pre { border:1px solid #28f7ff; padding:16px; box-shadow:0 0 12px #28f7ff55; white-space:pre-wrap; }
10 </style>
11</head>
12<body>
13 <h1>Neon Breakout Core Tests</h1>
14 <pre id="out">Open the browser console or run: node tests.js</pre>
15 <script src="game.js"></script>
16 <script>
17 const out = document.getElementById('out');
18 function assert(cond, msg) { if (!cond) throw new Error(msg || 'assertion failed'); }
19 const c = window.BreakoutCore;
20 const results = [];
21 function run(name, fn) { try { fn(); results.push('✓ ' + name); } catch (e) { results.push('✗ ' + name + ': ' + e.message); throw e; } }
22 run('circleRectCollision overlap', () => assert(c.circleRectCollision({x:12,y:12,r:5},{x:10,y:10,w:20,h:20})));
23 run('paddle reflection upward', () => { const s=c.createState(); s.ball.vy=200; s.ball.x=s.paddle.x+s.paddle.w; c.reflectFromPaddle(s.ball,s.paddle); assert(s.ball.vy<0); });
24 run('brick collision scores', () => { const s=c.createState(); s.paused=false; s.ball.stuck=false; const b=s.bricks[0]; s.ball.x=b.x+b.w/2; s.ball.y=b.y-s.ball.r+1; s.ball.vy=200; c.step(s,.016,{move:0}); assert(!b.alive && s.score>0); });
25 out.textContent = results.join('\n') + '\nBrowser smoke tests passed.';
26 </script>
27</body>
28</html>
29
Discussion
No comments yet. Start the discussion. Recorded by @patrick-toulme.