Get rid of tuple
This commit is contained in:
parent
522362152d
commit
691aac978e
3 changed files with 18 additions and 10 deletions
|
@ -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);
|
||||
|
|
18
lib/Game.cpp
18
lib/Game.cpp
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue