void GameState::Update() { if(currentInGameState == Play) { std::list<Player*>::iterator it_player = Player::s_playerList.begin(); while(it_player != Player::s_playerList.end()) { if(!(*it_player)->isDead()) (*it_player)->update(); it_player++; } std::list<Rock*>::iterator it_rock = Rock::s_rockList.begin(); while(it_rock != Rock::s_rockList.end()) { (*it_rock)->update(); it_rock++; } std::list<Enemy*>::iterator it_enemy = Enemy::s_enemyList.begin(); while(it_enemy != Enemy::s_enemyList.end()) { (*it_enemy)->update(); it_enemy++; } checkForCollision(); createDollar(); createEnemy(); createRock(); if(isGameOver() && currentInGameState != GameOver) { //ALL PLAYERS DIED! currentInGameState = GameOver; Text::s_textList.push_back(new Text("Press key to exit to menu", 48, 0, 0, 255, 255, 255)); Text::s_textList.back()->centerHorizontal(0,config::W_WIDTH); Text::s_textList.back()->bottomAlign(config::W_HEIGHT, 20); temp_delay = 1000; } } else if (currentInGameState == CountDown) { if(countDown_compareTime < SDL_GetTicks()) { text_countDown->updateText(countDown); text_countDown->centerHorizontal(0,config::W_WIDTH); text_countDown->centerVertical(0,config::W_HEIGHT / 2); countDown_compareTime += 1000; countDown--; if (countDown < 0) { Text::s_textList.remove(text_countDown); currentInGameState = Play; } } } FPS::FPSControl.Update(); #ifdef WIN32 std::stringstream ss; ss << config::WINDOW_TEXT << " " << FPS::FPSControl.GetFPS(); SDL_WM_SetCaption(ss.str().c_str(), ss.str().c_str()); #endif }
void randomizeMap() { OBJECT *theRock = rockHeader; OBJECT *theRockSave = rockHeader; while (theRock != NULL) { theRockSave = theRock->next; destroyObject(theRock, &rockHeader); theRock = theRockSave; } pointHeader = NULL; for (int i = 0; i < NUMBLOCKS; i ++) { createRock(); } }