From 691aac978eff5c079149447dab4d354ed40192e2 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Thu, 15 Jul 2021 09:14:25 +0200 Subject: [PATCH] Get rid of tuple --- lib/Canvas.cpp | 5 ++++- lib/Game.cpp | 18 ++++++++++-------- lib/include/GameState.hpp | 5 ++++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/Canvas.cpp b/lib/Canvas.cpp index 69cacfd..e61cd49 100644 --- a/lib/Canvas.cpp +++ b/lib/Canvas.cpp @@ -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); diff --git a/lib/Game.cpp b/lib/Game.cpp index 313f28d..78a80ea 100644 --- a/lib/Game.cpp +++ b/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(); + } } diff --git a/lib/include/GameState.hpp b/lib/include/GameState.hpp index aad923e..8141f6e 100644 --- a/lib/include/GameState.hpp +++ b/lib/include/GameState.hpp @@ -9,7 +9,10 @@ namespace pacman { struct GameState { - std::tuple ghosts; + Blinky blinky; + Speedy speedy; + Inky inky; + Clyde clyde; PacMan pacMan; Pellets pellets; SuperPellets superPellets;