A clean and simple HTML Canvas physics simulation written in pure JavaScript.
Multiple balls fall with gravity, collide realistically, slide with friction, display their velocity as arrows, and increment a live collision counter.
- Gravity-based movement
- Realistic elastic collisions (with friction and impulse)
- Velocity arrow visualization
- Live collision counter
- Ball spawning system
- Reset function
- 100% Vanilla JavaScript, no external libraries
- spawnBall() – spawns a new ball
- resetAll() – clears all balls and resets the collision counter
Useful for learning and experimenting with:
- 2D vector math
- Collision detection and resolution
- Impulse and friction simulation
- Canvas rendering
- Basic game-physics systems