Get rid of tuple
This commit is contained in:
parent
522362152d
commit
691aac978e
|
@ -37,7 +37,10 @@ void Canvas::update(const GameState & gameState, const Score & score) {
|
||||||
renderPellets(gameState.pellets);
|
renderPellets(gameState.pellets);
|
||||||
renderSuperPellets(gameState.superPellets);
|
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);
|
renderScore(score.points);
|
||||||
renderLives(score.lives);
|
renderLives(score.lives);
|
||||||
|
|
18
lib/Game.cpp
18
lib/Game.cpp
|
@ -52,10 +52,10 @@ void Game::handleDeathAnimation(std::chrono::milliseconds delta) {
|
||||||
timeSinceDeath += delta;
|
timeSinceDeath += delta;
|
||||||
|
|
||||||
if (timeSinceDeath.count() > 1000) {
|
if (timeSinceDeath.count() > 1000) {
|
||||||
std::apply([&](auto &... ghost) {
|
gameState.blinky.reset();
|
||||||
(ghost.reset(), ...);
|
gameState.speedy.reset();
|
||||||
},
|
gameState.inky.reset();
|
||||||
gameState.ghosts);
|
gameState.clyde.reset();
|
||||||
gameState.pacMan.reset();
|
gameState.pacMan.reset();
|
||||||
timeSinceDeath = std::chrono::milliseconds(0);
|
timeSinceDeath = std::chrono::milliseconds(0);
|
||||||
}
|
}
|
||||||
|
@ -107,10 +107,12 @@ void Game::eatPellets() {
|
||||||
if (gameState.superPellets.eatPelletAtPosition(pos)) {
|
if (gameState.superPellets.eatPelletAtPosition(pos)) {
|
||||||
score.eatenPellets++;
|
score.eatenPellets++;
|
||||||
score.points += POWER_PELLET_POINTS;
|
score.points += POWER_PELLET_POINTS;
|
||||||
std::apply([&](auto &... ghost) {
|
|
||||||
(ghost.frighten(), ...);
|
gameState.blinky.frighten();
|
||||||
},
|
gameState.speedy.frighten();
|
||||||
gameState.ghosts);
|
gameState.inky.frighten();
|
||||||
|
gameState.clyde.frighten();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,10 @@
|
||||||
namespace pacman {
|
namespace pacman {
|
||||||
|
|
||||||
struct GameState {
|
struct GameState {
|
||||||
std::tuple<Blinky, Speedy, Inky, Clyde> ghosts;
|
Blinky blinky;
|
||||||
|
Speedy speedy;
|
||||||
|
Inky inky;
|
||||||
|
Clyde clyde;
|
||||||
PacMan pacMan;
|
PacMan pacMan;
|
||||||
Pellets pellets;
|
Pellets pellets;
|
||||||
SuperPellets superPellets;
|
SuperPellets superPellets;
|
||||||
|
|
Loading…
Reference in New Issue