📂 The Stage 2 Files
Stage 2 is a refactoring stage: the bomb looks exactly the same as Stage 1 (click “Stage 1” in the card footer to compare), but every line of code has been improved. Three files make up the complete Stage 2 build:
| File | What it does | Stage 2 changes |
|---|---|---|
bombStg2.html |
HTML shell — loads p5js, CSS, and the sketch | File header added; stylesheet pointer updated |
bombStg2Sketch.js |
The p5.js sketch — all the drawing logic | Full TNT overhaul (see Laundry List) |
bombStg2Styles.css |
Minimal CSS reset — canvas flush, no margin | File header added; WHY: comments added |
fetch(url).then(r => r.text()).
That’s one of the cleanest patterns in modern web development.
📜 Source Code
Loading bombStg2.html…
Loading bombStg2Sketch.js…
Loading bombStg2Styles.css…
💪 Try It Yourself
Use the Copy button above to grab any file, then:
- Create a new project folder with the same sub-folders (
sketches/,styles/). - Paste each file into VS Code and save it with the matching filename.
- Open
bombStg2.htmlin your browser — you should see Crosby's bomb! -
Pick one constant to change — try doubling
PARTICLE_COUNTor halvingPARTICLE_SPEED_MAX— and observe the effect. -
Challenge: add a
bombVisibleboolean flag and make the bomb disappear when you click. Hint: the Saga Index gives you a spoiler!
⚠️ The Copy button requires a secure context
(https:// or localhost). If you’re viewing this file directly
from your file system (file://), right-click the
Run link above and choose “View Page Source” instead.