Let's build a simple pac-man game...

and improve our programming skills!

Hi! Welcome to this series of videos on building a simple Pac-Man game in Python. This series of videos is perfect for students that just learned how to program in Python and are now ready to program something bigger than simple functions!

Just follow the lectures below!

Video 01: Getting started!

In this first video, I'll explain what this series of videos is about and what our first steps are!

Video 02: Our first decision: the game map

Our first step in the code will be to model the map of the game.

Video 03: Finding the pacman in map

The first function we implement finds the coordinates of the pacman in a given map.

Video 04: Our first automated test

Let us now properly test the find_pacman() function we just created.

Video 05: Moving the pacman to another position

Our next step is to actually move the pacman from one position to another.

Video 06: Our first user interface

Let's show the pacman game for the first time to the player. It's a very simplistic map, but that's how we start!

Video 07: Moving the pacman based on a key

We now move the pacman according to the key that the user pressed.

Video 08: Checking for illegal moves, part 1

Moving is not that simple. The pacman should only move if a valid key was pressed or if the new position is within the borders of the map. Let's check that.

Video 09: Checking for illegal moves, part 2

We now check if we hit a wall of if we hit a ghost. The play() function is getting more and more complicated.

Video 10: Do we win the game?

The pacman wins the game if it collects all the pills. Let's find a way to count all the pills in the map.

Video 11: The main loop: part I

It is time for the main loop of the game: we get the key from the user, we move the pacman, we repeat!

Video 12: The main loop: part II

We now let the user know when s/he won or lost the game. The complex return of the play() function starts to pay off.

Video 13: Moving the ghosts: part I

The ghosts should move randomly in the map. How do we do it? We first find all the ghosts in the map, and then, randomly select a direction for them. In this video, you also see that copying and pasting code is really prone to errors!

Video 14: Moving the ghosts: part II

The ghosts should also respect the rules of the game: they should not go through walls or eat the pills. Let us add those checks.

Video 15: Improving the UI

Our UI is very simplistic. Let's make use of some ASCII art and make the UI a little bit more attractive.

Video 16: Revisiting our code

It seems we are done! Let's revisit the code and discuss about our main coding decisions one more time

Video 17: It's time to say good bye!

I show you a repository where you can see different implementations of the pacman game, even using some object-oriented programming!