Creating Pac-Man style games in Python
Pac-Man has earned its place in video gaming history. Calvin Robinson shows how you create your own version of the iconic arcade title.
Calvin Robinson
OUR EXPERT
Calvin Robinson is a former assistant principal and computer science teacher with a degree in computer games design and programming.
Pac-Man is arguably one of the most famous video game characters in the world. First shooting to fame in 1980 with the release of remakes and sequels over the years, but nothing compares to the original.
It’s a simple premise, really. Pac-Man is a yellow, disk-shaped, mainly feature-less character, who roams around a 2D environment collecting dots. The player has to collect all the dots in the room without being touched by any of the four enemy characters in the form of ghosts. Pinky, Blinky, Inky and Clyde are brightly coloured to stand out against the black background, being pink, red, cyan and orange, respectively. Pac-Man must avoid the ghosts and collect all the dots to progress to the next level.
Pac-Man can only move up, down, left or right, through the maze of dots, but does have some advantages in his arsenal. By collecting large ‘power pellets’ Pac-Mac becomes energised and the ghosts all turn blue, enabling him to eat them on impact. The more blue ghosts you eat, the more points you get. As with all arcade games, the aim of the game is to get the highest score on the leader board.
Originally called Puck Man in Japan because of the main character looking like a hockey puck, Pac-Man was renamed for Western audiences to avoid any dodgy naming issues. It’s fun and friendly, and potentially the first ‘inclusive’ video game, what with Pac-Man being designed to appeal to girls as well as boys, and to attract a younger audience.
QUICK TIP
Speed up Pac-Man by increasing or decreasing the ‘onkey’ values, at the bottom of our code (x, y). Remember that positive numbers move right or up, and negatives move left or down.
A vector based Pac-Man game developed in Python.
Working in Python
Likewise, Python is an incredibly accessible programming language. In LXF262 we used Python to create a Lunar Lander Module game, and in LXF263 we created a side-scrolling game in Python. The original Pac-Man game was released between the two, Lunar Lander being 1979 and the first side-scroller being 1981. Python is perfect for our retro gaming projects. So let’s begin…