NEW PROJECT – Asteroids

Category: | Posted on:January 9, 2025
asteroids

Asteroids is a bare-bones facsimile of the classic arcade game of the same name.

Objective

I want to focus on more creative projects this year in order to break up the grind of work skill development. I’ve always been passionate about game design, and there are a lot of free tools to chose from. My intent is to start with some JavaScript-based browser projects because that’s my wheelhouse. I’ve heard of cases where web-based games could be distributed as executables via Electron beyond the usual browser distribution too. It’s an opportunity to do more of the object-oriented programming that I don’t get from WordPress development.

Development

My experience with the JavaScript Canvas API is nonexistent, so I started from a Net Ninja tutorial to get a feel for the process. That series helped to establish the basics of drawing simple shapes in Canvas, moving them around and colliding them.

From there I added a variety of enhancements on my own.

  • Border detection for the player character
  • A Game Over screen with reset
  • A score system
  • Variable speeds and point values for different sized asteroids
  • A timer that gradually increases the spawn rate for the asteroids
  • Asteroid splitting on impact
  • Simple fun color effects for all of the objects
  • Refactored some of the tutorial code into new functions to eliminate repetition in some places.

Hurdles

My high school trigonometry is very rusty. Fortunately I remember my Pythagorean theorem, which is the key to finding collision distances in a 2D game like this. The tutorial did a lot of the heavy lifting for me in the math department, since this was a first go, but I’d like to try it more freehand on my next project.

Another issue is collision detection for polygonal objects. Getting a triangle to know it collided with a circle required an external library with a lot of math. This might be okay. My aim is programming, not computer graphics design. For this reason, the game lacks the special graphical effects of the original game. I’m not drawing all those asteroid bits breaking apart.

Takeaways

This is a project I can definitely come back to after I’ve gained more experience with Canvas. Some additional features I’d like to add are diagonal paths for the asteroids, and multiple lives for the player.

Related Logs


  • NEW PROJECT – Centipede

    February 13, 2025

    CentipedeĀ is a bare-bones facsimile of the classic arcade game of the same name. Objective Continuing my exploration of Game Development with the Javascript Canvas API, I moved onto Centipede mostly by accident. Once again I avoided tutorials in order to try and work through the logic myself. The key goal with this game was handling […]

    Continue Reading
  • UPDATE – Space Invaders

    January 28, 2025

    Quick presentational update to the Space Invaders project. Keep Shields Centered On Hit Shields will now automatically maintain a centered position when hit my an alien missile. I initially thought this was going to involve some math to determine whether the missile hit on the right or left side. I even put together a formula […]

    Continue Reading
  • NEW PROJECT – Space Invaders

    January 27, 2025

    Space Invaders is a bare-bones facsimile of the classic arcade game of the same name. Objective I wanted to take what I learned from the Asteroids Tutorial in my last project and iterate without the training wheels this time. Space Invaders has more lateral movement from the player and hostiles than in Asteroids, and has […]

    Continue Reading