Look Here First

Curious why I created this blog? The following two posts explain it all. Click on the titles below to read more.

What this Blog is about.

Project Description.

Sunday, April 10, 2011

Game Design: Character Storage.

The idea of most video games is you have a character that affects the environment around it.  Pac-Man runs through a maze gobbling up Pac-Dots and the occasional ghost.  The ghosts in turn can ruin Pac-Man's day if they touch him, while they are strong.  The purpose of this section is to identify data which would be valuable to be associated with Pac-Man or each of the four ghosts.

Position:  If Pac-Man and the Ghosts are confined to the maze, there must be information at hand of where to draw the sprite that represents the character.  Position helps determine if what direction the character can move, whether it has run into another character, pac-dot, power pellet or wall.  Position is probably the single most important attribute about the character.

State: Is a ghost dark blue and ready to be eaten?  Is Pac-Man in the throes of his over-dramatic death animation?  Does Pac-Man have his mouth open or shut?  All this information can be stored in one or more variables that tell the program about the characters state.

Sprites: If each character has quick access to information on how to draw it.  Drawing the screen can be simplified.

Color Palette: The sprites were designed so that the colors can be changed easily. On the ghosts that only thing that changes from character to character (in appearance) is the colors.  Storing the color palette for each character makes sense.

Direction: In Pac-Man the characters are always in motion.  Storing the position in which a character is moving seems natural.

There may be other data that makes sense to be added to the character record later on.
Below are examples of possible structures (the student would prefer to avoid classes and other C++ code if possible) to serve as character storage.

struct  PacMan
    point  mPosition;
    pstate  mState;
    int     mColors[12];
    unsigned char mSprites[X][64];
    usigned char mDirection;

struct Ghost
    point  mPosition;
    gstate  mState;
    int     mColors[12];
    unsigned char mSprites[Y][64];
    usigned char mDirection;

Pac-Man will most likely have more states and sprites than the ghosts.

No comments:

Post a Comment