This project's canonical repositories is hosted on Gothel
Software.
Overview
This project demonstrates a complex system written in modern C++ for
our computer science
class.
We have chosen the classic game for our project to pay homage to Toru Iwatani's
original Puckman.
Besides management of animated sprite graphics, maze environment and
tile positioning, animation speed synchronization, the interesting part
might be the ghost's state machine and their movements.
To implement the original Puckman game behavior like
weighted tile collision, ghost algorithm, etc. - we have used the
following documents for reference
While we have focused on implementing the original behavior most
accurately, some aspects are not fully in our control and are discussed
here.
PRNG Scared Mode
The original uses a known seeding iteration, used as a memory address
within the game rom. The last bits of the addressed rom byte represents
the PRNG value for the ghost's direction in scared mode.
Since the roms can't be used, we use the PRNG value of another
algorithm with same seeding sequence to preserver the periodic attrbutes
at least.
Frame Sync Timing
This implementation uses the monitor's frames per second number to
approximate the sub-tile step-width for the desired tiles per frame
pace.
This is achieved via Keyframe interval for animation, see keyframei_t.
Below we added measurements from pacman via commandline argument
-show_fps running along the bottom longest line from
collision to collision.
For each level we measured the slower first walk eating pellets and
the second walk faster without pellets.
Level 1: Fields/s deviation on longest line measured 7.955 f/s to
8.000 f/s or 0.5635%
Below 3% deviation should be good enough for this game using >=
10% speed differences in modes.
Below 1% deviation is a great match.
Bugs
This software may have bugs :)
Optional Deviations from
the Original
Decision on the Spot
As stated in The
Pac-Man Dossier, the ghosts select their next direction one tile
ahead of an intersection.
With the -decision_on_spot mode enabled, see Commandline Arguments
above, the ghosts decide their next direction for each field using a
more current pacman position.
The default setting is to use the original one tile ahead of an
intersection.
Bugfix Mode
With the -bugfix mode enabled, see Commandline Arguments
above, the original puckman behavior (bugs) are disabled.
The list below shall be updated in case we further the implementation
and kept in sync with include/pacman/globals.hpp.
By default the original pacman behavior is being implemented:
weighted (round) tile position for collision tests
Pinky's up-target not 4 ahead, but 4 ahead and 4 to the left
...
If false, a more accurate implementation, the pacman bugfix, is
used:
pixel accurate tile position for collision tests
Pinky's up-target to be 4 ahead as intended
...
Manhatten Distance
With the -dist_manhatten mode enabled, see Commandline Arguments
above, the Manhatten distance function is used instead of the Euclidean
default.
Second Player Mode
With the '-2p' mode enabled, see
Commandline Arguments above, a 2nd player can control
Blinky when chasing, scattering or scared.
Testing Options
The following testing options are available
-no_ghosts to disable all ghosts (testing)
-invincible to make pacman invincible (testing)
Implementation Status
Done
Maze
Read maze specification from text file
Sprites
Speed per tile accurate key-frame animation
Weighted tile position from floating position
Renderer fps derived step width, i.e. sub-tiles
Sync speed by dropping tick, every n-frames
Ghost AI
Scatter, chase and phantom targets
Scared RNG target
PRNG with an identical seed value every new level and life for
predictable results
Next direction_t algo
No turning up in Red-Zones if chasing or scattering
Optionally use alternative Manhatten distance function instead of
the Euclidean default.
Grouped wave switch of scatter, chase and frightened
Exit Home
Using local and global pellet timer
Additional maximum time when no pellets are eaten
Speed
Adjust tunnel speed
Elroy 1+2 mode
Pacman
show eaten ghosts and fruit score onscreen (FREEZE)
Freeze pacman only for 3 frames after eating power pellet
Level specification (per level)
Timings
scatter and chase duration per phase
frightening/powered duration
Speed
pacman normal on empty tile or eating
pacman powered on empty tile or eating
ghost speed normal, frightening or in tunnel
Score
Score
ghost 1-4 per power pellet
Fruits / Bonus
Sound
Using chunks (wav/mp3), mixed from seperated channels
Use lossy formats where applicable
Persistent game state
Snapshot (screenshot)
Video recording via bmp snapshots each frame
Extension
Second player controls Blinky when chasing, scattering or
scared
To Do
Pacman
Lives
Sound
Complete samples
Maze
Render maze itself from maze-spec file
Persistent game state
Save/load game state
Media Data
The pixel data in media/playfield_pacman.png and
media/tiles_all.png are copied from Arcade
- Pac-Man - General Sprites.png, which were submitted and created by
Superjustinbros and assumed to be in the public domain.
Audio samples have been edited using any of the following sources
The included audio samples are incomplete by design, only
demonstrating utilizing sound from a coding perspective using loops and
concurrently mixed channels.
Changes
1.0.0
Reached clean code demo stage with functional implementation.
0.2.0
Stability, next_target bug fix and alternative distance
function
0.1.0
Usable working state with most ghost algorithms for further analysis
and demonstration
0.0.1
Initial commit with working status and prelim ghost algorithm.