Got a day free this week? Why not see if you can make Pac-Man entirely within 24 hours? It sounds like a simple challenge, because it is, but it's the perfect challenge for testing your skills, new tools, new languages, working with sounds and images, or using Git.
Getting Started
The first thing you should do is decide what language and tools you're going to use. For me, I used C as my language, and raylib as my graphics library. A simple choice for a simple game, however, you may decide to use a full game engine, other languages, and so on. A good choice is a language that you are wanting to learn, and for me, I wanted to get better at using C.
Helpful Information
To create Pac-Man, there are some rules that you should follow.
I'm going to explain what I consider the fundamental algorithms of the game, but you can add more you find from here.
First you have the grid of the game, which can be the original, or any modified version you want. When you reach the end of the grid, however, the player should be able to warp to the other side. Then you have pellets, the player, and 4 ghosts.
The pellets should disappear when the play moves over them, you can choose to keep track of score.
The player just has to moves around the grid, and other than that, doesn't do much.
Each ghost is more interesting.
The Ghosts
Each ghost has a specific target for each movement. The different ghosts determines what this target is. Otherwise, there are still some rules that apply to every ghost. The can't move back on the themselves, and they take the greedy path to their target. So as long as they get closer to the target in the next movement, it doesn't matter if that path is twice as long.
The first ghost is Blinky, and Blinky's target is the player's current position.
Pinky's target is 4 tiles in front of the player, so if the player is moving left, it will be 4 tiles left of the player.
Clyde's target changes depending on how far away from the player Clyde is. If Clyde is more than 8 tiles away from the player, its target is the player's current position. Otherwise it's a scatter position, outside the bounds of the grid. Really the position doesn't matter, but if you want the exact position, it's on the website linked.
Inky's target is based on both Blinky's position and the player's position. Take a line from Blinky's position to the player's position, then double the length of that line so you have a straight line from the new position and Blinky, with the player in the middle. That position is the new position.
Ending
There's not much more to it, but the more you add the better. Mine is a very simple version, without images, sound, or a score. Put down your code in the comments! And have fun designing, implementing, and playing this game!
Top comments (0)