0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 07:53:43 +00:00

ref(popup window): remove popup window code from main.cpp and game.cpp

This commit is contained in:
Nimac0 2024-04-29 23:00:20 +02:00
parent 8e0c76457e
commit 6744f519c5
2 changed files with 16 additions and 32 deletions

View File

@ -354,19 +354,19 @@ Entity::TeamLabel Game::getWinner() const
return this->winner;
}
void Game::refreshPlayers() {
for(auto& p : projectiles) {
p->destroy();
}
player1.getComponent<TransformComponent>().position = Vector2D(80, 80);
player2.getComponent<TransformComponent>().position = Vector2D(600, 500);
player1.getComponent<HealthComponent>().setHealth(5);
player2.getComponent<HealthComponent>().setHealth(5);
isRunning = true;
update();
}
//void Game::refreshPlayers() {
//
// for(auto& p : projectiles) {
// p->destroy();
// }
//
// player1.getComponent<TransformComponent>().position = Vector2D(80, 80);
// player2.getComponent<TransformComponent>().position = Vector2D(600, 500);
//
// player1.getComponent<HealthComponent>().setHealth(5);
// player2.getComponent<HealthComponent>().setHealth(5);
//
// isRunning = true;
//
// update();
//}

View File

@ -21,7 +21,6 @@ int main(int argc, char* argv[])
game = new Game();
game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false);
while(playing) {
while (game->running()) {
frameStart = SDL_GetTicks();
@ -35,21 +34,6 @@ int main(int argc, char* argv[])
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();