Get rid of tuple

This commit is contained in:
Corentin Jabot 2021-07-15 09:14:25 +02:00
parent 522362152d
commit 691aac978e
3 changed files with 18 additions and 10 deletions

View File

@ -37,7 +37,10 @@ void Canvas::update(const GameState & gameState, const Score & score) {
renderPellets(gameState.pellets);
renderSuperPellets(gameState.superPellets);
std::apply([&](const auto &... ghost) { (renderGhost(ghost), ...); }, gameState.ghosts);
renderGhost(gameState.blinky);
renderGhost(gameState.speedy);
renderGhost(gameState.inky);
renderGhost(gameState.clyde);
renderScore(score.points);
renderLives(score.lives);

View File

@ -52,10 +52,10 @@ void Game::handleDeathAnimation(std::chrono::milliseconds delta) {
timeSinceDeath += delta;
if (timeSinceDeath.count() > 1000) {
std::apply([&](auto &... ghost) {
(ghost.reset(), ...);
},
gameState.ghosts);
gameState.blinky.reset();
gameState.speedy.reset();
gameState.inky.reset();
gameState.clyde.reset();
gameState.pacMan.reset();
timeSinceDeath = std::chrono::milliseconds(0);
}
@ -107,10 +107,12 @@ void Game::eatPellets() {
if (gameState.superPellets.eatPelletAtPosition(pos)) {
score.eatenPellets++;
score.points += POWER_PELLET_POINTS;
std::apply([&](auto &... ghost) {
(ghost.frighten(), ...);
},
gameState.ghosts);
gameState.blinky.frighten();
gameState.speedy.frighten();
gameState.inky.frighten();
gameState.clyde.frighten();
}
}

View File

@ -9,7 +9,10 @@
namespace pacman {
struct GameState {
std::tuple<Blinky, Speedy, Inky, Clyde> ghosts;
Blinky blinky;
Speedy speedy;
Inky inky;
Clyde clyde;
PacMan pacMan;
Pellets pellets;
SuperPellets superPellets;