Categories
Game Development

Space Invaders Clone Progress: Finding My Way

I’ve been reading through the source code of a number of games, and I’ve been picking up some good ideas.

Specifically, I had been struggling with the idea of retrofitting a menu system to a finished game. I hadn’t been focused on the task (as I need a finished game first), but I had a vague idea that I would need to design the menu system and run it separately from the game loop. Interestingly enough, I found that a number of games have the menu system as part of the main loop! I was a bit confused by it at first, but apparently the game is paused for one reason or another, and the menu system has its own update() function that gets called if it is active. It seems fairly easy to implement, and there are plenty of code examples for menu system implementations out there.

I now feel more confident that I can leave the menu system to a later time, allowing me to focus on finishing Space Invaders. I have since added functionality to allow the aliens to move down the screen in formation, and once an alien hits the player’s ship, the alien is destroyed, and the player’s ship becomes invisible.

It becomes invisible because I have yet to actually define what it means for the ship to be destroyed. Technically you can still shoot and move the ship. You just can’t see it. To really destroy it, I will need a way to disable the player’s input, and I will also need a way to restore the ship after a few seconds.

Explosion effects would help, too. B-) Currently, the alien and the ship simply disappear when “destroyed”, although the alien sprite really does disappear for all intents and purposes. I am still making small changes, and being very careful with new ideas I come up with. I write them down and put them away, ready for v2.0’s development. I just want to finish v1.0 as quickly as I can.

At one point, I felt stuck. I didn’t know how to proceed, and I found myself sitting in front of the code without any real reason. I stopped, took out some notecards, and came up with a few scenarios. I basically wanted to determine what should happen in specific situations.

For example, what happens when an alien touches the player’s ship? Well, the alien and the player’s ship both get destroyed.

What happens when the alien gets destroyed? Well, some explosion animation should occur, the alien should be removed from the list of active aliens, and if it was the last alien, then the next level should start.

What happens when the player’s ship gets destroyed? What should happen when the game starts up for the first time? What happens if there is no player ship on the screen? What happens if the player has no ships left? What happens if the alien reaches the ground?

Answering each of these questions helps me to see what functionality is missing. I still need animations for the explosions, I think I may make use of a timer for the player’s ship to get restored, and I still need to add some font to display text such as “Game Over” and “Start Game”.

It is amazing how clear everything becomes when you stop and think, “What will happen in this specific circumstance?”