Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WRITE A C++ Program which simulates a race between several cars. http://www.cheg

ID: 656811 • Letter: W

Question

WRITE A C++ Program which simulates a race between several cars.

http://www.chegg.com/homework-help/questions-and-answers/program-simulates-race-two-cars-c-language-include-using-namespace-std-include-car-header--q7066391

This is a link to complete fully working LAB08 with Header and class files included. Just have to make changes in Lab08 as asked in this LAB.

NEED URGENT HELP.............. MAXIMUM POINTS WILL BE AWARDED.............

Lab Exercise For this lab you must extend and revise the program that you created for lab 8. You must: Ask the user how many cars they would like to race Get the name of each driver from the user Store ail the cars in a vector Simulate the race for all the cars. In all other respects this program should work just like the program you were asked to create for Lab 8.

Explanation / Answer

#include<iostream>

using std :: count;

using std :: end;

int main()

{

while(device->run())

{

driver->beginScene(true, true, SColor(255,100,101,140));

     camera->setTarget(vector3df(carData.carBodyNode->getPosition().X,

carData.carBodyNode->getPosition().Y+3,

carData.carBodyNode->getPosition().Z ));   

    if(staticCamera)

        camera->setPosition(vector3df(carData.carBodyNode->getPosition().X,

count<<"carData.carBodyNode->getPosition().Y+3"<<end,

             count<<"carData.carBodyNode->getPosition().Z + 7))"<<end

smgr->drawAll();

device->getGUIEnvironment()->drawAll();        

driver->endScene();

  physics.update();

}

ISceneNode* dynamicShereNode = smgr->addSphereSceneNode(0.70f);

dynamicShereNode->setMaterialFlag(video::EMF_LIGHTING, false);

ITexture * ballTexture = driver->getTexture("../media/Balls/BeachBallColor.jpg");

dynamicShereNode->setMaterialTexture(0,ballTexture);

SPhysicsSphere dynamicSphere;

dynamicSphere.bodyType = EBT_DYNAMIC;

dynamicSphere.mass = 1.1;

dynamicSphere.radius_x = .70f;

dynamicSphere.radius_y = .70f;

dynamicSphere.radius_z = .70f;

dynamicSphere.node = dynamicShereNode;

IPhysicsEntity* dynamicSphereEntity = physics.addEntity(&dynamicSphere);

Void Class Event()

{

if(event.EventType == EET_KEY_INPUT_EVENT)

{

    if(event.KeyInput.Key == KEY_UP)

    {

        if(!m_keys[KEY_UP])

        {

            m_keys[KEY_UP] = true

            m_car->setThrottlePercent(1.0f);

        }

        else if(event.KeyInput.PressedDown == false)

        {

            m_keys[KEY_UP] = false;

        }

    }

    if(event.KeyInput.Key == KEY_DOWN)

    {

        if(!m_keys[KEY_DOWN])

        {

            m_keys[KEY_DOWN] = true;

count<<" m_car->setThrottlePercent(-100.0f)"<<end;

        }

        else if(event.KeyInput.PressedDown == false)

        {

            m_keys[KEY_DOWN] = false;

        }

    }

Hide   Copy Code

if(!m_keys[KEY_LEFT] && !m_keys[KEY_RIGHT])

{

count<<"m_car->setSteeringPercent(0.0f)"<<end;

}

if(event.KeyInput.Key == KEY_KEY_C)

{

    dropDynSphere(m_smgr,m_driver,m_physics,m_car);

}

else if(event.KeyInput.Key == KEY_KEY_V)

{

count<<"m_car->setPosition(vector3df(m_car->getPosition().X"<<end; ,

count<<"m_car->getPosition().Y + 3 ,m_car->getPosition().Z))"<<end;

count<<"m_car->setRotation(vector3df(m_car->getRotation().X +90"<<end,

count<<"m_car->getRotation().Y,m_car->getRotation().Z))"<<end;

}

else if(event.KeyInput.Key == KEY_F3)

{

    staticCamera= true;

}

else if(event.KeyInput.Key == KEY_F2)

    staticCamera = false;

}

if(!m_keys[KEY_UP] && !m_keys[KEY_DOWN])

{

count<<"m_car->setThrottlePercent(0.0f)"<<end;

}