ECE 291 Final Project - Pacman's Great Adventures  
 
 This game is a re-make of the classic Pacman game, revamped for the 80x86 with VGA graphics, SoundBlaster audio, and new game features.  Pacman roams around the mazes trying to collect as many pellets as possible without being caught by the ghosts.  The game has many levels to play and different difficulty levels.  The special two-player head-to-head mode allows the second player to control the four ghosts.


 

Implementation

The game is broken down into five major parts: AI, gameplay/game engine, 2D animation, 2D graphics, sound.  We are trying for an AI that gets progressively harder based on difficulty and level, also showing the different "personalities" of each ghost.  The gameplay/game engine consists of the interface with the keyboard and mouse, and the logic behind the movement of the characters in the game.  To make the game look more continuous, 2D animation must be used.  Using PCX files and 2D graphics procedures, we load the images of our game from files, then translate it to a playable map based on data maps.  This also allows other PCX file images to be used so that we can easily change what the pieces of the game look like.  We will use SoundBlaster sound effects, and also MIDI quality music to improve the general gameplay. One neat feature of our game is the addition of a Board Editor. It allows the user to create his or her own levels.

2D Graphics The moveable components of the game (i.e. ghosts, pacman, fruit), work on a continuous X,Y basis.  The non-moving components use a Board array that works in a "block" format.  The DataArray consists of numbers telling the engine what to display at that "block" (our gameboard is 20x20 blocks).  The moveable components can move within blocks however, to simulate animation, and so that pacman doesn't have to be exactly on a block to be killed by or to eat a ghost.  Continuous X,Y is the same as the pixel value, so unlike the blocks, the moveable components can have 320x200 values.  There will be a constant step value for pacman and fruit, because they will probably move more than 1 pixel at a time.  There is also a ghost step value, but this changes with difficulty and level, thus simulating a faster ghost.


 

Team Members

Constants
 
Constants relating to board and block dimensions:

BOARDEDGE       EQU 60
BLOCKDIM        EQU 10
BOARDDIM        EQU 20
OVERLAP         EQU 2

Movement constants:

GOUP            EQU 0
GORIGHT         EQU 1
GODOWN          EQU 2
GOLEFT          EQU 3

Look-Up Tables

DeltaFruitX - change in x coordinates for indexed direction
DeltaFruitY - change in y coordinates for indexed direction
Intersection - table containing values of intersections
DeltaBlockX - block x-coordinate change
DeltaBlockY - block y-coordinate change
DeltaPacX - Change in pacman's pixel x-coordinate
DeltaPacY - Change in pacman's pixel y-coordinate
DeltaGstX - Change in ghost pixel x-coordinate
DeltaGstY - Change in ghost pixel y-coordinate
WarpX - Change in x-coordinate of warping
WarpY - Change in y-coordinate of warping
OpDirTable - opposite direction lookup table
OpAxisDir - opposite axis diections
GhostTimer - lookup table to see when ghosts leave the box
Method - Computer AI lookup table based on difficulty and personality
FruitScoreIndex - index for offsets of fruit score
GhostScoreIndex - index for offsets of ghost score
 
 

Global Variables

The procedures of the game input and output, primarily global variables.  This is the list of variables used by our game:

WORD GhostX - array of the four ghost X-positions
WORD GhostY - array of the four ghost Y-positions
WORD PacX - X-position of Pacman
WORD PacY - Y-position of Pacman
WORD FruitX - X-position of fruit/bonus piece
WORD FruitY - Y-position of fruit/bonus piece
WORD FruitDir - angle/direction of Fruit movement
WORD PacDir - View angle/direction Pacman is facing
WORD GhostDir - array of the four ghost view angles
WORD BoardLocation - Offset of the DataArray
WORD PacState - current state of pacman (animation of pacman opening and closing mouth)
WORD LevelData - array of offsets pointing to filenames of each level's map data
WORD TotalPellets - Total pellets on the current board
WORD Pelletsleft - number of pellets left on the current level
WORD GhostSelect - flags which ghost is being controlled by the second player
WORD Randval - random value seed
WORD MemLoc - 20-bit linear address used by sound procedure
DOUBLE EngineCycles - numebr of mainloop iterations for the current level
BYTE   Pause_Flag - flag determining when game is paused
BYTE   Quit - flag for quitting of game
BYTE   PacLives - Number of lives left
BYTE   MoveBuffer1 - next move pacman will make
BYTE   MoveBuffer2 - next move the selected ghost will make
BYTE   PowerPelletFlag - array of flags determining when and which ghosts are vunerable
BYTE   GhostData - array that holds information about ghost AI
BYTE   GhostStep - translates to the "speed" of the ghosts, which changes throughout the game
BYTE   BlockPX - block X-position of pacman
BYTE   BlockPY - block Y-position of pacman
BYTE   Gamedata - string holding filename of TextSeg file
BYTE   DelayC - Delay Consant
BYTE   Length1 - length of file for sound procedure

Segments

SBSeg: screen buffer segment -> outputs directly to screen
LevelSeg: wall, pellet element segments (changes per level)
ScratchSeg: scratch segment (used by LoadPCX)
TextSeg: textures segment, containing ghost, pacman, and fruit images

Procedures

Gameplay/Game Engine

InstKey/GameKeyInt/DeinstKey

Mouse_Control

MoveGhost

MovePacMan

CalcBlockRound

GetBoardValue

PutBoardValue

BlockXY

ExitGhost

SetUpGameData

InitHighScore

ChangePacState

SetUpLevelData

CheckArray

2D Animation

Pacman_Death

Ghost_Death

Fruit_Death

CheckDeath

DrawPacman

DrawGhost

DrawFruit

 

2D Graphics

Introduction

ExitDisplay

DrawScore

DrawDigits

DrawPacLife

DrawFruitLevel

DrawBlockPart

DrawBoardPart

DrawArray

DrawPacKills

DrawRectangle

DrawBlock

ClearScreenBuffer

ShowScreenBuffer

LoadPCX

Artificial Intelligence

ComputeAI

Sound and Music

RegisterXmidi

PlaySequence

MidiStop

ResumePlaying

 

Board Editor Procedures

CalcCursorBlock

EditMouseControl

DrawEditor

BoardEditor

General Procedures

RandVal

Delay

DefineCustom

IntroMouseControl

DrawIntroScreen

DrawIntroButton

IntroductionAnimation

DrawIntroImages

CreditAnimation

DrawCreditImages

Credits