jail_audio: actualitzat a la ultima versió (ara sense threads)
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
#include <array> // Para array
|
||||
#include <cstdlib> // Para rand, size_t
|
||||
#include <functional> // Para function
|
||||
#include <iterator> // Para distance, size
|
||||
#include <iostream> // Para std::cout, std::endl
|
||||
#include <iterator> // Para distance, size
|
||||
|
||||
#include "asset.h" // Para Asset
|
||||
#include "audio.h" // Para Audio
|
||||
@@ -886,40 +886,59 @@ void Game::updateTimeStopped() {
|
||||
void Game::update() {
|
||||
if (SDL_GetTicks() - ticks_ > param.game.speed) {
|
||||
ticks_ = SDL_GetTicks();
|
||||
screen_->update();
|
||||
|
||||
checkServiceMenu();
|
||||
updateDemo();
|
||||
#ifdef RECORDING
|
||||
updateRecording();
|
||||
#endif
|
||||
if (!paused_) {
|
||||
switch (state_) {
|
||||
case GameState::FADE_IN:
|
||||
updateGameStateFadeIn();
|
||||
break;
|
||||
case GameState::ENTERING_PLAYER:
|
||||
updateGameStateEnteringPlayer();
|
||||
break;
|
||||
case GameState::SHOWING_GET_READY_MESSAGE:
|
||||
updateGameStateShowingGetReadyMessage();
|
||||
break;
|
||||
case GameState::PLAYING:
|
||||
updateGameStatePlaying();
|
||||
break;
|
||||
case GameState::COMPLETED:
|
||||
updateGameStateCompleted();
|
||||
break;
|
||||
case GameState::GAME_OVER:
|
||||
updateGameStateGameOver();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
screen_->update();
|
||||
updateGameStates();
|
||||
fillCanvas();
|
||||
}
|
||||
|
||||
static const auto audio = Audio::get();
|
||||
audio->update();
|
||||
}
|
||||
|
||||
// Dibuja el juego
|
||||
void Game::render() {
|
||||
screen_->start(); // Prepara para empezar a dibujar en la textura de juego
|
||||
|
||||
SDL_RenderTexture(renderer_, canvas_, nullptr, ¶m.game.play_area.rect); // Copia la textura con la zona de juego a la pantalla
|
||||
scoreboard_->render(); // Dibuja el marcador
|
||||
fade_in_->render(); // Dibuja el fade de entrada
|
||||
fade_out_->render(); // Dibuja el fade de salida
|
||||
|
||||
screen_->render(); // Vuelca el contenido del renderizador en pantalla
|
||||
}
|
||||
|
||||
// Actualiza los estados del juego
|
||||
void Game::updateGameStates() {
|
||||
if (!paused_) {
|
||||
switch (state_) {
|
||||
case GameState::FADE_IN:
|
||||
updateGameStateFadeIn();
|
||||
break;
|
||||
case GameState::ENTERING_PLAYER:
|
||||
updateGameStateEnteringPlayer();
|
||||
break;
|
||||
case GameState::SHOWING_GET_READY_MESSAGE:
|
||||
updateGameStateShowingGetReadyMessage();
|
||||
break;
|
||||
case GameState::PLAYING:
|
||||
updateGameStatePlaying();
|
||||
break;
|
||||
case GameState::COMPLETED:
|
||||
updateGameStateCompleted();
|
||||
break;
|
||||
case GameState::GAME_OVER:
|
||||
updateGameStateGameOver();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el fondo
|
||||
@@ -971,25 +990,6 @@ void Game::fillCanvas() {
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
}
|
||||
|
||||
// Dibuja el juego
|
||||
void Game::render() {
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen_->start();
|
||||
|
||||
// Copia la textura con la zona de juego a la pantalla
|
||||
SDL_RenderTexture(renderer_, canvas_, nullptr, ¶m.game.play_area.rect);
|
||||
|
||||
// Dibuja el marcador
|
||||
scoreboard_->render();
|
||||
|
||||
// Dibuja el fade
|
||||
fade_in_->render();
|
||||
fade_out_->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->render();
|
||||
}
|
||||
|
||||
// Habilita el efecto del item de detener el tiempo
|
||||
void Game::enableTimeStopItem() {
|
||||
balloon_manager_->stopAllBalloons();
|
||||
@@ -1786,8 +1786,8 @@ void Game::playSound(const std::string &name) const {
|
||||
return;
|
||||
}
|
||||
|
||||
static auto *audio_ = Audio::get();
|
||||
audio_->playSound(name);
|
||||
static auto audio = Audio::get();
|
||||
audio->playSound(name);
|
||||
}
|
||||
|
||||
// Organiza los jugadores para que los vivos se pinten sobre los muertos
|
||||
@@ -1895,14 +1895,14 @@ void Game::checkDebugEvents(const SDL_Event &event) {
|
||||
tabe_->enable();
|
||||
break;
|
||||
}
|
||||
case SDLK_KP_PLUS:{
|
||||
case SDLK_KP_PLUS: {
|
||||
++formation_id;
|
||||
balloon_manager_->destroyAllBalloons();
|
||||
balloon_manager_->deployFormation(formation_id);
|
||||
std::cout << formation_id << std::endl;
|
||||
break;
|
||||
}
|
||||
case SDLK_KP_MINUS:{
|
||||
case SDLK_KP_MINUS: {
|
||||
--formation_id;
|
||||
balloon_manager_->destroyAllBalloons();
|
||||
balloon_manager_->deployFormation(formation_id);
|
||||
|
||||
Reference in New Issue
Block a user