Game · project 09 of 19
Buzz-wire lab.
The steady-hand wire game, in your browser.
How to use it
- Pick Easy, Medium or Hard and press Start game.
- Drag the dot along the wire with a finger or the mouse. Touch the edge and you go back to the last safe point.
- Turn the sound on for the buzz. Arrow keys work too.
Where it helps most
- A two-minute break.
- A first game to build with AI: small, visual, and easy to tell when it works.
- Teaching kids how a path, a hit test and a timer make a game.
The idea
The classic buzz-wire game is a DIY electronics project: a wire loop, a steady hand, a buzzer. I wanted the same tension in a browser so anyone could play it with a finger or a mouse.
The build
Claude built it with SVG paths and pointer capture: drag the dot along the wire, miss and you are sent back to the last safe point with an optional buzz from the Web Audio API, three difficulty levels, a timer, and keyboard play. Deployed on sghadimi.com.
Free to take
Build your own.
Copy the skill, paste it into your own AI, and say what you want different. How to use a skill, step by step ›
Get the skillThe instructions your AI follows. Works in Claude, ChatGPT, Gemini or any other
Build a browser version of the 'buzz wire' steady-hand game in a single HTML file.
- Draw the wire as an SVG path inside an 800×440 viewBox, with a wide translucent 'safe zone' stroke behind a thin guide line. Start circle on the left, star finish on the right.
- Three levels (easy, medium, hard) are three different path strings; harder ones have tighter curves.
- Press Start, then drag the white handle. Use pointer events with setPointerCapture so it works for mouse, pen and touch.
- Project the pointer onto the path (sample getPointAtLength) and only let the handle move forward along it. If the pointer strays more than the safe-zone half-width from the path, count a 'touch', stop dragging, and resume from the last safe point.
- Draw completed progress as a green overlay using stroke-dasharray.
- Show time (0.1 s), touches, level and a result message (Perfect / Nice work / Finished).
- Optional sound toggle: a short square-wave buzz with the Web Audio API on each touch.
- Keyboard alternative: ArrowRight advances carefully.
No libraries, no network, mobile friendly.
Get the code2 files, exactly as they run on this site
game logic (app.js)47 lines
// 03 BUZZ WIRE — playable pointer/keyboard precision game.
const gamePaths={easy:'M75 270 C200 270 245 270 370 270 S610 270 722 270',medium:'M75 278 C165 282 127 133 258 165 S375 377 481 293 S608 128 722 254',hard:'M75 295 C183 320 95 107 253 120 S370 397 462 304 S511 75 624 161 S665 324 722 238'};
function initBuzz(){
const svg=$('#game-svg'),guide=$('#game-guide'),wide=$('#game-wide'),progress=$('#game-completed');
let level='easy',running=false,dragging=false,position=0,misses=0,started=0,elapsed=0,pointerID=null,sound=false,audioCtx=null;
let interval=null;
const path=()=>guide;
const total=()=>path().getTotalLength();
function xy(frac){return path().getPointAtLength(Math.max(0,Math.min(1,frac))*total());}
function pointFromEvent(ev){const c=svg.createSVGPoint();c.x=ev.clientX;c.y=ev.clientY;return c.matrixTransform(svg.getScreenCTM().inverse());}
function place(){const p=xy(position);for(const sel of ['#game-handle','#game-handle-glow']){$(sel).setAttribute('cx',p.x);$(sel).setAttribute('cy',p.y);}$('#game-progress').textContent=Math.round(position*100)+'% complete';const len=Math.max(.1,position*total());progress.setAttribute('d',guide.getAttribute('d'));progress.style.strokeDasharray=`${len} ${total()+1}`;}
function setState(v){setText('#buzz-state',v);}
function paintLevel(){
const d=gamePaths[level];guide.setAttribute('d',d);wide.setAttribute('d',d);progress.setAttribute('d',d);
const origin=xy(0),end=xy(1);
$('#game-origin').setAttribute('cx',origin.x);$('#game-origin').setAttribute('cy',origin.y);
$('#game-finish').setAttribute('cx',end.x);$('#game-finish').setAttribute('cy',end.y);
$('#game-star').setAttribute('x',end.x);$('#game-star').setAttribute('y',end.y);
$('#game-level').textContent=String(['easy','medium','hard'].indexOf(level)+1)+' / 3';place();
}
function stopTimer(){if(interval!==null){clearInterval(interval);interval=null;}}
function updateTime(){if(running)elapsed=(performance.now()-started)/1000;setText('#game-time',elapsed.toFixed(1)+'s');}
function start(){svg.scrollIntoView({block:'center',behavior:'instant'});stopTimer();running=true;dragging=false;position=0;misses=0;elapsed=0;started=performance.now();setText('#game-misses','0');setText('#game-result','—');setState('GRAB THE WHITE DOT TO BEGIN');place();updateTime();interval=setInterval(updateTime,100);}
function finish(){running=false;dragging=false;stopTimer();updateTime();setText('#game-result',misses===0?'Perfect!':misses<=3?'Nice work!':'Finished');setState('CIRCUIT COMPLETE ✓');}
function reset(){running=false;dragging=false;stopTimer();position=0;misses=0;elapsed=0;setText('#game-time','0.0s');setText('#game-misses','0');setText('#game-result','—');setState('CHOOSE LEVEL · PRESS START');place();}
function penalty(){dragging=false;misses++;setText('#game-misses',misses);setState('TOUCH! GRAB THE DOT TO RESUME');if(sound){try{audioCtx ||=new (window.AudioContext||window.webkitAudioContext)();const osc=audioCtx.createOscillator(),gain=audioCtx.createGain();osc.type='square';osc.frequency.value=190;gain.gain.setValueAtTime(.025,audioCtx.currentTime);gain.gain.exponentialRampToValueAtTime(.001,audioCtx.currentTime+.13);osc.connect(gain).connect(audioCtx.destination);osc.start();osc.stop(audioCtx.currentTime+.14);}catch(_){}}}
function pointerDown(e){if(!running)return;const p=pointFromEvent(e),h=xy(position);if(Math.hypot(p.x-h.x,p.y-h.y)>55)return;dragging=true;pointerID=e.pointerId;svg.setPointerCapture(e.pointerId);e.preventDefault();setState('STAY ON THE GUIDE');}
function pointerMove(e){if(!running||!dragging||e.pointerId!==pointerID)return;
const p=pointFromEvent(e),current=position;let best={dist:Infinity,pos:current};
// Look ahead a bounded distance, so visitors cannot teleport to the finish.
for(let i=0;i<=35;i++){const frac=Math.min(1,current+i*.004);const q=xy(frac),dist=Math.hypot(q.x-p.x,q.y-p.y);if(dist<best.dist)best={dist,pos:frac};}
const tolerance={easy:44,medium:36,hard:29}[level];
if(best.dist>tolerance){penalty();return;}
position=Math.max(position,best.pos);place();if(position>=.994)finish();
}
function pointerUp(e){if(e.pointerId===pointerID){dragging=false;pointerID=null;}}
svg.addEventListener('pointerdown',pointerDown);svg.addEventListener('pointermove',pointerMove);
svg.addEventListener('pointerup',pointerUp);svg.addEventListener('pointercancel',pointerUp);
// Accessible alternative: advance carefully by arrow key.
svg.setAttribute('tabindex','0');
svg.addEventListener('keydown',e=>{if(!running)return;if(e.key==='ArrowRight'){position=Math.min(1,position+.027);place();if(position>=.994)finish();e.preventDefault();}});
$('#buzz-start').addEventListener('click',start);$('#buzz-reset').addEventListener('click',reset);
$('#buzz-sound').addEventListener('click',e=>{sound=!sound;e.currentTarget.setAttribute('aria-pressed',String(sound));e.currentTarget.textContent=sound?'Sound on ◉':'Sound off ◌';});
$$('[data-level]').forEach(b=>b.addEventListener('click',()=>{level=b.dataset.level;$$('[data-level]').forEach(x=>x.setAttribute('aria-pressed',String(x===b)));reset();paintLevel();}));
watch(()=>{stopTimer();audioCtx?.close();});paintLevel();
}
markup (index.html)2 lines
<template id="tpl-buzz"><div class="workspace-head buzz-head"><div><span class="overline">PLAYGROUND / 03</span><h1>Buzz-wire lab<span class="gold-point">.</span></h1><p>Trace the circuit. Stay on the path.</p></div><span class="workspace-status">PLAYABLE PROTOTYPE</span></div><div class="buzz-workspace"><div class="buzz-toolbar"><div class="toolbar-field"><span class="toolbar-label">DIFFICULTY</span><div class="segmented levels"><button type="button" data-level="easy" aria-pressed="true">Easy</button><button type="button" data-level="medium" aria-pressed="false">Medium</button><button type="button" data-level="hard" aria-pressed="false">Hard</button></div></div><div class="buzz-actions"><button type="button" id="buzz-start" class="primary-action">Start game ↗</button><button type="button" id="buzz-reset">Reset</button><button type="button" id="buzz-sound" aria-pressed="false">Sound off ◌</button></div></div><div class="game-card"><div class="game-top"><span id="buzz-state" role="status">CHOOSE LEVEL · PRESS START</span><span>START ● → FINISH ★</span></div><svg id="game-svg" viewBox="0 0 800 440" role="img" aria-label="Playable precision path: start at the circle on the left, drag along the track to the star at the right"><defs><filter id="game-glow"><feGaussianBlur stdDeviation="6"/></filter></defs><rect x="0" y="0" width="800" height="440" rx="28" fill="#1d2531"/><g stroke="#536273" stroke-opacity=".18"><path d="M0 70H800M0 140H800M0 210H800M0 280H800M0 350H800M100 0V440M200 0V440M300 0V440M400 0V440M500 0V440M600 0V440M700 0V440"/></g><path id="game-wide" fill="none" stroke="#fbba87" stroke-opacity=".17" stroke-width="35" stroke-linecap="round"/><path id="game-guide" fill="none" stroke="#f1a77c" stroke-width="5" stroke-linecap="round"/><path id="game-completed" fill="none" stroke="#bbffbc" stroke-width="6" stroke-linecap="round"/><circle id="game-origin" r="19" fill="#c6ffc9" stroke="#fff" stroke-width="4"/><circle id="game-finish" r="23" fill="#f9bf6a" stroke="#fff" stroke-width="3"/><text id="game-star" font-size="22" font-weight="800" fill="#342d30" text-anchor="middle" dominant-baseline="central">★</text><circle id="game-handle" r="15" fill="#fff" stroke="#abebaf" stroke-width="5"/><circle id="game-handle-glow" r="28" fill="none" stroke="#a4ffa7" stroke-width="2" stroke-opacity=".5"/></svg><div class="game-bottom"><span>PRESS START, THEN DRAG THE WHITE DOT</span><span id="game-progress">0% complete</span></div></div><div class="game-stats"><div><span>TIME</span><strong id="game-time">0.0s</strong></div><div><span>TOUCHES / MISSES</span><strong id="game-misses">0</strong></div><div><span>LEVEL</span><strong id="game-level">1 / 3</strong></div><div><span>RESULT</span><strong id="game-result">—</strong></div></div><div class="game-instructions"><strong>THE CHALLENGE</strong><p>Drag the white dot from start to finish without leaving the highlighted wire. If you stray, you get a touch penalty and resume from the last safe point. A digital skill game inspired by the DIY electronics project—not a connected hardware device.</p></div></div></template>
Have an idea of your own?
Look around your day, find the thing that wastes your time, and build the fix. Everything here is free to help you start. If you would rather I built it, or you just want to talk an idea through, write to me.