Road rage was an assignment to incorporate the previously developed FSM into a 2D, short game prototype. The final product was an R-Type styled game where cars on a road attempt to crash into the players car, the player is able to blast other cars off the road with rockets. This project gave me an excellent insight on how to effectively use pointers.

 

 

Code Snippet:

 


#include "Game.h"
// Namespaces.
 using namespace WlvGameFramework;
 using namespace std;
/****************************************************************
 * Public Methods.
 ****************************************************************/
/****************************************************************
 * The Game class constructor.
 ****************************************************************/
 Game::Game(HINSTANCE hInstance, bool gameWindowed, bool useDepthStencilView) :
 GameManager(hInstance, gameWindowed, useDepthStencilView) // constructor initializer list.
 { // This calls the parent class constructor.
}
/****************************************************************
 * The Game class destructor.
 ****************************************************************/
 Game::~Game(){
}
/****************************************************************
 * Private Methods.
 ****************************************************************/
/****************************************************************
 * Load game content.
 ****************************************************************/
 void Game::loadContent(){
/****************************************************************
 * Players Car entity.
 ****************************************************************/
 // First initialize the entity. This call creates the vertex buffer.
 humanPlayerEntity.initializeEntity(0.9f,0.4f);
// Next create a list using a vector to store your frames of animation
 // (or textures).
 vector myTextures;
 // Add all the frames of animation for a particular direction.
 myTextures.push_back("graphics/car.png");
 // Add the textures to the entity.
 // myTextures = the frames of animation for a particular direction.
 // animationId - Use an id / index for the animation. This could indicate direction - E.g. 0 = up, 1 = right, etc.
 // 1 = the animationId. You use this index to identify the frames of animation.
 humanPlayerEntity.setTexture(myTextures, 0);
// Set the current animationId. 2 = a left direction in this case.
 humanPlayerEntity.setAnimationId(0);
 // Set the speed of the entity.
 humanPlayerEntity.setSpeed(4);
 // Set how long each frame of animation should last.
 humanPlayerEntity.setMillisecondsPerAnimationFrame(0.0f);
 // Set the position of the car.
 humanPlayerEntity.setPositionX(-5.0f);
 myTextures.clear();
/****************************************************************
 * roadAnimatedBackgroundBasicEntity.
 ****************************************************************/
 roadAnimatedBackgroundBasicEntity.initializeEntity(6.3f, 6.3f);
 myTextures.push_back("graphics/straightroad.png");
 myTextures.push_back("graphics/straightroad.png");
 roadAnimatedBackgroundBasicEntity.setSpeed(5.0f);
 roadAnimatedBackgroundBasicEntity.setTexture(myTextures);
 roadAnimatedBackgroundBasicEntity.setDirectionUpX();
myTextures.clear();
// Game menu (FSM) variables.
 // ****************************************************************
/****************************************************************
 * menuBackgroundEntity.
 ****************************************************************/
 menuBackgroundEntity.initializeEntity(6.3f, 6.3f);
 myTextures.push_back("graphics/straightroad.png"); // background 1.
 menuBackgroundEntity.setTexture(myTextures);
 menuBackgroundEntity.setDirectionUpX();
 menuBackgroundEntity.setSpeed(0.005f);
 myTextures.clear();
/****************************************************************
 * menuBackgroundTextEntity.
 ****************************************************************/
 menuBackgroundTextEntity.initializeEntity(3.3f, 2.3f);
 myTextures.push_back("graphics/roadrage.png"); // background 1.
 menuBackgroundTextEntity.setTexture(myTextures);
 menuBackgroundTextEntity.setDirectionUpX();
 menuBackgroundTextEntity.setPosition(-3,2,1);
 menuBackgroundTextEntity.setSpeed(0.0f);
 myTextures.clear();
/****************************************************************
 * menuSpaceShipPointerEntity.
 ****************************************************************/
 // First initialize the entity. This call creates the vertex buffer.
 menuCarPointerEntity.initializeEntity(1.0f,0.5f);
// Next create a list using a vector to store your frames of animation
 // (or textures).
 // Add all the frames of animation for a particular direction.
 myTextures.push_back("graphics/car.png");
 // Add the textures to the entity.
 // myTextures = the frames of animation for a particular direction.
 // animationId - Use an id / index for the animation. This could indicate direction - E.g. 0 = up, 1 = right, etc.
 // 1 = the animationId. You use this index to identify the frames of animation.
 menuCarPointerEntity.setTexture(myTextures, 0);
// Set the current animationId. 2 = a left direction in this case.
 menuCarPointerEntity.setAnimationId(0);
 // Set the speed of the entity.
 menuCarPointerEntity.setSpeed(2);
 // Set how long each frame of animation should last.
 menuCarPointerEntity.setMillisecondsPerAnimationFrame(0.1f);
 // Set the position of the car.
 menuCarPointerEntity.setPositionX(2.0f);
 menuCarPointerEntity.setPositionY(2.0f);
 myTextures.clear();
/****************************************************************
 * menuStartEntity.
 ****************************************************************/
 menuStartEntity.initializeEntity(1.0f, 1.0f);
 myTextures.push_back("graphics/start.png"); // background 1.
 menuStartEntity.setTexture(myTextures);
 menuStartEntity.setDirectionUpX();
 menuStartEntity.setSpeed(0.0f);
 menuStartEntity.setPosition(4.5f,2.0f,0.0f);
 myTextures.clear();
/****************************************************************
 * menuOptionsEntity.
 ****************************************************************/
 menuOptionsEntity.initializeEntity(1.0f, 1.0f);
 myTextures.push_back("graphics/options.png"); // background 1.
 menuOptionsEntity.setTexture(myTextures);
 menuOptionsEntity.setDirectionUpX();
 menuOptionsEntity.setSpeed(0.0f);
 menuOptionsEntity.setPosition(4.5f,0.0f,0.0f);
 myTextures.clear();
/****************************************************************
 * menuExitEntity.
 ****************************************************************/
 menuExitEntity.initializeEntity(1.0f, 1.0f);
 myTextures.push_back("graphics/exit.png"); // background 1.
 menuExitEntity.setTexture(myTextures);
 menuExitEntity.setDirectionUpX();
 menuExitEntity.setSpeed(0.0f);
 menuExitEntity.setPosition(4.5f,-2.0f,0.0f);
 myTextures.clear();
}
/****************************************************************
 * Initialize game content.
 ****************************************************************/
 void Game::InitializeContent(){
// Setup the game score. Param - halfwidth, halfheight.
 myGameScore.initialize(0.5, 0.5);
 // Param - x, y, z.
 myGameScore.setPosition(3.5,8.5,8);
 myGameScore.setScore(0);
// Setup the game score. Param - halfwidth, halfheight.
 myHealthScore.initialize(0.5, 0.5);
 // Param - x, y, z.
 myHealthScore.setPosition(3.5,6.5,8);
 myHealthScore.setScore(100);
// Switch on the mouse cursor.
 this->showCursor(true);
 // Switch debug info on.
 this->setDisplayInfo(true);
rocketsGameFrameDelayCount = 0.5f;
 carGameFrameDelayCount = 1;
 lorryGameFrameDelayCount = 1;
// Set the game state to the main menu.
 gameState = 0;
 // Set the game event to on enter.
 gameEvent = 0;
// Set the current menu option to start.
 // Current menu option. 0 == exit. 1 == start. 2 == options.
 currentMenuOption = 1;
menuGameFrameDelayCount = 0.0f;
 }
/****************************************************************
 * The game loop. The update method.
 ****************************************************************/
 void Game::gameLoop(GameTime gameTime){
// We want to check for input here so we need to get the state objects.
 KeyboardState myKeyboardState = this->getkeyboardState();
 MouseState myMouseState = this->getMouseState();
switch(gameState){
 // The main menu..
case 0:
 if (gameEvent == 0){
 // Enter the state.
 gameEvent = 1;
 break;
 }
 if (gameEvent == 1){
 // Update the state.
 menuCarPointerEntity.setEntityMoved(true);
if(menuGameFrameDelayCount >= 0){
 menuGameFrameDelayCount -= gameTime.elpasedTimeSinceLastFrame_Seconds;
 }
 if(menuGameFrameDelayCount <= 0){ if ( myKeyboardState.IsKeyDown( VK_ESCAPE ) ){ this->quitGame();
 }
if ( myKeyboardState.IsKeyDown( VK_UP ) ){
 if(currentMenuOption == 0){
 // Current = Exit. Move up to Options.
 menuCarPointerEntity.setPositionY(0.0f);
 currentMenuOption = 2;
 menuGameFrameDelayCount = 0.2f;
 break;
 }
 if(currentMenuOption == 1){
 // Current = Play. No where to move up to.
 break;
 }
 if(currentMenuOption == 2){
 // Current = Options. Move up to Play.
 menuCarPointerEntity.setPositionY(2.0f);
 currentMenuOption = 1;
 menuGameFrameDelayCount = 0.2f;
 break;
 }
 }
if ( myKeyboardState.IsKeyDown( VK_DOWN ) ){
 if(currentMenuOption == 0){
 // Current = Exit. No where to move down to.
 break;
 }
 if(currentMenuOption == 1){
 // Current = Play. Move down to options.
 menuCarPointerEntity.setPositionY(0.0f);
 currentMenuOption = 2;
 menuGameFrameDelayCount = 0.2f;
 break;
 }
 if(currentMenuOption == 2){
 // Current = Options. Move down to Exit.
 menuCarPointerEntity.setPositionY(-2.0f);
 currentMenuOption = 0;
 menuGameFrameDelayCount = 0.2f;
 break;
 }
 }
if ( myKeyboardState.IsKeyReleased( VK_RETURN ) ){
 if(currentMenuOption == 1){
 gameEvent = 2;
 }
 if(currentMenuOption == 0){
 this->quitGame();
 }
}
 break;
 }
 }
 if(gameEvent == 2){
 //Exit the state.
 gameEvent = 0;
 gameState = 1;
 break;
 }
 break;
// The Main game..
 case 1:
 if (gameEvent == 0){
 // Enter the state.
 gameEvent = 1;
 break;
 }
 if (gameEvent == 1){
 // The main gameloop code for the main game.
if ( myKeyboardState.IsKeyDown( VK_ESCAPE ) ){
 gameEvent = 2;
 menuGameFrameDelayCount = 0.2f;
 }
// Keyboard test..
 if ( myKeyboardState.IsKeyDown( VK_UP ) ){
 if (humanPlayerEntity.getPositionY() < 5){ humanPlayerEntity.moveUpY(gameTime.elpasedTimeSinceLastFrame_Seconds); } } if ( myKeyboardState.IsKeyDown( VK_DOWN ) ){ if (humanPlayerEntity.getPositionY() > -5){
 humanPlayerEntity.moveDownY(gameTime.elpasedTimeSinceLastFrame_Seconds);
 }
}
if ( myKeyboardState.IsKeyDown( VK_RIGHT ) ){
 if (humanPlayerEntity.getPositionX() < 0){ humanPlayerEntity.moveUpX(gameTime.elpasedTimeSinceLastFrame_Seconds); roadAnimatedBackgroundBasicEntity.setSpeed(10.0f); } } if ( myKeyboardState.IsKeyDown( VK_LEFT ) ){ if (humanPlayerEntity.getPositionX() > -5){
 humanPlayerEntity.moveDownX(gameTime.elpasedTimeSinceLastFrame_Seconds);
 }
 }
// Always set the entity to moved so the animation will always play.
 humanPlayerEntity.setEntityMoved(true);
// Count the delay down to zero - rocketsGameFrameDelayCount.
 if(rocketsGameFrameDelayCount >= 0){
 rocketsGameFrameDelayCount -= gameTime.elpasedTimeSinceLastFrame_Seconds;
 }
// Check if the fire button has been pressed.
 if ( myKeyboardState.IsKeyDown( VK_SPACE ) || myMouseState.isLeftButtonDown() ){
 if(rocketsGameFrameDelayCount <= 0){ // Fire a rocket!!!! rocketsGameFrameDelayCount = 0.4f; /**************************************************************** * rocketsBasicEntity. ****************************************************************/ // Create a new rocket pointer. BasicEntity* aRocketsBasicEntity = new BasicEntity(); // First initialize the entity. This call creates the vertex buffer. aRocketsBasicEntity->initializeEntity(0.25f,0.15f);
 // Next create a list using a vector to store your frames of animation
 // (or textures).
 vector myTextures;
 // Add all the frames of animation for a particular direction.
 myTextures.push_back("graphics/rocket1.png"); // frame 1.
// Add the textures to the entity.
 // myTextures = the frames of animation for a particular direction.
 // animationId - Use an id / index for the animation. This could indicate direction - E.g. 0 = up, 1 = right, etc.
 // 1 = the animationId. You use this index to identify the frames of animation.
 aRocketsBasicEntity->setTexture(myTextures, 0);
 myTextures.clear();
// Set the current animationId. 2 = a left direction in this case.
 aRocketsBasicEntity->setAnimationId(0);
 // Set the speed of the entity.
 aRocketsBasicEntity->setSpeed(2.0f);
 // Set how long each frame of animation should last.
 aRocketsBasicEntity->setMillisecondsPerAnimationFrame(0.1f);
 // Set the position of the space ship.
 aRocketsBasicEntity->setPosition(humanPlayerEntity.getPositionX() + 0.5f, humanPlayerEntity.getPositionY(), humanPlayerEntity.getPositionZ() );
 // Add the rocket to our list of rockets.
 rocketsBasicEntity.push_back(aRocketsBasicEntity);
 /****************************************************************
 * END - rocketsBasicEntity.
 ****************************************************************/
 }
 }
// Count the delay down to zero - carGameFrameDelayCount.
 if(carGameFrameDelayCount >= 0){
 carGameFrameDelayCount -= gameTime.elpasedTimeSinceLastFrame_Seconds;
 }
 if(carGameFrameDelayCount <= 0){ // Create a new object and add it to the list. carGameFrameDelayCount = 1; /**************************************************************** * car basic entity. ****************************************************************/ // Create a new rocket pointer. BasicEntity* aNPCCar = new BasicEntity(); // First initialize the entity. This call creates the vertex buffer. aNPCCar->initializeEntity(0.9f,0.4f);
 // Next create a list using a vector to store your frames of animation
 // (or textures).
 vector myTextures;
 // Add all the frames of animation for a particular direction.
 myTextures.push_back("graphics/NPCCar.png"); // frame 1.
 // Add the textures to the entity.
 // myTextures = the frames of animation for a particular direction.
 // animationId - Use an id / index for the animation. This could indicate direction - E.g. 0 = up, 1 = right, etc.
 // 1 = the animationId. You use this index to identify the frames of animation.
 aNPCCar->setTexture(myTextures, 0);
 myTextures.clear();
// Set the current animationId. 2 = a left direction in this case.
 aNPCCar->setAnimationId(0);
 // Set the speed of the entity.
 if (myGameScore.getScore() < 40){ srand ( ( float)time(0) ); float myCarRandNum = rand() % 10 - 2; aNPCCar->setSpeed(myCarRandNum);
 }
 else{
 srand ( ( float)time(0) );
 float myCarRandNum = rand() % 10 + 2;
aNPCCar->setSpeed(myCarRandNum);
 }
// Set how long each frame of animation should last.
 aNPCCar->setMillisecondsPerAnimationFrame(0.1f);
// Generate a random x position.
 srand ( (unsigned int)time(0) );
 int myRandNum = rand() % 10 - 5;
aNPCCar->setPosition(9, (float)myRandNum,0);
 // Add the rocket to our list of rockets.
 carNPCEntity.push_back(aNPCCar);
/****************************************************************
 * END - car NPC.
 ****************************************************************/
 }
// Count the delay down to zero
 if(lorryGameFrameDelayCount >= 0){
 lorryGameFrameDelayCount -= gameTime.elpasedTimeSinceLastFrame_Seconds;
 }
 if(lorryGameFrameDelayCount <= 0){ // Create a new object and add it to the list. lorryGameFrameDelayCount = 1; /**************************************************************** * lorryBasicEntity. ****************************************************************/ // Create a new rocket pointer. BasicEntity* aLorryNPC = new BasicEntity(); // First initialize the entity. This call creates the vertex buffer. aLorryNPC->initializeEntity(1.0f,0.4f);
 // Next create a list using a vector to store your frames of animation
 // (or textures).
 vector myTextures;
 // Add all the frames of animation for a particular direction.
 myTextures.push_back("graphics/bluelorry.png"); // frame 1.
 // Add the textures to the entity.
 // myTextures = the frames of animation for a particular direction.
 // animationId - Use an id / index for the animation. This could indicate direction - E.g. 0 = up, 1 = right, etc.
 // 1 = the animationId. You use this index to identify the frames of animation.
 aLorryNPC->setTexture(myTextures, 0);
 myTextures.clear();
// Set the current animationId. 2 = a left direction in this case.
 aLorryNPC->setAnimationId(0);
 // Set the speed of the entity.
 if (myGameScore.getScore() < 50){ srand ( ( float)time(0) ); float myLorryRandNum = rand() % 10 - 2; aLorryNPC->setSpeed(myLorryRandNum);
 }
 else{
 srand ( ( float)time(0) );
 float myLorryRandNum = rand() % 20 + 2;
aLorryNPC->setSpeed(myLorryRandNum);
 }
// Set how long each frame of animation should last.
 aLorryNPC->setMillisecondsPerAnimationFrame(0.1f);
// Generate a random x position.
 srand ( (unsigned int)time(0) );
 int myRandNum = rand() % 10 - 3;
aLorryNPC->setPosition(7, (float)myRandNum,0);
 // Add the lorry to our list of lorries.
 lorryNPCEntity.push_back(aLorryNPC);
/****************************************************************
 * END - lorry NPC.
 ****************************************************************/
 }
// Move all the rockets and do checks.
 // Loop through the vector (list).
 if(rocketsBasicEntity.size() > 0){
 for (unsigned int i = 0; i < rocketsBasicEntity.size(); i++){ rocketsBasicEntity[i]->moveUpX(gameTime.elpasedTimeSinceLastFrame_Seconds);
 if( rocketsBasicEntity[i]->getPositionX() > 8){
 delete rocketsBasicEntity[i];
 rocketsBasicEntity.erase(rocketsBasicEntity.begin() + i);
 continue;
 }
for (unsigned int i2 = 0; i2 < carNPCEntity.size(); i2++){ if(rocketsBasicEntity[i]->collision( (*carNPCEntity[i2]) )){
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 delete carNPCEntity[i2];
 carNPCEntity.erase(carNPCEntity.begin() + i2);
 delete rocketsBasicEntity[i];
 rocketsBasicEntity.erase(rocketsBasicEntity.begin() + i);
 break;
 }
 }
}
}
}
 if(rocketsBasicEntity.size() > 0){
 for (unsigned int i = 0; i < rocketsBasicEntity.size(); i++){ rocketsBasicEntity[i]->moveUpX(gameTime.elpasedTimeSinceLastFrame_Seconds);
if( rocketsBasicEntity[i]->getPositionX() > 8){
 delete rocketsBasicEntity[i];
 rocketsBasicEntity.erase(rocketsBasicEntity.begin() + i);
 continue;
 }
for (unsigned int i2 = 0; i2 < lorryNPCEntity.size(); i2++){ if(rocketsBasicEntity[i]->collision( (*lorryNPCEntity[i2]) )){
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 myGameScore.increaseScore();
 delete lorryNPCEntity[i2];
 lorryNPCEntity.erase(lorryNPCEntity.begin() + i2);
delete rocketsBasicEntity[i];
 rocketsBasicEntity.erase(rocketsBasicEntity.begin() + i);
 break;
 }
 }
}
}
// Loop through the vector (list).
 if(carNPCEntity.size() > 0){
 for (unsigned int i = 0; i < carNPCEntity.size(); i++){ carNPCEntity[i]->moveDownX(gameTime.elpasedTimeSinceLastFrame_Seconds);
if(carNPCEntity[i]->collision(humanPlayerEntity)){
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 delete carNPCEntity[i];
 carNPCEntity.erase(carNPCEntity.begin() + i);
 }
 if( carNPCEntity[i]->getPositionX() < -7){ delete carNPCEntity[i]; carNPCEntity.erase(carNPCEntity.begin() + i); } } } // Loop through the vector (list). if(lorryNPCEntity.size() > 0){
 for (unsigned int i = 0; i < lorryNPCEntity.size(); i++){ lorryNPCEntity[i]->moveDownX(gameTime.elpasedTimeSinceLastFrame_Seconds);
if(lorryNPCEntity[i]->collision(humanPlayerEntity)){
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 myHealthScore.decreaseScore();
 delete lorryNPCEntity[i];
 lorryNPCEntity.erase(lorryNPCEntity.begin() + i);
 }
if( lorryNPCEntity[i]->getPositionX() < -7){ delete lorryNPCEntity[i]; lorryNPCEntity.erase(lorryNPCEntity.begin() + i); } } } if(gameEvent == 2){ //Exit the state. gameEvent = 0; gameState = 0; break; } } } /**************************************************************** * Draw the scene. ****************************************************************/ void Game::render(GameTime gameTime){ switch(gameState){ case 0: if (gameEvent == 0){ // Enter the state. break; } if (gameEvent == 1){ // Update the state. // DRAW THE BACKGROUND FIRST. Entities need to be drawn in order. menuBackgroundEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); menuBackgroundTextEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); menuStartEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); menuOptionsEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); menuExitEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); // Draw the menu car entity. menuCarPointerEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); break; } if(gameEvent == 2){ //Exit the state. break; } break; case 1: if (gameEvent == 0){ // Enter the state. break; } if (gameEvent == 1){ // DRAW THE BACKGROUND FIRST. Entities need to be drawn in order. roadAnimatedBackgroundBasicEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds); // Draw all the rockets. // Loop through the vector (list). if(rocketsBasicEntity.size() > 0){
 vector<BasicEntity*>::const_iterator myConstIterator;
 for (myConstIterator = rocketsBasicEntity.begin(); myConstIterator != rocketsBasicEntity.end(); myConstIterator++){
(*myConstIterator)->renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds);
}
 }
// Draw the human car.
 humanPlayerEntity.renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds);
// Draw all the NPCs.
 // Loop through the vector (list).
 if(carNPCEntity.size() > 0){
 vector<BasicEntity*>::const_iterator myConstIterator;
 for (myConstIterator = carNPCEntity.begin(); myConstIterator != carNPCEntity.end(); myConstIterator++){
(*myConstIterator)->renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds);
}
 }
// Loop through the vector (list).
 if(lorryNPCEntity.size() > 0){
 vector<BasicEntity*>::const_iterator myConstIterator;
 for (myConstIterator = lorryNPCEntity.begin(); myConstIterator != lorryNPCEntity.end(); myConstIterator++){
(*myConstIterator)->renderEntity(gameTime.elpasedTimeSinceLastFrame_Seconds);
}
 }
// Draw the score.
 myGameScore.renderText();
 myHealthScore.renderText();
break;
 }
 if(gameEvent == 2){
 //Exit the state.
 break;
 }
 break;
 }
}
/****************************************************************
 * Unload game content.
 ****************************************************************/
 void Game::UnloadContent(){
// Loop through the vector (list) and delete all the rocketsBasicEntity's.
 while (!rocketsBasicEntity.empty()) {
 delete rocketsBasicEntity.back();
 rocketsBasicEntity.pop_back();
 }
 // Loop through the vector (list) and delete all the carNPC's.
 while (!carNPCEntity.empty()) {
 delete carNPCEntity.back();
 carNPCEntity.pop_back();
 }
 // Loop through the vector (list) and delete all the lorryNPC's.
 while (!lorryNPCEntity.empty()) {
 delete lorryNPCEntity.back();
 lorryNPCEntity.pop_back();
 }
}

 



Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.