Making a video game

For this assignment, I chose to create a remake of the space invaders video game using Microsoft Visual Studio. I used the software library Allegro to help me develop the 2d game. For me, this project was relatively simple because I am a comp sci major and I’ve been making video games for fun since I was in high school. The entire game was built from scratch using C++ code.

This is what the beginning screen of the game looks like when you launch it. The controls of the game are similar to the original space invaders game with the user using left and right arrow keys to move right and left and pressing space to shoot the cannon laser. There are three levels in total and with each level increases the speed of the aliens.

This is what the game looks like when you start it. You are the green cannon at the bottom of the screen and the red aliens falling are the enemies. Your task is to move directly under each enemy and shoot them with your cannon. If the enemy reaches the bottom before you kill it, you lose a life. If you lose all three lives, you will get a screen that looks like this.

It will tell you your final score, which is the number of enemies you killed, and the level you reached. If you manage to beat each level and win the game, you will get a screen that looks like this.

Again, it will tell you your final score and instead of saying game over, it will give you a congrats message on beating the game.

Below you will be able to find some screenshots of what the code I wrote to create this game looks like. Overall, it was a bit over 500 lines of code, including empty lines and comments.

This is the Aliens header file, which is the class where I defined the alien object’s functions and variables. The bullet class and player class are very similar looking to this, with the main differences being what is written in the functions in the .cpp files, which is where the source code for the functions in the header are written out.

This is the primary class where the main function is located. Here I created the display, which was an 800 by 650 pixels black display. I created a fps timer to render the game at a smooth and consistent 60 fps. I loaded in audio for the game that is triggered with different actions, such as shooting, losing a life, and killing an enemy. I created a loop to enter the game and remain in the game until the player loses all lives or wins the game.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.