We may earn an affiliate commission when you visit our partners.
Bob Grant

Writing your own computer programs is a great skill to have. Whether it's for a hobby, a school computer science course, University or because you'd like a career as a software engineer.

We all have to start at the beginning. This is why my Python course doesn't require any previous knowledge of computer programming. We'll start at the very beginning and work from there. Whatever your age, 9 to 90 this course will take you step-by-step from your very first line of code through to a fully working, object orientated, Python application.

And what could be a more fun way to learn coding than to write computer games?

Read more

Writing your own computer programs is a great skill to have. Whether it's for a hobby, a school computer science course, University or because you'd like a career as a software engineer.

We all have to start at the beginning. This is why my Python course doesn't require any previous knowledge of computer programming. We'll start at the very beginning and work from there. Whatever your age, 9 to 90 this course will take you step-by-step from your very first line of code through to a fully working, object orientated, Python application.

And what could be a more fun way to learn coding than to write computer games?

All the programming examples and exercises in my course are based around building your very own games programs.

We'll learn how to store data to represent game characters, test what's happening in our game so our code can decide what to do next, build Python classes to create objects that model our game, and add sound effects and graphics to make them look cool.

We start with some simple text based games to teach you the basics of coding. Then we quickly move on to basic animation techniques. Finally we code a full version of the classic snake game which brings all your coding skills together and shows you how to apply them using professional programming techniques to create complex applications with ease.

Every lesson is video-based and I take you through every line of code, explaining exactly how it works. There's lots of opportunity for you to have a go yourself first but knowing my fully explained solutions are there when you need them.

As I work through the code on screen you follow along on your computer. As I get the code working so do you. Every piece of code we write in each lesson can also be downloaded as part of the lesson's resources. This way you always have a reference to fall back on if you need it.

By the end of this course you will have all the skills required to write well structured, object orientated, working, Python games. You'll then be ready to expand your skills into any areas of programming you desire.

So boot up your computer and start coding today.

Enroll now

Here's a deal for you

We found an offer that may be relevant to this course.
Save money when you learn. All coupon codes, vouchers, and discounts are applied automatically unless otherwise noted.

What's inside

Learning objectives

  • How to have fun learning to code - no tedious exercises, no meaningless programs - just working games!
  • How to build your own fully working, object orientated, python games and programs
  • Professional python skills to get you through gcse (16 year old) and a-level (18 year old) computer science courses
  • How to install python and a beginner friendly development system (all the software is free)
  • How data is stored by your code so you can manipulate and make decisions based on it
  • How to use pythons lists and tuples to create collections of data
  • What python classes and objects are and how they can be used to encapsulate data and code
  • How to design your own classes and use object orientated programming techniques
  • How to break down complex problems and design classes to share the programming load
  • How to create animations using pygame - a python package for games coding
  • How to integrate sound effects and backing music into your games
  • Collision detection techniques to get your games working
  • State machine techniques to control how the game and individual characters behave
  • Show more
  • Show less

Syllabus

Introduction and Getting Started

Welcome to the Course.

Let's get started.

Before we can start coding we'll need to install some software on to your computer. In this lesson we'll install Python itself along with a development tool to make coding much easier.

Read more

Computer programs basically revolve around data. They collect data, store it, manipulate it and output it. Every piece of software you can think of is carrying out these tasks.

As data is so vital to our code we need to know how to store it inside our program so that we can work with it.

This is where variables come in.

In this lesson we'll learn what variables are, how to create them, how to store data in them and how to manipulate and change that data.

So far we've been typing or Python commands into the console. But this only lets us execute one program statement at the time. Computer programs need a large number of instructions executed one after another.

In this lesson will learn how to use the Mu editor to create a program, save it and run it.

Once a computer program has gathered some data we need to analyse it and make decisions based on our findings. This allows a code to take different actions depending on the values of our variables.

In this lesson we learn about the main conditional statement in Python, the IF statement. We'll learn how to create Boolean expressions using, and comparing variables and then see how the IF statement can be used to control which blocks of code are executed.

Sometimes our code needs to repeat a block of statements over and over again. Instead of writing out our statements multiple times, we can use looping structures to repeat a single block of code as many times we want.

In this lesson will learn about the FOR loop and use the RANGE function to control its operation.

Our simple guessing game needs to let the user have a number of goes at guessing the word. In this lesson will use our looping skills to add a FOR loop to achieve this. We'll also see how we can use the BREAK command to jump out of the loop before it's finished.

For our second game we're going to write a text based version of noughts and crosses (or tic-tac-toe).

To begin with I'll describe how the game works (just in case you don't know!) and then cover a few of the basic programming techniques you will need to complete the project. This will include an expansion of the IF statement using both the ELSE clause and the Python ELIF statement (ELSE IF).

If you've already got some programming experience this is a good project to try to complete by yourself. After covering the major ideas I'll give you a chance to have a go by yourself.

If you've only got a little bit of programming experience I'll give you an overview of how to solve the problem so you can have a go at creating the code by yourself.

If you are not yet ready to programme on your own the next lesson is will cover the whole solution step-by-step.

In this lesson I'll take you through the complete solution for the noughts and crosses game.

We'll start with a completely blank project and then build the code line by line so you can see how we turn the algorithm for how the game works into actual Python code. By the end of the lesson will have a fully working version of the game using only the programming techniques we've covered so far in the course.

The code we created in the previous lesson works, but it's not a very elegant solution. A number of blocks of code are repeated throughout the programme which is bad programming practice.

In this lesson will learn how to pull blocks of code out of the main program and placed them in two things called functions. These functions then allow us to execute these blocks of code simply by calling them by name. Instead of repeating blocks of code that have been typed into our program listing, we simply call the function whenever it's needed.

Using functions is one of the main building blocks in being able to write well structured code. Without this skill you'll find it almost impossible to write more complex programs.

One of the great features of modern programming languages, including Python, is the availability of code packages. Packages are blocks of code written by somebody else that you can bolt onto your code to instantly give you a whole range of new features to use in your program.

In this lesson we'll move away from text based software and start graphic programming. For this we'll need to use a package called PyGameZero. PyGameZero is pre-installed by the Mu editor, but I'll show you where you can get hold of other packages and how you install them for future use.

We'll then start using PyGameZero to create a window for our game and learn how to use the documentation to find out about the features of a package and how we can apply them in our code. By the end of the lesson we'll be able to draw primitive shapes inside our game window.

Now that we've got a static square being drawn in our game window we need to make it move.

In this lesson we'll see how we can model our square using variables, and then by adjusting these variables make it move around the screen.

We'll also be looking at the idea of global and local variables in our code. So far we've been assuming that if we create a variable we can use it anywhere we want. Once we start using functions this is no longer the case. I'll show you the difference between global and local variable scope and we'll then work out how to make sure our code understands what we're trying to do.

We can now move the square on screen so let's expand upon that and get it bouncing around inside our game window.

We'll learn how to control the speed and direction of our square and how to detect when it has collided with the sides of the window.

Our bouncing box code uses a number of discrete variables to model the actual box and its position on the screen. If we had to model a number of different objects we'd end up with lots of discrete variables lying around inside our code. As our code gets more more complex this will just get incredibly confusing.

We need a way of packaging the data that represents a particular object into one place. This is where objects come into play.

In this lesson you will learn how to specify a CLASS which can then be used to create, or instantiate, an OBJECT. This can then be stored in a variable. These objects can contain both data and code and allow us to model various parts of our software and encapsulate it all within a single data entity.

This is your first step towards Object Orientated Programming, OOP.

We've now built a class to model a single box. We also know how to instantiate an object using this class which can be stored in a single variable. This object has the ability to move and draw itself using simple commands or methods.

Once we have the ability to create one object we can create as many as we want. We can use loops to repeatedly generate new objects but we need a better way of organising them so we can work with them as a group.

In this lesson we learn about lists, arrays and tuples and how we can store multiple variables inside these data structures.

By the end of this lesson our code will be able to generate as many boxes as we want and control all of them as they bounce around the screen.

We've now had a play with some smaller programs whilst we learnt the basic programming techniques will need for larger projects.

So let's get started on a proper game.

In this lesson we'll have a look at the Snake game project and get ready to start coding it.

The Snake game is going to be a fairly complex piece of software. There are a lot of things happening as the game progresses and the number of game characters that need to be modelled and animated. When we tackle projects like this we need to break them up into smaller, manageable pieces. As we solve and code each of the smaller problems we can put them together to create the finished game.

In this lesson we will go through a top-level design to try to identify a number of objects that we'll need to code to manage our game characters.

Before we can start the game we need to create a game area and be able to prompt the user to start the game.

In this lesson we will learn how to detect keyboard presses and react to them. We'll also build in the major game states: the start screen, the game playing state and the endgame screen.

We'll also learn how to add graphics to our game by downloading an image and using it on our start screen together with some properly aligned text in a font of your choice.

The game screen needs a number of fixed objects and text for things like the player score, play area outline and other game information - usually called boilerplate.

In this lesson we'll learn how to use program constants to define a number of parameters for our game. Our game display will then use these constants to calculate the sizes and positions of areas and objects within our game. This allows us to easily make adjustments to the layout of the screen without having to alter our code.

By the end of this lesson our game screen will be ready for the actual game characters and will be fully controllable using our newly created constants.

The first character we need to animate is the snake itself.

In this lesson we will look at how the snake moves and develop a grid system to control its position on the screen. We'll then build this grid system into our screen layout code so that we can easily specify a size for our active play area and have our screen automatically adjust itself to accommodate this.

In this lesson we'll learn how to animate the snake's head.

We'll be starting to code the main snake class that will encapsulate the data and code needed to model the snake character. We'll learn how to convert between the snake's grid and the actual pixels on the screen and then how to control the speed of the snake by adding a delay timer into the snakes move method.

Now that the snake is moving we need to add the player controls.

In this lesson will learn how to detect key presses and then decode these to control the direction the snake moves in. We'll also build in the code to stop the snake backtracking on itself as later in the game this would cause an instant death.

By the end of this lesson the player will have full control over the snake movement.

So far the snake has just been a single square moving around the screen. We need to add more body parts and have those follow one after the other, tracing the same track as the head of the snake.

In this lesson will create a separate class to model an individual snake body part and then see how we can use a Python list within our main snake class to store and control the individual body parts as one whole snake.

At the end of this lesson we will be able to create a snake of any length and have it slither around the screen.

When we created our screen display we put a green box to mark the limits of the active play area. If the snake tries to go outside this area it dies.

In this lesson will be adding limit detection to the snakes movement so that our code can detect when the snake has moved outside the active play area. If this happens our code will kill the snake and take us to the endgame state.

The game objective is to grow the size of the snake by eating food.

In this lesson we will start building our food classes to model both individual piece of food and to create an overall food handling class. Food needs to be generated using a random timer and each piece of food will stay on screen for a random length of time. Our food code therefore needs to have built in timers to control these events.

By the end of this lesson we will have food randomly appearing in the play area, staying there for a random time, and then disappearing.

For our snake to be able to eat food our code needs to detect when the snake's head has collided with one of the food objects.

In this lesson we'll learn about bounding box collision detection and how we can model our objects as rectangles to make it easy to calculate when they have collided. We'll code our own collision detection software and then use that to allow our snake to eat the food.

When our snake eats food it should start to grow.

In this lesson will use the collision detection from the previous tutorial to trigger a new block of code that will add body segments to the tale of the snake. The number of body segments each piece of food generates will be built into the food object, and this data will be transferred through the objects to the snake object so that it can grow the snake.

By the end of this lesson you will understand how data can be fed into and out of objects using parameters and return values.

At the moment the only way the snake can die is to crash into the edge of the playing area.

In this lesson will write the code to detect if the snake's head is collided with another part of its body. If this happens we will kill the snake.

As the game progresses we need to increase the game difficulty. One way we can do this is to increase the snake speed as it gets longer and longer.

In this lesson will write code to monitor the length of the snake and then adjust its speed accordingly. We'll also learn how to translate the speed value into a meaningful number that can be displayed to the player.

By the end of this lesson are snake speed will automatically increase as our snake gets longer and longer.

Signed adds to the atmosphere of the game. At the moment our game is completely silent.

In this lesson will add sound effects and backing music to the snake game. You'll learn how to use PyGameZero's built in sound objects to generate simple tones, and then to import pre-recorded sound effects which we can play to mark certain events in the game such as hitting the edge of the screen, eating food, etc.

We'll also learn how to add background music and how to control its playing as we move between the start, play and endgame states.

When the snake dies we simply leave all of our variables and objects at the same state as when the game ended. If we try to restart the game it doesn't work.

In this lesson we learn how to write code that will both initialise the game at the very start, but also reset it back to its starting values when we want to play a second game. This will involve re-factoring (reworking) some of our code to make it more flexible.

By the end of this lesson our game will easily transition from the start screen, through the game playing state, into the end game state and then back to the playing state.

A game can never have too many things that kill you!

In this lesson we'll design spiders for our game. We'll work out how they appear and how they move around the screen. This will involve a bit of mathematics but I'll walk you through all the calculations step-by-step.

PyGameZero has a number of built-in objects that we can use to simplify our game code. One of those is the Actor object.

In this lesson we'll reuse part of our food class code to get our spiders appearing on screen using a random timer. We'll then see how we can use the Actor class to model the spider sprite (image) and render the graphic in our game window.

The spiders need to move randomly around the screen, but mustn't go off the edges.

In this lesson we'll implement the algorithms we discussed in the first spider tutorial to control the spider movement. We'll learn how to translate the algorithm into Python code so we can make the spiders travel at any angle we want, and control the speed along that path.

By the end of this lesson our spiders will be crawling all over the screen.

If the snake head hits a spider it dies.

In this lesson we will use the bounding box collision detection built into PyGameZero to detect when the snake head hits a spider.

By the end of this lesson you'll have a fully working, finished, Snake game.

Congratulations on completing the course.

Let's take the next step!

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Uses game development as a fun and engaging way to introduce fundamental programming concepts, which can help beginners stay motivated and grasp core principles more easily
Covers object-oriented programming (OOP) techniques, which are essential for building more complex applications and are widely used in professional software development
Employs PygameZero, which simplifies game creation, allowing learners to focus on programming logic rather than getting bogged down in complex game engine mechanics
Includes a full version of the classic Snake game project, which allows learners to apply their new coding skills to create a complex application with ease
Uses video-based lessons with downloadable code, which provides learners with both visual instruction and a reference to fall back on if they need it
Teaches collision detection techniques, which are essential for creating interactive games and simulations, but may require additional mathematical understanding

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Reviews summary

Beginners python through game coding

According to the course materials provided, "Beginners Python Programming - Learn By Coding Games" offers a highly engaging and beginner-friendly introduction to Python programming. It focuses on teaching core concepts through the practical and fun process of building games, starting with simple text-based examples and progressing to a comprehensive Snake game project using the PyGameZero library. The teaching approach is described as step-by-step video lessons where the instructor explains every line of code, providing opportunities to practice and offering solutions. This method aims to provide a solid foundation for new programmers, potentially preparing them for exams like GCSE or A-Level.
Introduction to game graphics.
"Learning PyGameZero was useful for getting started with simple 2D game graphics."
"I appreciate learning a library specifically designed to be beginner-friendly like PyGameZero."
"The course effectively shows how to use PyGameZero for animation and collision detection."
Provides a solid foundation.
"This course gave me a good start in Python, providing a solid foundation in the basics."
"It covers the fundamentals and core concepts thoroughly, which is exactly what I needed as a new programmer."
"I feel confident in the basics and ready to explore more advanced topics or other areas of Python after this."
Build a full Snake game step-by-step.
"Building the full Snake game was a great culmination of everything we learned and felt like a real accomplishment."
"The Snake project was challenging at times, but the step-by-step guidance made it manageable and very rewarding."
"I liked how the Snake game integrated all the concepts we learned throughout the course into one large project."
Designed for absolute beginners.
"As a total beginner with no prior coding experience, I found the course incredibly easy to follow."
"It truly starts right from the beginning, explaining every little detail, which was perfect for me."
"The step-by-step approach and use of the Mu editor prevented me from feeling overwhelmed."
Instructor explains every line of code.
"The instructor explained concepts really clearly, making sure I understood the 'why' behind the code."
"I could follow along easily as he explained each line and demonstrated its effect."
"His explanations made even the slightly more complex ideas, like OOP, understandable for a beginner."
Learn Python by building fun games.
"Learning Python through games was super engaging and kept me motivated throughout the course."
"The projects were the best part, making coding feel less like a chore and more like fun."
"I found building the games really helped solidify the concepts in a practical way."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Beginners Python Programming - Learn By Coding Games with these activities:
Review Basic Programming Concepts
Reinforce fundamental programming concepts like variables, loops, and conditional statements to build a solid foundation for learning Python.
Browse courses on Variables
Show steps
  • Read introductory materials on programming concepts.
  • Complete online quizzes to test your understanding.
  • Write simple programs using these concepts.
Review "Python Crash Course"
Supplement the course material with a comprehensive guide to Python programming, focusing on hands-on projects and practical applications.
Show steps
  • Read the introductory chapters covering Python basics.
  • Work through the example code and exercises.
  • Attempt one of the project-based chapters.
Practice Coding Challenges on HackerRank
Sharpen your Python coding skills by solving targeted coding challenges that reinforce concepts learned in each module.
Show steps
  • Create an account on HackerRank.
  • Solve Python challenges related to the current module.
  • Review solutions and learn from others.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Review "Automate the Boring Stuff with Python"
Expand your Python knowledge by exploring practical applications beyond game development, learning how to automate tasks and build useful tools.
Show steps
  • Work through the example code and exercises.
  • Read chapters on relevant Python libraries.
  • Apply the concepts to automate a task.
Develop a Simple Text-Based Adventure Game
Apply your Python skills to create a text-based adventure game, solidifying your understanding of game logic, user input, and conditional statements.
Show steps
  • Plan the game's story and structure.
  • Implement user input and game logic.
  • Test and debug the game thoroughly.
Create a Video Tutorial on a Python Game Concept
Deepen your understanding by explaining a Python game development concept in a video tutorial, reinforcing your knowledge and teaching skills.
Show steps
  • Choose a specific game development concept.
  • Prepare a script and example code.
  • Record and edit the video tutorial.
  • Share the tutorial with other students.
Contribute to a Pygame Open Source Project
Enhance your skills by contributing to an open-source Pygame project, gaining experience in collaborative development and advanced game programming techniques.
Show steps
  • Find a suitable Pygame project on GitHub.
  • Identify a bug or feature to work on.
  • Submit a pull request with your changes.

Career center

Learners who complete Beginners Python Programming - Learn By Coding Games will develop knowledge and skills that may be useful to these careers:
Game Developer
A game developer designs and creates video games for various platforms. This Beginners Python Programming course gives students the tools to start from the very beginning and advance step by step to make games. Through the course, learners apply professional programming techniques to creating complex applications with ease, readying them for the world of serious game creation. The course's focus on building fully working, object oriented Python games directly translates to the skills needed in game development.
Python Developer
Python developers specialize in building applications and software using the Python programming language. If you are looking to become a Python developer, this course can help teach coding and programming skills by starting at the beginning. Every piece of code written in each lesson can also be downloaded as part of the lesson's resources. By the end of this course, students will have all the skills required to write well structured, object oriented, working Python games using professional techniques.
Software Developer
Software developers create, maintain, and test software applications. This Python course is a great way to become one, as it teaches learners to code. It is helpful because learners write computer games, teaching them how to store data to represent game characters, test what’s happening in their game so their code can decide what to do next, build Python classes to create objects that model their game, and add sound effects and graphics to make them look cool.
Mobile App Developer
Mobile app developers design, develop, and test mobile applications for smartphones and tablets. This mobile app developer course is a great jumping off point, as it teaches learners how to create collision detection techniques to get their games working. The course is also helpful, because, by the end of the course, learners will have the skills to write well structured, object oriented, working Python games.
Applications Developer
Applications developers are focused on creating and improving computer applications. This Beginners Python Programming course helps build a foundation in the fundamentals of coding. As learners advance through the course, they will pick up techniques to create animations using PyGame and integrate sound effects and backing music into games. The course may be particularly helpful to those wishing to learn about how to design their own classes and use Object Orientated Programming techniques.
Software Engineer
Software engineers are involved in the design, development, testing, and evaluation of software systems and applications. This Python course may be useful in building a foundation in core programming concepts. The course helps one build the skills to write well structured, object oriented, working Python games. It may be particularly helpful to those wishing to enhance their skills to expand into areas of programming they desire.
Automation Engineer
Automation engineers design, develop, and implement automated systems to improve efficiency and reliability. This course may be helpful to the automation engineer, for it focuses on state machine techniques to control how the game and individual characters behave. The Python foundation gained in this course may be helpful to those looking to pick up professional Python skills to get them through Computer Science courses.
Teaching Assistant
Teaching assistants support instructors by assisting with teaching, grading, and administrative tasks in an educational setting. This course may be useful for teaching assistants. The course is helpful because it provides learners with working games that have already been created. Additionally, students will show up with some object oriented Python games and programs, allowing teaching assistants to come to their aid.
Web Developer
Web developers design and build websites, ensuring they function correctly and are visually appealing. This course in Python programming may be useful for those looking to build skills in coding. The course is particularly helpful because the course teaches students how to install Python, and it provides a beginner friendly development system. The course's focus on building games may be helpful to those wishing to create visually appealing websites.
Robotics Engineer
Robotics engineers design, build, and program robots and robotic systems. This course provides a foundation in programming concepts and introduces learners to building Python classes to create objects that model games and add sound effects and graphics. The core concepts gained in this course may be useful for robotics engineers wishing to model aspects of the robots that they design.
Data Scientist
Data scientists analyze large datasets to extract meaningful insights and help organizations make better decisions. The course's focus on data structures, like lists and tuples, may be useful for data scientists dealing with large datasets. It may be helpful in showing learners how data is stored by code so they can manipulate and make decisions based on it. In data science, the skills taught in the course, such as breaking down complex problems, can be helpful.
Data Analyst
Data analysts collect, process, and analyze data to identify trends and insights that can help organizations make informed decisions. This course teaches learners how to create collections of data. Data analysts may find it useful to build a foundation in programming concepts. In this course, learners will get to know how data is stored by code so they can manipulate data and make decisions based on it.
Quantitative Analyst
Quantitative analysts, often working in the finance industry, use mathematical and statistical methods to analyze financial data and assess risk. This course teaches the fundamental concepts of data and data handling. Quantitative analysts may find it useful to build a foundation in programming concepts and how it is used to manipulate data.
Quality Assurance Analyst
Quality assurance analysts are responsible for testing software and identifying defects to ensure the quality of the final product. The course may be helpful to quality assurance analysts, as they will be familiar with the software design process. A quality assurance analyst may find it useful to understand how Python classes and objects are and how they can be used to encapsulate data and code.
IT Support Specialist
IT support specialists provide technical assistance and support to computer users, resolving hardware and software issues. The course may be helpful to IT support specialists, as they will be familiar with troubleshooting software issues. The course is also helpful, as it provides learners familiarity with a beginner friendly development system.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Beginners Python Programming - Learn By Coding Games.
Provides a project-based introduction to Python, aligning perfectly with the course's game development approach. It covers fundamental concepts clearly and concisely, making it ideal for beginners. The book includes hands-on projects that allow students to apply their knowledge and build practical skills. It serves as a valuable reference throughout the course and beyond.
Provides a practical introduction to Python programming, focusing on automating everyday tasks. While not directly focused on game development, it covers essential Python concepts and libraries that are useful for building game tools and utilities. It's a great resource for expanding your Python skills beyond game development and applying them to real-world problems. This book is more valuable as additional reading than as a current reference.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser