I decided that I wanted to delve into some game development. Having never developed a game before, I needed to start with the basics. I decided that I would create my own Asteroids clone.
I started out by researching some examples, the best of which I found is A Guide to Programming Asteroids as a Java Applet By Brandon Carroll. After reading half of this guide, I was able create my own version (I always feel like I’m cheating when using guides).
The biggest issue I came across was null pointers, specifically the integer arrays for drawing the ship. They were originally initialized in the constructor, but I had to use field level initialization. Another other interesting bug was when the game was paused and the window was re-sized (forced to repaint), the moving space objects would move. This was caused by the fact that I called the objects move method before I called it’s draw method. I ended up added a simple check to see if the moving space object is active before calling the move method.
One of the most interesting topics of game development, I feel is object collision detection. This game uses simple collision detection utilizing radii for each object. Basically for every frame, we need to check every space object in the world, against the other space objects checking if the distance > the sum of the radii. If the check returns true, then there was a collision.
After roughly 8-10 hours of research and development I have finished version 0.0.1 of my clone. Its not perfect, how ever its a mostly working, playable version.
It has been an interesting learning experience, and I will continue to build upon on this simple game, to continue my learning experience experience.
You can download a working copy of my clone for free here and the source code can be found here. Please keep in mind that this is only version 0.0.1 and there may be some bugs, or incomplete features.