Microsoft Word - spec.docx 2 Table of Contents Introduction ...................................................................................................... XXXXXXXXXX5 Game Details...

1 answer below »
This is a C++ assignment. Please assist me with the part two assignment. I have worked out some, not sure if they meet the requirements.


Microsoft Word - spec.docx 2 Table of Contents Introduction ......................................................................................................................... 5 Game Details ....................................................................................................................... 7 Determining Object Overlap ......................................................................................... 10 So how does a video game work? ..................................................................................... 11 What Do You Have to Do? ............................................................................................... 14 You Have to Create the StudentWorld Class ................................................................ 15 init() Details ............................................................................................................... 17 move() Details ........................................................................................................... 19 Give Each Actor a Chance to Do Something ........................................................ 21 Remove Dead Actors After Each Tick .................................................................. 21 Add New Actors As Required During Each Tick ................................................. 22 Border Lines ...................................................................................................... 22 Zombie Cabs ...................................................................................................... 22 Determining a Starting Position and Initial Movement Plan of a Zombie Cab ....................................................................................................................... 22 Oil Slicks ........................................................................................................... 23 Zombie Peds ...................................................................................................... 23 Human Peds ....................................................................................................... 24 Holy Water Refill Goodies ................................................................................ 24 Lost Soul Goodies ............................................................................................. 24 cleanUp() Details .............................................................................................
Answered 2 days AfterFeb 24, 2021

Answer To: Microsoft Word - spec.docx 2 Table of Contents Introduction...

Swapnil answered on Feb 26 2021
149 Votes
76388/Actor.cpp
#include "Actor.h"
#include "StudentWorld.h"
using namespace std;
Actor::Actor( StudentWorld* world, int imageID, int startX, int startY, int startDirection, double size, int depth,
             bool alive, int health, bool avoidanceWorthy, int yVel, int xVel )
    : GraphObject(imageID, startX, startY, startDirection, size, depth),
     m_world(world), m_alive(alive), m_health(health), m_avoidanceWorthy(avoidanceWorthy),
     m_yVel(yVel), m_xVel(xVel)
{
}
void Actor::doSomething()
{
    if (! isAlive())
    {
        return;
    }
    doSomethingSpecializedA();
    moveActor();
    doSomethingSpecializedB();
}
void Actor::moveActor()
{
    int vert_speed = getYVelocity() - getWorld()->getRacer()->get
YVelocity();
    int horiz_speed = getXVelocity();
    double new_y = getY() + vert_speed;
    double new_x = getX() + horiz_speed;
    moveTo(new_x, new_y);
    if (getY() < 0 || getX() < 0 || getX() > VIEW_WIDTH || getY() > VIEW_HEIGHT)
    {
        setAliveSatus(false);
        return;
    }
}
void Actor::damageActor(int soundHurt, int soundDead, int direction, int damage)
{
    changeHealth(damage);
    if(getHealth() <= 0)
    {
        setAliveSatus(false);
        getWorld()->playSound(soundDead);
        specializedDamageA();
    }
    setDirection(direction);
    getWorld()->playSound(soundHurt);
    specializedDamageB();
}
GhostRacer::GhostRacer( StudentWorld* world, int imageID, int startX, int startY, int startDirection, double size, int depth,
                        bool alive, int health, bool avoidanceWorthy, int yVel, int xVel,
                        int sprays )
    : Actor(world, imageID, startX, startY, startDirection, size, depth, alive, health, avoidanceWorthy, yVel, xVel),
     m_sprays(sprays)
{
}
void GhostRacer::doSomethingSpecializedA()
{
    int ch;
    if (getX() <= LEFT_EDGE)
    {
        if (getDirection() > FACING_STRAIGHT)
            damageActor(SOUND_VEHICLE_CRASH, SOUND_PLAYER_DIE, FACING_STRAIGHT - INCREMENT_DIR, HP_LOSS_HIT_EDGE);
    }
    else if (getX() >= RIGHT_EDGE)
    {
        if (getDirection() < FACING_STRAIGHT)
            damageActor(SOUND_VEHICLE_CRASH, SOUND_PLAYER_DIE, FACING_STRAIGHT + INCREMENT_DIR, HP_LOSS_HIT_EDGE);
    }
    else if (getWorld()->getKey(ch))
    {
        switch (ch)
        {
            case KEY_PRESS_SPACE:
                if (getSprays() >= 1)
                {
                }
                break;
            case KEY_PRESS_LEFT:
                if (getDirection() < FACING_STRAIGHT + 3 * INCREMENT_DIR)
                    setDirection(getDirection() + INCREMENT_DIR);
                break;
            case KEY_PRESS_RIGHT:
                if (getDirection() > FACING_STRAIGHT - 3 * INCREMENT_DIR)
                    setDirection(getDirection() - INCREMENT_DIR);
                break;
            case KEY_PRESS_UP:
                if (getYVelocity() < MAX_RACER_VEL)
                    changeYVel(1);
                break;
            case KEY_PRESS_DOWN:
                if (getYVelocity() > MIN_RACER_VEL)
                    changeYVel(-1);
                break;
        }
    }
}
void GhostRacer::moveActor()
{
    double max_shift_per_tick = 4.0;
    double direction = degreesToRad(getDirection());
    double delta_x = cos(direction) * max_shift_per_tick;
    double cur_x = getX();
    double cur_y = getY();
    moveTo(cur_x + delta_x, cur_y);
}
BorderLine::BorderLine( StudentWorld* world, int imageID, int startX, int startY, int startDirection, double size, int depth,
                         bool alive, int health, bool avoidanceWorthy, int yVel, int xVel )
    : Actor(world, imageID, startX, startY, startDirection, size, depth, alive, health, avoidanceWorthy, yVel, xVel)
{
}
Pedestrian::Pedestrian( StudentWorld* world, int startX, int startY, int imageID, int startDirection, double size, int depth,
                        bool alive, int health, bool avoidanceWorthy, int yVel, int xVel, int movePlan )
    : Actor(world, imageID, startX, startY, startDirection, size, depth, alive, health, avoidanceWorthy, yVel, xVel),
    m_movePlan(movePlan)
{
}
void Pedestrian::doSomethingSpecializedA()
{
    if (getWorld()->doesOverlap(this, getWorld()->getRacer()))
    {
        setAliveSatus(false);
        getWorld()->getRacer()->setAliveSatus(false);
        return;
    }
}
void Pedestrian::doSomethingSpecializedB()
{
    changeMovePlan(-1);
    if (getMovePlan() > 0)
    {
        return;
    }
    const int nSpeeds = 6;
    const int possibleXVels[nSpeeds] = { -3, -2, -1, 1, 2, 3 };
    int randIndex = randInt(0, nSpeeds - 1);
    setXVelocity(possibleXVels[randIndex]);
    setMovePlan(randInt(4, 32));
    if (getXVelocity() < 0)
    {
        setDirection(180);
    }
    else if (getXVelocity() > 0)
    {
        setDirection(0);
    }
}
ZombiePedestrian::ZombiePedestrian( StudentWorld* world, int startX, int startY, int imageID, int startDirection, double size, int depth,
                             bool alive, int health, bool avoidanceWorthy, int yVel, int xVel, int movePlan, int nextGrunt )
    : Pedestrian(world, startX, startY, imageID, startDirection, size, depth, alive, health, avoidanceWorthy, yVel, xVel, movePlan),
    m_tickToNextGrunt(nextGrunt)
{
}
76388/GameController.cpp
#include "freeglut.h"
#include "GameController.h"
#include "GameWorld.h"
#include "GameConstants.h"
#include "GraphObject.h"
#include "SoundFX.h"
#include "SpriteManager.h"
#include
#include
#include
#include
#include
using namespace std;
static const int WINDOW_WIDTH = 768;
static const int WINDOW_HEIGHT = 768;
static const int PERSPECTIVE_NEAR_PLANE = 4;
static const int PERSPECTIVE_FAR_PLANE    = 22;
static const double VISIBLE_MIN_X = -2.39;
static const double VISIBLE_MAX_X = 2.1;
static const double VISIBLE_MIN_Y = -2.1;
static const double VISIBLE_MAX_Y = 1.9;
static const double VISIBLE_MIN_Z = -20;
static const double FONT_SCALEDOWN = 760.0;
static const double SCORE_Y = 3.8;
static const double SCORE_Z = -10;
static const int MS_PER_FRAME = 5;
int GameController::m_ms_per_tick = kDefaultMsPerTick;
struct SpriteInfo
{
    unsigned int imageID;
    unsigned int frameNum;
    std::string     tgaFileName;
};
static void convertToGlutCoords(double x, double y, double& gx, double& gy, double& gz);
static void drawPrompt(string mainMessage, string secondMessage);
static void drawScoreAndLives(string);
enum GameController::GameControllerState : int {
welcome, contgame, finishedlevel, init, cleanup, makemove, animate, gameover, prompt, quit, not_applicable
};
void GameController::initDrawersAndSounds()
{
    SpriteInfo drawers[] = {
        { IID_GHOST_RACER     , 0, "redcar.tga" },
        { IID_WHITE_BORDER_LINE     , 0, "white-lane.tga" },
        { IID_YELLOW_BORDER_LINE , 0, "yellow-lane.tga" },
        { IID_OIL_SLICK    , 0, "oil.tga" },
        { IID_HUMAN_PED    , 0, "dude_1.tga" },
        { IID_HUMAN_PED    , 1, "dude_2.tga" },
        { IID_HUMAN_PED    , 2, "dude_3.tga" },
        { IID_ZOMBIE_PED    , 0, "zombie_1.tga" },
        { IID_ZOMBIE_PED    , 1, "zombie_2.tga" },
        { IID_ZOMBIE_PED    , 2, "zombie_3.tga" },
        { IID_ZOMBIE_CAB         , 0, "yellow.tga" },
        { IID_HOLY_WATER_PROJECTILE     , 0, "water1.tga" },
        { IID_HOLY_WATER_PROJECTILE     , 1, "water2.tga" },
        { IID_HOLY_WATER_PROJECTILE     , 2, "water3.tga" },
        { IID_HEAL_GOODIE , 0, "health.tga"},
        { IID_HOLY_WATER_GOODIE , 0, "holy_water.tga"},
        { IID_SOUL_GOODIE , 0, "soul.tga"},
    };
    SoundMapType::value_type sounds[] = {
        make_pair(SOUND_PED_HURT            , "hurt.wav"),
        make_pair(SOUND_VEHICLE_HURT ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here