Pacman Report
Pacman Report
Pacman Report
CS324 - Coursework
Tom Kilminster - u1411335
January 15, 2017
1 Features
In order for the solution to remain true to the original Pac-Man game [2] a
lot of original features have been incorporated. These include: level resets,
tunnel portals, a high score mechanic and multiple lives.
Furthering the point of remaining true to the original game, sprites have
been used 2 to give the authentic feel. Each of the games many animations
are simply executed by changing the sprite image over time, mirroring the
way a flip-book would work.
Ghosts also have the original be-
haviour of Pac-Man implemented
where each ghost has a unique per-
sonality [1]. This enables a more
immersive and exciting feel to the
game as the player must track multi-
ple ghost movements of which none
are the same. The ghosts are also
”released” from the Ghost Pen at
different times, akin to the origi-
nal, which leads to the player hav-
ing to think more about their actions
the further through the level they
progress. Finally, the ghosts also
operate on a wave mechanic where Figure 1: The ghosts respective scatter
they will switch between two modes: movements [1]
CHASE and SCATTER. When in
scatter the ghosts will go to separate corners 1 and in chase they will switch
to their individual AIs. This is so the player does not feel a constant level of
stress when playing of all ghosts constantly behind Pac-Man.
1
As with the original Pac-Man, bonus fruit also spawn in the level after
Pac-Man has eaten first, 70 pills and then after he has eaten 170 pills. The
fruit implemented are the cherry and strawberry which are worth 100 and 200
points respectively. Again, the original sprites were used for drawing them
keeping everything authentic. The fruits only spawn in the lower portion of
the maze and their spawn location is randomly selected. The application will
randomly select a tile to spawn the fruit at and as long as it is an empty tile
where a small pill once was, the fruit will be spawned, otherwise another tile
will be chosen.
2 OpenGL Implementation
Rather than loading and binding textures throughout the course of the ap-
plication it has been written such that in the init method all textures that
will be used throughout the game will be loaded and bound. This translates
to better performance in game, although does require more processing power
initially.
As mentioned, the game uses
sprites for drawing. However, when
Pac-Man must interact with other
entities, such as walls or ghosts, an
extra feature must be used. All in-
formation on each entity’s location
is stored in a maze array. This
will determine wall collision, pill eat-
ing or ghost collision. It is also
from this array that all the map
sprites are drawn; the array is iter-
ated through and depending on the
contents of each index, a different
sprite is drawn. Figure 2: The initial ready state of the
In order to keep track of time and game, displaying the sprites used
movement within the game, ticks are
used. There are multiple ticks for different purposes, however the overarching
tick is gameTick which determines sprite animations, game events and game
state changes. This tick incremented in the idle method to ensure smooth
movement and interactions between all bodies.
A high score mechanic has been implemented which uses a high score.txt
file to store the highest score. This enables the score to be stored even after
the game has been closed and be reloaded upon launch of the game. If, upon
2
launch, there is no such file then one is created and initialised with the value
0.
3 Setup Instructions
3.1 Compilation
In order to compile execute the solution some commands must be executed
in the terminal.
3.2 Execution
In order to execute the solution use:
$ . / c ou r s e w o r k
Unless changes are being made to the code, compilation does not need to
be run every time before execution.
4 How To Play
The aim of Pac-Man is to eat all the pills to advance to the next level, without
being caught by the ghosts.
If Pac-Man eats a super pill the ghosts will turn frightened and Pac-
Man will be able to eat them to gain bonus points. Otherwise, if Pac-Man
encounters a ghost he will lose a life.
Pac-Man can also gain bonus points by eating the bonus fruit which ap-
pears randomly in the maze once a certain amount of pills have been eaten.
Movement:
• Arrow Keys - Left, Up, Right, Down
Game:
• P - Pause/ Unpause the game
3
• Q - Quit the game
References
[1] Chad Birch. Understanding pac-man ghost behav-
ior. http://gameinternals.com/post/2072558330/
understanding-pac-man-ghost-behavior. Accessed: 07-01-2017.