Tron Classic Arcade Game in Python for GCSE Computer Science

In this article we will have more fun and games with the Python Turtle Graphics Module. There are so many things you can do with this module from very basic programs to quite sophisticated applications, making it an ideal learning tool for GCSE Computer Science.

One resource based on Python Turtle Graphics that is not as well known as it should be is the Free Python Games Project, which has some really fun and well-written games that you can play, examine the code for and modify for yourself. In this article we will look a version of the classic arcade game Tron from this collection.

To get the program to run, the author recommends that you install freegames via pip. If you don’t know how to do this, you can find out here. Another way, which I prefer, is to download the utilities file and save it as freegames.py in the same folder as the actual games, and you are good to go.

One thing I like about this project from an educational point of view, is that a lot of the implementation datails are abstracted away into the a utilities module (consisting of a vector class and a few handy functions), so students can focus on the game logic itself. The coding style is very succinct – almost like poetry, some might say. Below is the code for the tron game.

Tron Game with Python Turtle

Several exercises are given to modify the program:

Exercise one is quite simple – can you find the value which controls the speed?

Another simple change is to change the background colour and add a title to the turtle window:

Exercise 4 is quite interesting, and takes us into the realm of AI or Artificial intelligence. This could get quite complex quite quickly, but one very simple idea is to get one of the players (the computer) to change direction randomly with a certain probability.

Have a go to see if you can implement that functionality for yourself.

And that’s it for today’s look into the Free Python Games Project. I hope you found it fun and interesting. Any questions or comments, please let me know below.

Leave a Reply

Your email address will not be published. Required fields are marked

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}