In this lesson, we will walk through the Pygame library and setup the foundation for the Pygame project and eventually build a Space Shooter game.
The main program loop will contain 3 main sections:
Type the code as follows:
To begin with, we're going to make a simple pygame program that does nothing but open a window and run a game loop.
Here is our game loop, which is a while loop controlled by the variable running. If we ever want the game to end, we just have to set running to False and the loop will end.
This would work for background color or any other pictures that you want to display on the screen.
Next in the game logic scetion we will add following :
Full code so far should be following:
To add and display score we will use a pre-defined function display_score() Every time bullet hot he enemy we inscrease score by 1
Don't forget to save your work. Click the Save button or Remix to save to your account.
The gamess final code should look like this:
You have completed this project.