Creating an arcade-style shooting game is a fun project to help you improve your Python and PyGame programming skills.
We just published a course on the freeCodeCamp.org YouTube channel that will teach you how to create a fun game using Python and PyGame.
Pete LeMaster created this course. Pete is a control systems engineer and creator of the LeMaster Tech YouTube channel.
This project was inspired by the classic carnival/arcade style shooting gallery games! You will learn to build the entire project from scratch using Python and the PyGame framework.
We start by setting up PyGame, and drawing static images on the screen. Then we animate tiers of procedurally drawn enemies onto each level and get them moving, then check to see if the player has shot them. Once the player clears a full level of enemies, they proceed to the next level. Then we create pause functionality, a main menu and game over conditions.
We store the high scores in an external text file that we read in from when the game boots up and write to it any time there is a new high score during gameplay.
Here are the sections in this course:
- Project Showcase
- Setting Up Pygame And Importing Images
- Drawing the Gun and Rotating With Mouse Position
- Drawing Enemies Onto the Screen
- Procedurally Generate Enemy Starting Coordinates
- Make Enemies Move With Speed Based on Tiers
- Check for Mouse Collision with Targets on Shots
- Display Score, Mode Status, Time Elapsed and Total Shots!
- Menu Control and Setup
- Pause Menu and Restarting from the Game Screens
- Re-Initializing Enemy Coordinates on Restart
- Game Over Conditions!
- Reading and Writing to a .txt Text file for high scores!
- Adding Background Music and Sound Effects!
Watch the full course below or on the freeCodeCamp.org YouTube channel (2-hour watch).