Video Tutorial: A Simple Python Turtle Graphics Game

Simple Python Turtle Graphics GameSeymour Papert and his colleagues invented the programming language Logo back in 1967. Generations of schoolchildren learned to move a little graphical turtle around their computer screens in order to learn the basic concepts behind coding. Python, an excellent programming language for beginners, includes a wonderful turtle graphics module that can be used to program any number of simple computer games.  

In this video tutorial series, I will walk you through all the steps necessary to put some turtles on the screen and make a simple, yet fun little game out of them.  

Note: This tutorial was written in Python 2.7 on a Mac - the code (except for the code that plays a sound) should work fine on other platforms as well using the standard Python modules.

The Game

In this game, players are in control of a spaceship inside of an arena of unknown origin.  Also trapped inside the arena are mysterious alien orbs (your goals) that fly around at random.  The player's job is to fly around and touch as many of the orbs as possible. When an orb is touched, it disappears and reappears at a random position in the arena. The commands are simple, the left arrow key rotates the ship left, the right arrow key rotates the ship right, and the up key accelerates. 

The Tutorial

The tutorial is broken down into a number of video files which are hosted on YouTube.  Click the links below to view the tutorials.

Part 1: Getting started / Creating the Turtle Window / Creating your first turtle / Main Game Loop / Move the turtle 

Part 2: Keyboard binding / Turning the turtle

Part 3: Drawing the arena border / Boundary checking for the player

Part 4: Creating a goal (orb) / Basic collision checking

Part 5: Collision checking using a function

Part 6: Moving the goal / Boundary checking for the goal

Part 7: Making multiple goals / Collision checking / Boundary checking

Part 8: Loading a background image / Adding sound (Sorry, Mac only for now.)

Part 9: Keeping track of the score / Drawing the score on the screen

You can download the source code and image and sound files here.

This is still a work in progress - stay tuned for updates.  Feel free to comment below or to follow me on Twitter (@tokyoedtech).

Comments

Python problem

Hello

I visit your website. It’s very useful for me. You explain everything very beautiful. I hope you continue these tutorials.

Now I have a problem. I want to write a program to show windscreen wiper or windows pinball game. My main problem is that I want to create two lines that moves concurrently. And only with turtle graphics, without using threads, tkinter or pygame, ….

Would you please help me?

 

Best Regards

N.R.

Thanks a lot for your nice tutorials

Hello 

I visit your website. It's very useful for me and I learn many good points. Thank you very much and I hope I see new tutorials from you.

Would you please teach about creating custom shapes with turtle and make an animation with them. I have a problem with this. For example create two parallel lines that turns concurrently.

 

Best Regards

Negin from Iran

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.

@TokyoEdTech

Poll

What LMS does your school use?: