void CarManager::spawnBonusCar() { unsigned int i; Car *car; car = cars.at(0); if(car->getCarState() == CAR_READY) { car->setSlideDirection(DIRECTION_NONE); car->initMe(); //manage the positions of all the cars findPositionToSpawn(car); car->setCarState(CAR_RUNNING); car->setSpeed(200); } }
Logical CarManager::allCarsDestroyed() { int i = 0; int totalCars = cars.size(); Car *car; for(i = 0; i < totalCars; i++) { car = cars.at(i); if(car->getCarState() != CAR_DESTROYED && car->getOnScreen() && car->getCarType() != BONUS_CAR) { return no; } } return yes; }
void CarManager::spawnTruckCar() { if(getCurrentStage() == 1) return; unsigned int i; Car *car; car = cars.at(cars.size() - 1); if(car->getCarState() == CAR_READY) { car->setSlideDirection(DIRECTION_NONE); car->initMe(); //manage the positions of all the cars findPositionToSpawn(car); car->setCarState(CAR_RUNNING); car->setSpeed(200); } }
void CarManager::spawn() { unsigned int i; Car *car; for(i = 0; i < cars.size(); i++) { car = cars.at(i); if(car->getCarState() == CAR_READY && car->getCarType() != BONUS_CAR && car->getCarType() != TRUCK_CAR) { car->setSlideDirection(DIRECTION_NONE); car->initMe(); //manage the positions of all the cars findPositionToSpawn(car); car->setCarState(CAR_RUNNING); car->setSpeed(200); break; } } }
void CarManager::update() { unsigned int i; Car *car; for(i = 0; i < cars.size(); i++) { car = cars.at(i); car->calculateTurnIndex(); // lprintf("car %d x = %f y = %f\n", i, car->getXPosWC(), car->getYPosWC()); if(car->getCarState() == CAR_RUNNING && car->getYPosSC() != NOT_INSIDE_VIEWPORT && !car->getOnScreen()) { car->setOnScreen(yes); car->reInitFrameTimer(); } if(car->getOnScreen() && car->getYPosSC() == NOT_INSIDE_VIEWPORT) { car->setCarState(CAR_DESTROYED); } if(!car->getOnScreen() && !isCanSpawnNewCars() && car->getCarState() == CAR_DESTROYING) { car->setCarState(CAR_READY); } if(car->getOnScreen()) { if(car->getCarState() == CAR_DESTROYING) { car->destroying(); } else if(car->getCarState() == CAR_DESTROYED) { car->setOnScreen(no); if(isCanSpawnNewCars()) { car->setCarState(CAR_READY); } } else if(car->getCarState() == CAR_SLIDING) { car->sliding(); } else if(car->isRivalCar()) { RivalCar *rivalCar = (RivalCar*)car; if(rivalCar->getCarState() == CAR_RUNNING && (rivalCar->isNearPlayerCar() || rivalCar->getCarType() == BLUEFIGHTER_CAR)) { if(rivalCar->getCarState() != CAR_DODGING) { rivalCar->dodge(); } } if(rivalCar->getCarState() == CAR_DODGING) { rivalCar->dodging(); } } } car->move(); } }