forked from jaildesigner-jailgames/jaildoctors_dilemma
Retocado un poco el game over
This commit is contained in:
@@ -9,7 +9,7 @@ Director::Director(int argc, char *argv[])
|
|||||||
section.name = SECTION_PROG_LOGO;
|
section.name = SECTION_PROG_LOGO;
|
||||||
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
section.subsection = SUBSECTION_LOGO_TO_INTRO;
|
||||||
|
|
||||||
section.name = SECTION_PROG_GAME;
|
//section.name = SECTION_PROG_GAME;
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
iniOptions();
|
iniOptions();
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
this->options = options;
|
this->options = options;
|
||||||
|
|
||||||
// ****
|
// ****
|
||||||
currentRoom = "03.room";
|
//currentRoom = "03.room";
|
||||||
const int x = 29;
|
//const int x = 29;
|
||||||
const int y = 13;
|
//const int y = 13;
|
||||||
spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
//spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL};
|
||||||
// ****
|
// ****
|
||||||
|
|
||||||
// Crea los objetos
|
// Crea los objetos
|
||||||
@@ -40,7 +40,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as
|
|||||||
// Inicializa el resto de variables
|
// Inicializa el resto de variables
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
board.lives = 0;
|
board.lives = 9;
|
||||||
board.items = 0;
|
board.items = 0;
|
||||||
board.rooms = 1;
|
board.rooms = 1;
|
||||||
board.music = true;
|
board.music = true;
|
||||||
|
|||||||
@@ -18,13 +18,14 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
music = JA_LoadMusic(asset->get("game_over.ogg").c_str());
|
music = JA_LoadMusic(asset->get("game_over.ogg").c_str());
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
|
preCounter = 0;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
section.name = SECTION_PROG_GAME_OVER;
|
section.name = SECTION_PROG_GAME_OVER;
|
||||||
section.subsection = 0;
|
section.subsection = 0;
|
||||||
ticks = 0;
|
ticks = 0;
|
||||||
ticksSpeed = 15;
|
ticksSpeed = 15;
|
||||||
endSection = 350;
|
endSection = 400;
|
||||||
iniFade = 260;
|
iniFade = 310;
|
||||||
fadeLenght = 20;
|
fadeLenght = 20;
|
||||||
playerSprite->setPosX(GAMECANVAS_CENTER_X + 10);
|
playerSprite->setPosX(GAMECANVAS_CENTER_X + 10);
|
||||||
playerSprite->setPosY(GAMECANVAS_CENTER_Y + 10);
|
playerSprite->setPosY(GAMECANVAS_CENTER_Y + 10);
|
||||||
@@ -37,7 +38,7 @@ GameOver::GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, A
|
|||||||
{
|
{
|
||||||
colors.push_back(stringToColor(options->palette, cl));
|
colors.push_back(stringToColor(options->palette, cl));
|
||||||
}
|
}
|
||||||
color = colors.at(0);
|
color = colors.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -66,25 +67,12 @@ void GameOver::update()
|
|||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
updateColor();
|
updateColor();
|
||||||
|
|
||||||
|
// Actualiza los contadores
|
||||||
|
updateCounters();
|
||||||
|
|
||||||
// Actualiza los dos sprites
|
// Actualiza los dos sprites
|
||||||
playerSprite->update();
|
playerSprite->update();
|
||||||
tvSprite->update();
|
tvSprite->update();
|
||||||
|
|
||||||
// Actualiza el contador
|
|
||||||
counter++;
|
|
||||||
|
|
||||||
// Hace sonar la música
|
|
||||||
if (counter == 30)
|
|
||||||
{
|
|
||||||
JA_PlayMusic(music, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la sección
|
|
||||||
if (counter == endSection)
|
|
||||||
{
|
|
||||||
section.name = SECTION_PROG_LOGO;
|
|
||||||
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,9 +178,21 @@ section_t GameOver::run()
|
|||||||
// Actualiza el color usado para renderizar los textos e imagenes
|
// Actualiza el color usado para renderizar los textos e imagenes
|
||||||
void GameOver::updateColor()
|
void GameOver::updateColor()
|
||||||
{
|
{
|
||||||
|
const int half = endSection / 2;
|
||||||
|
|
||||||
|
if (counter < half)
|
||||||
|
{
|
||||||
|
//const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
||||||
|
const float step = std::min(counter, fadeLenght) / (float)fadeLenght;
|
||||||
|
const int index = (colors.size() - 1) - int((colors.size() - 1) * step);
|
||||||
|
color = colors.at(index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
const float step = std::min(std::max(counter, iniFade) - iniFade, fadeLenght) / (float)fadeLenght;
|
||||||
const int index = (colors.size() - 1) * step;
|
const int index = (colors.size() - 1) * step;
|
||||||
color = colors.at(index);
|
color = colors.at(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja los sprites
|
// Dibuja los sprites
|
||||||
@@ -204,3 +204,30 @@ void GameOver::renderSprites()
|
|||||||
tvSprite->getTexture()->setColor(color.r, color.g, color.b);
|
tvSprite->getTexture()->setColor(color.r, color.g, color.b);
|
||||||
tvSprite->render();
|
tvSprite->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Actualiza los contadores
|
||||||
|
void GameOver::updateCounters()
|
||||||
|
{
|
||||||
|
// Actualiza el contador
|
||||||
|
if (preCounter < 50)
|
||||||
|
{
|
||||||
|
preCounter++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hace sonar la música
|
||||||
|
if (counter == 1)
|
||||||
|
{
|
||||||
|
JA_PlayMusic(music, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comprueba si ha terminado la sección
|
||||||
|
else if (counter == endSection)
|
||||||
|
{
|
||||||
|
section.name = SECTION_PROG_LOGO;
|
||||||
|
section.subsection = SUBSECTION_LOGO_TO_TITLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,6 +30,7 @@ private:
|
|||||||
AnimatedSprite *tvSprite; // Sprite con el televisor
|
AnimatedSprite *tvSprite; // Sprite con el televisor
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
|
int preCounter; // Contador previo
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||||
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
Uint32 ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||||
@@ -56,6 +57,9 @@ private:
|
|||||||
// Dibuja los sprites
|
// Dibuja los sprites
|
||||||
void renderSprites();
|
void renderSprites();
|
||||||
|
|
||||||
|
// Actualiza los contadores
|
||||||
|
void updateCounters();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
GameOver(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
||||||
|
|||||||
Reference in New Issue
Block a user