Computer programmers are the unsung heroes of the modern world. From smartphones to laptops, traffic systems to bank cards, their hard work touches almost every aspect of our lives. Behind each technological advance is a team of creative coders.
Computer programmers are the unsung heroes of the modern world. From smartphones to laptops, traffic systems to bank cards, their hard work touches almost every aspect of our lives. Behind each technological advance is a team of creative coders.
Over the past 30 years, computer games have become one of the most exciting and popular areas of the entertainment industry to work in. Becoming a game programmer takes creative talent to help to create the story, graphics, music, and characters you need for your games, and the technical know-how brings them to life. Who knows? This course could be the very first step on your journey from gamer to game maker.
This course uses a programming language call Python, a fairly simple text-based language, and is perfect for kids and beginners, or as a step up from Scratch. However, unlike Scratch, it is not a purpose-built language to teach coding. Python is the world's fastest-growing programming language and one of the most widely used professional programming languages in the world among software engineers, mathematicians, data analysts, scientists, accountants, and even kids. In fact, it should be the first programming language to learn.
The best way to learn any new language is to get stuck in, and programming languages are no different. Building your own computer games is a fun and immersive way to combine theory and practice. This course is divided into thirteen classes, starting from the basics of Python to building complex games that are enjoyable to learn, and fun to play.
In this course, we will use Pygame Zero, a Python library built around the famous and long-lived Python game engine, Pygame for all our game projects. Pygame Zero takes away the complicated interface required by Pygame so that I could focus on the teaching and you could focus on the learning of the gist of Python programming.
In total, we will build eleven games in this course, and each of them is treated as a separate game project and is designed in such a way that you will be able to apply and practice the programming concepts and ideas that you have learned in the previous projects into the current one, plus the new techniques in the current project to bring your skills to the next level. So, by the end of this course, you should be able to master the fundamental elements of Python programming.
In the last section of the course, there are nine lessons on the introduction to object-oriented programming in Python, the most used programming methodology in the software development world. This section is designed to prepare you for the next level of Python programming.
This course will help you start an incredible adventure into the world of programming. Most importantly, have fun while learning, once you have completed the games, you can show them off to your friends and I hope you enjoy playing them as much as I enjoyed creating them for you.
This course is intended for purchase by adults.
Python is one of the most popular and fastest-growing computer programming languages in the world. It was first released in the 1990s and is now used to build millions of apps, games, and websites.
Python is a great language for getting started with computer programming. Many schools, colleges, and universities use it to teach coding. Python is not just an educational tool. It's such a powerful programming language and it's used for many interesting and exciting tasks in business, medicine, science, and the media.
All the projects in this book use Python 3, so make sure you download the correct version from the website. Follow the instructions that match your computer.
[26-Dec-2020 updates]
For Windows 10 users, please download and install Python 3.8.2 for this course as the latest Python 3.9 version seems to have some compatibility issues with Pygame Zero version 1.0.2 according to the feedback from some students.
In this session, you'll test your Python, Pygame, Pygame Zero, and Visual Studio Code (VSCode) installations by creating your first Python program using Python & Pygame Zero. Follow these steps to create a simple program that greets the world.
If your program manages to function accordingly, it shows that your installation is done perfectly and you are ready to start your subsequent lessons.
All the projects in this book use Python 3, so make sure you download the correct version form the website. Follow the instructions that match your computer.
Python comes with many built-in functions. They allow you to perform a variety of tasks, from printing messages to converting one type of data to another. These built-in functions make programming with Python easier.
Variables are used to store and label pieces of information. You will use them a lot in your code, for example, to hold the current score or keep track of how many lives you have left in a game.
Variables can be used to store numbers, which can then be used with math operators such as add, subtract, multiply, divide, and so on to perform calculations just like you do in maths. The multiplication and division signs are different from the symbols you use at school, so take note of them.
A string is any data made up of a sequence of letters or other characters. Words or sentences are stored as strings. In Python, strings are frequently used and most programs use at least one string. Any character that you can type of your keyboard can be stored in a string.
In Python, a list is used to store a collection of data. It can hold many different values and keep them in order. For example, a list can store a deck of cards for a game or different colors used for the game. The position of each value in the list is identified with a number, starting from 0. You can use these numbers to change the values stored in a list or to access its value.
A tuple is another type in Python that holds a collection of items or objects, tuples are very similar to lists, and everything you know about lists is most likely the same for tuples! However, there are two major differences between tuples and lists: a) Tuples use parentheses b) Tuples are immutable, i.e. the values of the objects stored and the number of objects stored in a tuple cannot be changed throughout the program, once they are defined.
Another set of operators we often use in programming are called comparison operators. Just like the name, comparison operators help us compare one value to another. When we use comparison operators, they give us back a True or False answer known as a Boolean type or value. Comparison operators and Booleans are super important because they help us make decisions in our games.
Playing a game involves making decisions about what to do next. These are often based on answers to questions. For example, "Do I hit the alien?", "Is the coin is being collected?", "Does the rocket hit the wall?". These questions usually involve comparing one value to another. For instance, is one number bigger than the other? If it is, the computer might skip a block of code that would otherwise have run.
In this lesson, you'll learn how to play with loops in Python. When you're coding a game, you often need to run the same bit of code several times, but it'd be pretty boring if you have to type it in every single time. Luckily, you can use a loop to run the same block of code over and over again. There are many types of loops in Python.
Continue from the previous lesson, you'll learn how to play with loops in Python. When you're coding a game, you often need to run the same bit of code several times, but it'd be pretty boring if you have to type it in every single time. Luckily, you can use a loop to run the same block of code over and over again. There are many types of loops in Python.
Functions are really handy tools for all coders. They let you name useful chunks of code so that you can use them over and over again without having to type the whole thing out each time. Yes, you just have to type the name of the function to execute it in your program at the point you want them to execute!
You have learned about some built-in functions in the previous lessons, but you can also write your own functions to handle tasks specifics to your games.
Functions are really handy tools for all coders. They let you name useful chunks of code so that you can use them over and over again without having to type the whole thing out each time. Yes, you just have to type the name of the function to execute it in your program at the point you want them to execute!
You have learned about some built-in functions in the previous lessons, but there isn't a built-in function for everything, so you need to know how to write, or "define", your own. A function should have one clear purpose and a name that describes what it does.
When you write or define our own functions, you often want the functions to be able to take in parameters (you've learned this in the previous lesson) when you call them in your program. In this lesson, you'll learn how to make one or more parameters optional in Python by giving them a default value.
Learn the best Python programming practice in naming your variables and functions name to make them easy to read and understandable.
Errors are one of the things that you need to deal with quite a lot when you building your games, especially when you are new to Python or programming. In this lesson, you will learn the various types of common errors you might encounter while you are developing your game and how to solve or debug them.
The variables you defined in your program are fenced within their own boundary or "scope" in Python. Understanding how the scope of variable works will ensure your game function properly according to your plan without any unexpected errors.
In this lesson, you'll learn to set up your game project environment in VSCode, the project file structure, and also naming your code project file.
In this lesson, you'll learn how to import the Pygame Zero runner system into your code and also using the preset variable in Pygame Zero to set the size of the game window and also the title. You'll also learn how to use the Pygame Zero's functions to render your game window with a different color.
In this lesson, you'll learn how to add an actor to your game window and move it around on your game window. You'll also learn about the graphic representation of Pygame on a game window and how to utilize it to place your actor on a different location on the game window.
You'll also learn in this lesson how to import external functions from the external library and use them in your game.
This lesson shows you how to make your game responsive to the player's mouse click by detecting the mouse clicking events in your code. You'll also learn how to use collision detection in your code to respond to the event.
One of the key features of a game is able to display messages to the player such as instructions, player scores, player's lives count, and so on. You'll learn the trick in this lesson too!
In this lesson, you'll see how easy you could fine-tune your game after it is done. Also, knowing how to troubleshoot is also essential, knowing how Python interprets your code is a key to that as well.
You are going to enhance what you have learned in your previous lesson and also some new functionalities of Pygame and Pygame Zero. In this game, you will learn how to receive and interpret the arrow keys press from your keyboard and also more collision detection function of Pygame.
In this lesson, you will learn how to use function placeholders to organize your code structure.
In this lesson, we are going to build a game called "Connect The Satellites". In this game, you will challenge yourself and your friends to connect all the satellites that appear on the screen as quickly as possible.
In order to respond to the mouse click events by the player, we need to add the event handler from Pygame Zero to capture the events when the player clicks on any part of the game window. In this lesson, you will learn the skills you need to handle and process the mouse click events inside your game.
In order to record the time lapsed in a game, we need to use the time functions in Python. You will learn how to use one of them in your code to capture the game start and end time to see who is faster in finishing the job!
In this lesson, we are going to build a game called "The Shooting Stars", when the game starts, two stars will moving down the screen and the player needs to clicks on the red-star before it reaches the bottom of the game window. Each time the red-star is clicked, the game moves on to the next level and more stars with different colors will appear and the speed of them moving down to the game window will also increase. It is an interesting game that challenges your response time and speed.
In this lesson, you will learn how to use Pygame Zero's blit method to paint the background of your game window and also to display the game status messages on the screen.
In order to create stars with different colors, we need to create them randomly during program run-time. In this lesson, you'll learn how to use the random function together with the list's operation to complete the task.
There are many ways to move an object around the game window in Pygame Zero, one of the ways is to use the animation function and in this lesson, you will learn how the animation function works and how to incorporate that into your game.
In this lesson, you'll learn how to use the "in" operator in your game to examine if the red-star was clicked to make the next decision in your game, whether to move to the next level or the game is over!
In this lesson, you will put your coding skill to test and create a quiz game to challenge your friends. You are a quizmaster, so you can make questions about any topic you like.
When come to drawing the game interface for this game, we are going to look at a totally different set of functionalities in Pygame Zero, which are the functions to draw and fill rectangles as game objects and also to position them on the game window and respond to mouse click events.
Reading or writing information from and to a file are often activities when comes to building a game to records information such as the user's name, score, and level. In this lesson, you'll learn how to use the file read and write functions in Python to read the questions and answers you have saved in a text file.
Once you have the questions and answers read from the text file, you have to use some programming techniques to process and display them on pre-defined rectangles or boxes on your game window. This lesson shows you how you could use the techniques you have learned to display and questions and answers for your players.
If you allow your users to skip questions, you'll need to build the logic in your game to handle the score calculation and other conditions. This lesson will show you one of the ways to do that to make your game more interesting.
There are many ways to represent your data in a text file and how you design your game data will directly impact how you write the program for your game. In this lesson, I will show you the potential problem we might encounter if we represent our data structure in the previous lesson and how to resolve them.
I will introduce to you how you could access the various pre-defined Pygame Zero colors code in this lesson and how you could use them in your game. In this lesson, you can build a color chart for your future use as well.
Welcome back, in this lesson you will combine most of the coding skills you have learned previously to build this game. Also, you will be introduced to some new coding skills in Python that are required to build more advanced games.
So far, you have learned how to move an object on a pretty stagnant background. In this lesson, you will learn how to create objects on the game window that look like background objects and move them as if the background is moving and interact the main actor of your game with these "background" objects.
Animations make our game more fun and interesting to play and often it is a crucial piece in game development. In this lesson, we are going to learn some techniques to animate a bird flapping its wings while flying across the sky in our game window. Thanks to Pygame Zero, complicated animations can now be made simple.
In this lesson, you will learn how to handle detect and handle multiple collisions between your main actor and also the rest of the moving objects in your game to determine what action to be taken.
Once you have all the pieces of codes and functions completed, it is time for you to enjoy the game with your friends and see who can score the highest score by flying the ballons across the sky for the longest and avoid most obstacles.
In this lesson, we are going to build a game that many of you might have seen or played before, the flappy bird game! We will use the programming techniques that you have learned so far together with some new skills in programming to build this game so that you and your friend can compete to see who manages to navigate through most of the obstacles.
In this lesson, we are going to learn a new Python programming term and concept, which is the Instance variables. You will learn how to define them and use them in your game to make your code cleaner, shorter, and easier to manage.
Define the game settings, set up the pipes, and move them across the game windows using Pygame Zero's functions.
You will learn how to reset the pipes when they move beyond the game window and how you place them back to your game window. Throughout this lesson, you will learn how to animates the pipes, the bird and to calculate the dynamics of the bird.
Once all the settings and animations are done, you will learn how to detects the collision between the bird and any part of the pipes, except the opening between the two pipes. Also, you'll learn how to add and play a piece of background music in your game to make it more exciting. Once you are done, you could enjoy this awesome game with your friends.
In this lesson, you'll learn how to develop a game to challenge yours and your friends' memory to see who could memorize the most movement of the karate kid. You'll learn how to generate a sequence of numbers randomly and keep store this series in the computer memory and play them back one by one to check against the player's input.
You will learn how to set up your game stage by using the coordinate systems of Pygame graphics which you have learned in the previous lessons to place the actors and other items on the game window programmatically.
In this lesson, you will learn how to use the arrow keys on your keyboard to move or get the karate kid to perform the different karate moves. And each time a different arrow key is pressed, the karate kid performs a different action, you will learn how to change or set the actor's image programmatically while the game is running.
Apart from using the arrow keys on your keyboards to move the karate kid, you also learn how to store the moves or steps and replay them using your code. Also, you will learn how to value stored in a list dynamically using a special function in Python.
In this video, you'll learn how to define your data structure, slice through them for values, and manage them to keep the information up-to-date so that your game works according to your expectation.
When coming to the end of this game, you will learn how to fine-tune your game, adding music and sound effects to your game are some of the fine-tuning you could do to make your game more fun!
In this lesson, you will learn some cool stuff in building a game. As we are venturing into the space arena, you will build a game featuring a rocket collecting happy stars, before the stars mutate and turning into hot stars which could crash your rocket into pieces.
In this lesson, you will layout your game structure by setting up all the function place holders, which is like laying the cornerstones of a building. Once these function place holders are being set up, you could start to fill them with the respective codes.
You will learn the cool feature of how to maneuver your rocket to collect these happy stars. Learn to use the rotate function in Pygame Zero to change the angle of the actor image, you will learn the angle convention in Python, which is quite different from what you have learned in school.
You will learn how to use the random function to generate multiple happy stars inside the galaxy of your game window. Once the happy stars are in place, our game will randomly pick some of them to turn into hot stars after a certain time. You will learn how to use the schedule function to do so in this game.
In this lesson, we will learn another collision detection method in Pygame Zero. You will find out how flexible and easy to use Pygame Zero build-in function to detect collision between objects that are moving without involving complicated mathematics formulate in your code.
You will learn how to show explosion animation in your game to make it more real and fun to play.
In this lesson, you are going to learn to build a new game call space invasion, which is a famous computer game played by many. You are going to put most of the skills that you have learned from the previous lessons into practice.
This is considered the most complicated game to build in this course as it involves many different objects and with that, I further break down this lesson to 12 videos so that you could follow and digest the contents easier.
Once you have done setting up the background for the game, the first function you would like to do is to be able to move the spaceship horizontally left and right, but these movements should be within the boundary of the game window. Also, you will need to place an array of aliene spaceships on the sky using some simple maths functions. Learn the skills of how to do that in this lesson.
Learn the tricks on how to move the array of aliene spaceships across the sky simultaneously and with animations to make them appear real. You are required to construct a simple idea of how to move them and turn them into the codes of your program.
With the aliene spaceships moving, now you would want to be able to fire lasers from your spaceships to the alien spaceship. Learn how to write code to generate laser beams that are able to move up to the sky once they are fired from your spaceship.
In this lesson, you will learn how to fine-tune the laser firing from your spaceship using a few interlocking logics or flags in your program.
With the technique you have learned on how to generate the laser beams from your spaceships, in this lesson, you are going to do the same for each of the alien spaceships. Of course, you will have to further enhance this by enabling them to fire their laser automatically. Also, you will learn how to remove the alien spaceships that have been shotted down by your laser.
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.
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.