mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-13 12:33:42 +00:00
ref(popup window): remove popup window code from main.cpp and game.cpp
This commit is contained in:
parent
8e0c76457e
commit
6744f519c5
32
src/Game.cpp
32
src/Game.cpp
@ -354,19 +354,19 @@ Entity::TeamLabel Game::getWinner() const
|
|||||||
return this->winner;
|
return this->winner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::refreshPlayers() {
|
//void Game::refreshPlayers() {
|
||||||
|
//
|
||||||
for(auto& p : projectiles) {
|
// for(auto& p : projectiles) {
|
||||||
p->destroy();
|
// p->destroy();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
player1.getComponent<TransformComponent>().position = Vector2D(80, 80);
|
// player1.getComponent<TransformComponent>().position = Vector2D(80, 80);
|
||||||
player2.getComponent<TransformComponent>().position = Vector2D(600, 500);
|
// player2.getComponent<TransformComponent>().position = Vector2D(600, 500);
|
||||||
|
//
|
||||||
player1.getComponent<HealthComponent>().setHealth(5);
|
// player1.getComponent<HealthComponent>().setHealth(5);
|
||||||
player2.getComponent<HealthComponent>().setHealth(5);
|
// player2.getComponent<HealthComponent>().setHealth(5);
|
||||||
|
//
|
||||||
isRunning = true;
|
// isRunning = true;
|
||||||
|
//
|
||||||
update();
|
// update();
|
||||||
}
|
//}
|
||||||
|
|||||||
16
src/main.cpp
16
src/main.cpp
@ -21,7 +21,6 @@ int main(int argc, char* argv[])
|
|||||||
game = new Game();
|
game = new Game();
|
||||||
|
|
||||||
game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false);
|
game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false);
|
||||||
while(playing) {
|
|
||||||
while (game->running()) {
|
while (game->running()) {
|
||||||
frameStart = SDL_GetTicks();
|
frameStart = SDL_GetTicks();
|
||||||
|
|
||||||
@ -35,21 +34,6 @@ int main(int argc, char* argv[])
|
|||||||
SDL_Delay(frameDelay - frameTime);
|
SDL_Delay(frameDelay - frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Entity::TeamLabel winner = game->getWinner();
|
|
||||||
|
|
||||||
PopupWindow popupWindow("Game over", winner == Entity::TeamLabel::BLUE ?
|
|
||||||
"Player1 won! Press 'C' to continue or 'Q' to quit." :
|
|
||||||
"Player2 won! Press 'C' to continue or 'Q' to quit.");
|
|
||||||
|
|
||||||
popupWindow.renderWinnerPopup(winner);
|
|
||||||
|
|
||||||
while (!popupWindow.interacted) {
|
|
||||||
popupWindow.handleWinnerEvents();
|
|
||||||
SDL_Delay(10);
|
|
||||||
}
|
|
||||||
playing = popupWindow.shouldContinue();
|
|
||||||
game->refreshPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
game->clean();
|
game->clean();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user