Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Make a 2D Side-Scroller Game With PyGame (Summary)

In this course, you learned how game programming with pygame differs from standard procedural programming. You also learned how to:

  • Implement event loops
  • Draw items on the screen
  • Play sound effects and music
  • Handle user input

To do this, you used a subset of the pygame modules, including the display, mixer and music, time, image, event, and key modules. You also used several pygame classes, including Rect, Surface, Sound, and Sprite. But these only scratch the surface of what pygame can do! Check out the official pygame documentation for a full list of available modules and classes.

Download

Sample Code (.zip)

422.6 KB
Download

Course Slides (.pdf)

7.6 MB

00:00 This lesson is a conclusion and course review. Hey, congratulations! You completed the course. I’m going to take you through all that you’ve covered in PyGame throughout this course. We started with that intro and overview, then you learned a little background on PyGame and how to set it up on your machine.

00:20 You created a basic PyGame program.

00:27 Then ending Section 1, you covered some of the fundamental concepts of PyGame. Section 2 started with a discussion about what sort of game you’re building for this tutorial.

00:44 Then you started to build the code for the tutorial game, with importing and initializing pygame.

00:54 After that, you started setting up the display.

01:01 You learned the aspects of creating a game loop and what goes inside of it.

01:10 You covered drawing on the screen. In the next lesson, to wrap up Section 2, you learned about using .blit() and .flip() to make things display on that screen you created. Then it was into Section 3, where you started working with sprites, and the first lesson was all about creating those sprites, then you created the sprite for the player.

01:34 The next lesson was all about user input and controlling the player… which led to how to keep the player’s sprite on the screen. Then you created a class for all those enemies.

01:54 You learned about sprite groups to control and update all those sprites together. Then you were back in the event loop and learning about creating custom events.

02:09 The next lesson was a crucial one for any video game: collision detection. Then you started to add images to your sprites, and after that, a lesson on adding background images.

02:29 In Section 4, you started to really enhance the game by learning how to control the game’s speed. Then you added music. Next, you loaded up sound effects and added them to events so that they can be triggered.

02:52 After that, it was a quick discussion on resources and places you can find additional content and the licenses that you need to pay attention to if you use them in your own game. And, of course, this conclusion.

03:05 I want to thank you for watching. Make sure that you take time to practice with what you’ve learned. Thanks again, and hope to see you in another course soon!

Avatar image for sumakolurmath

sumakolurmath on March 27, 2020

Thanks Chris, for the awesome course!

Avatar image for David Wright

David Wright on April 26, 2020

Thank you Chris for a great course. I think I have found what I want to do with my Python knowledge.

Avatar image for mikesult

mikesult on May 4, 2020

Thanks Chris, Excellent course. You covered so many of the elements in a nice incremental way and always kept a working program at all stages.

One strange behavior for me was when loading the sprite images of the jet and missile, if I used the .convert() method then the .set_colorkey() method on the next line didn’t create the desired transparency. If I removed the .convert() method then the .set_colorkey() method did work. The cloud sprite worked fine when using the .convert() method. Very strange.

I learned a lot, thanks!

Avatar image for jamesbrown68

jamesbrown68 on July 22, 2020

Thanks. This was fun. I struggled a bit here and there, but I learned some new things.

Avatar image for Nick M

Nick M on April 17, 2021

That was a wicked fun course. Loved it. Learned tons and really made me value the idea of libraries of functions and object orientation. I’m remembering back to my early coding days (80s, 90s) with BBC Basic or Pascal and back then I’d have had to manage so many more things by hand. This is sooooooo much easier.

Very well done course that I really enjoyed. Thanks!

Avatar image for AntonB

AntonB on May 29, 2023

Thanks Chris! Really enjoyed the tutorial and learned a lot that has generated a lot of ideas that I will use in Space Rocks Strike Back!

Avatar image for JCode888

JCode888 on Oct. 21, 2023

Thanks Chris! That was a great tutorial! Time to try and figure out how to make my ship shoot and destroy the missiles!

Become a Member to join the conversation.