The Galaxians project is an attempt to recreate the old-school space shooter Galaxians within a time limit of 1 week. The goal of making this game was to dissect and recreate a similar game and try to apply the techniques learned so far when applicable.
I let “stars” move from the top of the screen to the bottom I create the illusion of forward movement and I added a second layer of depth by giving the stars different speeds making it look they are further away from the player.
The player and hostile ships are within a fixed world shape which allowed me to create a grid for the movement and positioning.
For collision I used 2D Rectangle collision to check for bullet impact and player impact with the ships.
The player has a limited space of navigation and can move in all 2D directions.
For the enemies I had 2 challenges:
- Arc movement when charging in
- Squadrons (the yellow and red ships)
I solved the charging by dividing the world in half to determine which direction the arc should go and I set a certain radius the ship could arc and do a half circular movement once the ship finished half the circle I change it movements to go directly at the player’s position from that point in time.
I solved the squadrons by giving a cross-reference between the red and yellow ships. This way the yellow ships knew which ships to pull with him and the red ships if they could go solo if the commander had died.
The entire collection of enemies is set within a grid that moves left to right. By remembering the grid position I could let the ships return to their original position.
Once I was done with the main game I implemented a progression system. You can complete the level and continue with a new one until you were defeated (the flags are levels). And I added some menu’s for extra clarity.
I also integrated SDL_Mixer to be able to play some background music.