Powerup munchies

When the player collects a 'Powerup munchie' (gold munchie) it resets the 'ghostFrightTimer', 'frightCounter' and image 'sourcRect' (in the Y direction) for each ghost. Also activating the new texture and setting 'destructable' and 'ghostFright' to be true so when they are collided with they are destroyed.



if (_munchies[i]->type == "Powerup")
{
 _menu->ghostFrightTimer = 0;
 for (int i = 0; i < _menu->ghostCounter; i++)
 {
  _ghosts[i]->frightCounter = 0;
  _ghosts[i]->sourceRect->Y = 0;
  _ghosts[i]->texture = _menu->frightTexture;
  _ghosts[i]->destructable = true;
 }
 _menu->ghostFright = true;
}

Wall Hitbox

Calculate the position of each side of the wall using simple maths. The sides are then used in collision logic with various other sprites in the game.


bottom = _walls[i]->Position->Y + _walls[i]->sourceRect->Height;
left = _walls[i]->Position->X;
right = _walls[i]->Position->X + _walls[i]->sourceRect->Width;
top = _walls[i]->Position->Y;
centerX = _walls[i]->Position->X + _walls[i]->sourceRect->Width / 2;
centerY = _walls[i]->Position->Y + _walls[i]->sourceRect->Height / 2;

Sprite sheet

A sprite sheet is a set of smaller images in one big image in a table like format. After each frame the sourceRectX is updated to implement a moving animation for Pacman. The sourceRectY is updated depending on the direction its moving so the image is changed to match the direction Pacman is moving.


_pacman->SourceRect->X = _pacman->SourceRect->Width * _pacman->Frame;
if (_pacman->Direction == 1)
{
 _pacman->SourceRect->Y = 96;
}
if (_pacman->Direction == 3)
{
 _pacman->SourceRect->Y = 64;
}
if (_pacman->Direction == 2)
{
 _pacman->SourceRect->Y = 32;
}
if (_pacman->Direction == 0)
{
 _pacman->SourceRect->Y = 128;
}
else
{
 _pacman->SourceRect->X = 0;
}
				

Pause menu

When the pause key is lifted it sets 'pKeyDown' to false. When the pause key is pressed and 'pKeyDown' is false it sets 'paused' boolean to opposite of the currenty state its in; if its unpaused, it pauses, and if paused, it unpauses. The 'pKeyDown' boolean is used to stop the menu flickering between states when the user is pressing the pause key.


void Pacman::CheckPaused(Input::KeyboardState* state, Input::Keys pauseKey)
{
 if (state->IsKeyUp(pauseKey))
 {
  _menu->pKeyDown = false;
 }
 if (state->IsKeyDown(pauseKey) && !_menu->pKeyDown)
 {
  _menu->pKeyDown = true;
  _menu->paused = !_menu->paused;
 }
}

Feedback

As it is a University assigment I recieved a mark for hitting certain criteria. Here is a breakdown of the marks;

User Interaction & Collision Detection

8/8

Skeleton code extended to enable Monster movement in all 4 directions using arrow keys or WASD. Monster confined to game board in all 4 directions or appropriate wrapping.

Player Animation

12/12

Player animation implemented so player faces the direction of movement and is animated.

Sound

8/8

Sounds play when in-game events occur. For example - sprite hits/wraps through a wall, collecting munchies, death etc.

Multiple animated collectable items

12/12

Different 2D images used for the collectible items. 2 or more items should be used and should be animated.

Sprite animations

15/15

Larger variety of sprites beyond the minimum requirements listed above. Walking / explosion animations.

User & game interaction

20/20

User interaction, feedback and sounds beyond the minimal application, responds to events such as collisions, gameplay and scoring.

Other

20/20

For example: * State machine * Other levels * High-score table.

Report

2/3

A brief description of the game concept with accompanying screenshots. Keyboard controls etc.

Video

2/2

A video capture of your game in action. Should highlight all features mentioned in the rubric.

Total: 99/100