Simple Python Game Tutorial Using Classes
Python is a great language, especially for beginners. Once you get a few concepts under your belt, you naturally want to start making some games! If you are just getting started, you will want to check out my previous (simpler) tutorial called A Simple Python Turtle Graphics Game. This tutorial is similar to the first one, but uses Classes to simplify the code.
Note: This tutorial was written in Python 2.7 / 3.5 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.
In this game, players are in control of a spaceship inside of an arena of unknown origin. Also trapped inside the arena are goals that fly around at random. The player's job is to fly around and touch as many of the goals as possible. When a goal 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.
Intro: Introduction and Overview
Part 1: Getting Started
Part 2: Keyboard Binding / Turning the Turtle
Part 3: Adding Borders / Border Checking
Part 4: Adding and Moving a Goal
Part 5: Collision Checking Function
Part 6: Multiple Goals and Performance
Part 7: Scoring
Part 8: Background Image / Sound (Mac Only)
Part 9: Turtle Image
Resources and Source Code Coming Soon!
Recent blog posts
- Simple Python Game Tutorial Using Classes
- Video Tutorial: Python Spacewar Game
- Video Tutorial: Python To-Do-List (GUI Version)
- Video Tutorial: Simple Space Invaders Clone
- Video Tutorial: Python Functions with Turtle Graphics
- Video Tutorial: Python Guessing Game (GUI Version)
- Global Codeathon Scratch Tutorials
- Video Tutorial: A Simple Python Turtle Graphics Game
- Video Tutorial: Tic-Tac-Toe in Python
- In Favor of Standardization in Ed Tech