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;
Pac-Man will most likely have more states and sprites than the ghosts.
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