Snake game in Python: use Pygame to build your game

Offered By
Coursera Project Network
In this Guided Project, you will:

Learn pygame library and its different modules and functions.

Apply programming techniques in game development.

Clock1 hour 40 minutes
IntermediateIntermediate
CloudNo download needed
VideoSplit-screen video
Comment DotsEnglish
LaptopDesktop only

In this 1-hour long project-based course, you will be able to create the famous snake game using Python and Pygame modules, also you will be able to identify most of the objects and functions in the pygame library that will help you to build your own game projects. This includes applying draw, time, and display modules, handling different types of events, and defining functions for completing the game logic. Python language is one of the most accessible programming languages available because of Its simplified syntax that gives emphasis on natural language. Python and Pygame are good languages and framework for rapid game prototyping or for beginners learning how to make simple games. Note: This project works best for learners who are based in the North America region. We’re currently working on providing the same experience in other regions.

Skills you will develop

Video Game DevelopmentPygame libraryPython ProgrammingPygameGame Programming

Learn step-by-step

In a video that plays in a split-screen with your work area, your instructor will walk you through these steps:

  1. By the end of Task 1, you will be able to initiate Pygame and create the first game screen.

  2. By the end of Task 2, you will be able to create RGB colors to draw rectangles and change the desktop background color.

  3. By the end of Task 3, you will be able to handle key down events, and apply the time module for controlling the snake speed.

  4. By the end of Task 4, you will be able to use if conditions for controlling the game logic and define the game_loop function.

  5. By the end of Task 5, you will be able to use different font functions to show messages on the screen, and use the random library to create food objects.

  6. By the end of Task 6, you will be able to use lists and logics to increase the length of the snake when eating the food.

  7. By the end of Task 7, you will be able to display the score on the screen, finalize the game logic, and implement the full generic game code.

How Guided Projects work

Your workspace is a cloud desktop right in your browser, no download required

In a split-screen video, your instructor guides you step-by-step

Frequently asked questions

Frequently Asked Questions

More questions? Visit the Learner Help Center.