top of page
Ascii Invaders
A SFML based 2D c++ game
In the above images, you can see a main menu, game over screen, and main gameplay state. These were the 3 game states that I used for this project.
The menu and game over screen use very similar code as they both have a title and menu options that a pointer must choose between. I had an input double fire or triple fire issue for a while. I was trying to get the pointer to work for the 3 options without it skipping the middle button. I tried to implement a time delay for the keyboard input to affect the pointer's position but it made the system feel clunky as it often led to 2 accurate inputs being stopped as the timer had not ended. I ended up using another variable to track within the if statements to stop it from skipping.
For the main game state, I created a basic player character which can only move up and down similar to the original space invaders which could only move left and right. I added limits to the top and bottom of the screen to stop the ship from clipping out of the viewable window. I added the UI in the top left to have a score and a health bar using animated sprites for both. This helps show the player exactly how they are doing and the multiple lives makes the game easier for the player as it allows mistakes without ending the game.
The enemy is an animated sprite that gets generated randomly off screen on the right before coming towards the left. If any reach the left hand side, the player loses a life. Killing an enemy spawns an explosion animated non looping sprite and then hides both but does not fully remove the enemy from memory.If I was to improve the game, I would start by creating a destructor for the enemy class to avoid a memory leak
bottom of page