About this simulation
This simulation involves interactions between four kinds of Molecools — the TNT name for particle objects that move, collide, and interact with one another:
- Beige Humans wander around aimlessly, bouncing off each other with elastic (momentum-conserving) collisions.
- Blue White Witch moves intentionally; any Human she touches is frozen into a gray Statue.
- Orange Aslan pursues the nearest Statue and frees it back into a Human on contact. He turns red whenever any Statues exist.
- Gray Statues are frozen Humans — immobile until Aslan reaches them.
All non-Statue interactions conserve momentum elastically.
This is Stage 10 — the ES6 class syntax upgrade.
Stage 8 behavior is preserved exactly; the improvement is internal:
Grid and Molecool are now true ES6
class declarations with a constructor()
method and class-body methods, ready for Stage 11 inheritance.
- Left Click Start or pause the simulation
- Right Click Add a Human at the click position (up to max population of 10)
- Slider Adjust the frame rate (15–60 fps)
- Save Image Download the current canvas frame as a PNG file
Right-click adds Humans only after starting and while paused.
Stage 10 converts Grid
and Molecool from
pre-ES6 constructor functions to true ES6
class declarations.
The simulation behavior is identical to Stage 8; the change is
structural: methods are now defined in the class body and shared
via the prototype, not re-created on every new call.
Stage 8 encapsulation improvements are fully preserved.
Teaching concept: ES6 class syntax
— modern JavaScript classes are prototype-based under the hood
(same as Stage 8), but the class
keyword makes the programmer’s intent explicit and lays the
structural foundation for Stage 11 inheritance.