Añadido soporte preliminar para estadisticas

This commit is contained in:
2022-11-17 09:30:56 +01:00
parent ea92241d6e
commit 5af554fecd
8 changed files with 210 additions and 121 deletions

View File

@@ -40,6 +40,8 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
music = JA_LoadMusic(asset->get("game.ogg").c_str());
deathSound = JA_LoadSound(asset->get("death.wav").c_str());
stats = new Stats(asset->get("stats.txt"));
stats->addVisit(room->getName());
// Inicializa el resto de variables
ticks = 0;
@@ -70,6 +72,7 @@ Game::~Game()
delete player;
delete eventHandler;
delete text;
delete stats;
JA_DeleteMusic(music);
JA_DeleteSound(deathSound);
@@ -210,7 +213,7 @@ void Game::update()
#ifdef DEBUG
debug->clear();
#endif
// Actualiza los objetos
room->update();
player->update();
@@ -336,6 +339,9 @@ bool Game::changeRoom(std::string file)
// Pasa la nueva habitación al jugador
player->setRoom(room);
// Actualiza las estadisticas
stats->addVisit(room->getName());
return true;
}
@@ -406,6 +412,9 @@ void Game::killPlayer()
board.lives--;
}
// Actualiza las estadisticas
stats->addDeath(room->getName());
// Destruye la habitacion y el jugador
delete room;
delete this->player;