Arcade shooters depend on fast movement and a lot of objects on screen at once, so I built this one entirely on a single canvas.
Use ARROWS to Move • SPACE to Fire
1. The Vector Engine (Velocity & Inertia)
Unlike platformers, which rely on constant gravity, my space shooter uses frictionless traversal. Bullets, asteroids, and enemy drones track separate coordinates and delta increments per axis. For explosions, I use an array of particles, each randomly assigned a trajectory and life counter, slowly decaying in global opacity to simulate fading light.
2. Radial Object Collision (Pythagorean Theorem)
While platforms use square bounding boxes (AABB), fast-moving circular objects like lasers and asteroids use radial collision detection. Instead of checking rectangle edges, I continuously calculate the hypotenuse distance between object centers using Math.hypot(x2-x1, y2-y1). If the distance falls below the combined radius threshold, the hit handler fires instantly.
3. Performance Scaling & Object Cleanup
Every laser fired and particle emitted is added to active arrays. To keep the game performing as well at 5 minutes as it did at 5 seconds, I run rigorous collection cycles, deleting any object that drifts past the visual canvas parameters (b.y < 0) directly from memory.