forked from jaildesigner-jailgames/jaildoctors_dilemma
Pantalla a negro al morir
This commit is contained in:
@@ -20,13 +20,16 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
||||
// Inicializa las variables
|
||||
counter = 0;
|
||||
colorChangeSpeed = 4;
|
||||
paused = false;
|
||||
timePaused = 0;
|
||||
totalTimePaused = 0;
|
||||
|
||||
// Inicializa los colores
|
||||
color_t c = stringToColor("blue");
|
||||
color.push_back(c);
|
||||
|
||||
//c = stringToColor("red");
|
||||
//color.push_back(c);
|
||||
// c = stringToColor("red");
|
||||
// color.push_back(c);
|
||||
|
||||
c = stringToColor("magenta");
|
||||
color.push_back(c);
|
||||
@@ -46,8 +49,8 @@ ScoreBoard::ScoreBoard(SDL_Renderer *renderer, Asset *asset, board_t *board)
|
||||
c = stringToColor("bright_blue");
|
||||
color.push_back(c);
|
||||
|
||||
//c = stringToColor("bright_red");
|
||||
//color.push_back(c);
|
||||
// c = stringToColor("bright_red");
|
||||
// color.push_back(c);
|
||||
|
||||
c = stringToColor("bright_magenta");
|
||||
color.push_back(c);
|
||||
@@ -117,7 +120,7 @@ void ScoreBoard::render()
|
||||
this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("white"));
|
||||
this->text->writeColored(20 * BLOCK, line1, " Time ", board->color);
|
||||
this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("white"));
|
||||
|
||||
|
||||
const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10);
|
||||
this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor("white"));
|
||||
this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("white"));
|
||||
@@ -128,13 +131,17 @@ void ScoreBoard::update()
|
||||
{
|
||||
counter++;
|
||||
sprite->update();
|
||||
clock = getTime();
|
||||
|
||||
if (!paused)
|
||||
{// Si está en pausa no se actualiza el reloj
|
||||
clock = getTime();
|
||||
}
|
||||
}
|
||||
|
||||
// Obtiene el tiempo transcurrido de partida
|
||||
ScoreBoard::clock_t ScoreBoard::getTime()
|
||||
{
|
||||
const Uint32 timeElapsed = SDL_GetTicks() - board->iniClock;
|
||||
const Uint32 timeElapsed = SDL_GetTicks() - board->iniClock - totalTimePaused;
|
||||
|
||||
clock_t time;
|
||||
time.hours = timeElapsed / 3600000;
|
||||
@@ -151,4 +158,18 @@ void ScoreBoard::reLoadTexture()
|
||||
playerTexture->reLoad();
|
||||
itemTexture->reLoad();
|
||||
text->reLoadTexture();
|
||||
}
|
||||
|
||||
// Pone el marcador en modo pausa
|
||||
void ScoreBoard::pause()
|
||||
{
|
||||
paused = true;
|
||||
timePaused = SDL_GetTicks();
|
||||
}
|
||||
|
||||
// Quita el modo pausa del marcador
|
||||
void ScoreBoard::resume()
|
||||
{
|
||||
paused = false;
|
||||
totalTimePaused += SDL_GetTicks() - timePaused;
|
||||
}
|
||||
Reference in New Issue
Block a user