forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en el ending2
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_ENDING;
|
section.name = SECTION_PROG_ENDING2;
|
||||||
|
|
||||||
// Crea e inicializa las opciones del programa
|
// Crea e inicializa las opciones del programa
|
||||||
iniOptions();
|
iniOptions();
|
||||||
@@ -322,10 +322,111 @@ void Director::loadResources(section_t section)
|
|||||||
{
|
{
|
||||||
// Texturas
|
// Texturas
|
||||||
std::vector<std::string> textureList;
|
std::vector<std::string> textureList;
|
||||||
|
|
||||||
|
// Texto
|
||||||
textureList.push_back("smb2.png");
|
textureList.push_back("smb2.png");
|
||||||
|
|
||||||
|
// Enemigos
|
||||||
|
textureList.push_back("abad.png");
|
||||||
|
textureList.push_back("abad_bell.png");
|
||||||
|
textureList.push_back("amstrad_character_set.png");
|
||||||
|
textureList.push_back("arounder_fly.png");
|
||||||
|
textureList.push_back("arounder_stop.png");
|
||||||
|
textureList.push_back("arounder_walk.png");
|
||||||
|
textureList.push_back("arounders_door.png");
|
||||||
|
textureList.push_back("arounders_machine.png");
|
||||||
|
textureList.push_back("bat.png");
|
||||||
|
textureList.push_back("batman_bell.png");
|
||||||
|
textureList.push_back("batman_fire.png");
|
||||||
|
textureList.push_back("batman.png");
|
||||||
|
textureList.push_back("bell.png");
|
||||||
|
textureList.push_back("bin.png");
|
||||||
|
textureList.push_back("bird.png");
|
||||||
|
textureList.push_back("breakout.png");
|
||||||
|
textureList.push_back("bry.png");
|
||||||
|
textureList.push_back("chip.png");
|
||||||
|
textureList.push_back("code.png");
|
||||||
|
textureList.push_back("demon.png");
|
||||||
|
textureList.push_back("dimallas_v.png");
|
||||||
|
textureList.push_back("dimallas.png");
|
||||||
|
textureList.push_back("diskette.png");
|
||||||
|
textureList.push_back("dong.png");
|
||||||
|
textureList.push_back("heavy.png");
|
||||||
|
textureList.push_back("jailbattle_alien.png");
|
||||||
|
textureList.push_back("jailbattle_human.png");
|
||||||
|
textureList.push_back("jailer.png");
|
||||||
|
textureList.push_back("jailer2.png");
|
||||||
|
textureList.push_back("jailer3.png");
|
||||||
|
textureList.push_back("lamp.png");
|
||||||
|
textureList.push_back("macaronni_ted.png");
|
||||||
|
textureList.push_back("matatunos.png");
|
||||||
|
textureList.push_back("mummy.png");
|
||||||
|
textureList.push_back("paco.png");
|
||||||
|
textureList.push_back("printer.png");
|
||||||
|
textureList.push_back("qvoid.png");
|
||||||
|
textureList.push_back("sam.png");
|
||||||
|
textureList.push_back("sigmasua.png");
|
||||||
|
textureList.push_back("spider.png");
|
||||||
|
textureList.push_back("tuno.png");
|
||||||
|
textureList.push_back("tv_panel.png");
|
||||||
|
textureList.push_back("tv.png");
|
||||||
|
textureList.push_back("wave_v.png");
|
||||||
|
textureList.push_back("wave.png");
|
||||||
|
|
||||||
resource->loadTextures(textureList);
|
resource->loadTextures(textureList);
|
||||||
|
|
||||||
|
// Animaciones
|
||||||
|
std::vector<std::string> animationList;
|
||||||
|
|
||||||
|
// Enemigos
|
||||||
|
animationList.push_back("abad.ani");
|
||||||
|
animationList.push_back("abad_bell.ani");
|
||||||
|
animationList.push_back("amstrad_character_set.ani");
|
||||||
|
animationList.push_back("arounder_fly.ani");
|
||||||
|
animationList.push_back("arounder_stop.ani");
|
||||||
|
animationList.push_back("arounder_walk.ani");
|
||||||
|
animationList.push_back("arounders_door.ani");
|
||||||
|
animationList.push_back("arounders_machine.ani");
|
||||||
|
animationList.push_back("bat.ani");
|
||||||
|
animationList.push_back("batman_bell.ani");
|
||||||
|
animationList.push_back("batman_fire.ani");
|
||||||
|
animationList.push_back("batman.ani");
|
||||||
|
animationList.push_back("bell.ani");
|
||||||
|
animationList.push_back("bin.ani");
|
||||||
|
animationList.push_back("bird.ani");
|
||||||
|
animationList.push_back("breakout.ani");
|
||||||
|
animationList.push_back("bry.ani");
|
||||||
|
animationList.push_back("chip.ani");
|
||||||
|
animationList.push_back("code.ani");
|
||||||
|
animationList.push_back("demon.ani");
|
||||||
|
animationList.push_back("dimallas_v.ani");
|
||||||
|
animationList.push_back("dimallas.ani");
|
||||||
|
animationList.push_back("diskette.ani");
|
||||||
|
animationList.push_back("dong.ani");
|
||||||
|
animationList.push_back("heavy.ani");
|
||||||
|
animationList.push_back("jailbattle_alien.ani");
|
||||||
|
animationList.push_back("jailbattle_human.ani");
|
||||||
|
animationList.push_back("jailer.ani");
|
||||||
|
animationList.push_back("jailer2.ani");
|
||||||
|
animationList.push_back("jailer3.ani");
|
||||||
|
animationList.push_back("lamp.ani");
|
||||||
|
animationList.push_back("macaronni_ted.ani");
|
||||||
|
animationList.push_back("matatunos.ani");
|
||||||
|
animationList.push_back("mummy.ani");
|
||||||
|
animationList.push_back("paco.ani");
|
||||||
|
animationList.push_back("printer.ani");
|
||||||
|
animationList.push_back("qvoid.ani");
|
||||||
|
animationList.push_back("sam.ani");
|
||||||
|
animationList.push_back("sigmasua.ani");
|
||||||
|
animationList.push_back("spider.ani");
|
||||||
|
animationList.push_back("tuno.ani");
|
||||||
|
animationList.push_back("tv_panel.ani");
|
||||||
|
animationList.push_back("tv.ani");
|
||||||
|
animationList.push_back("wave_v.ani");
|
||||||
|
animationList.push_back("wave.ani");
|
||||||
|
|
||||||
|
resource->loadAnimations(animationList);
|
||||||
|
|
||||||
// Offsets
|
// Offsets
|
||||||
std::vector<std::string> offsetsList;
|
std::vector<std::string> offsetsList;
|
||||||
offsetsList.push_back("smb2.txt");
|
offsetsList.push_back("smb2.txt");
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ Ending2::Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Ass
|
|||||||
|
|
||||||
// Cambia el color del borde
|
// Cambia el color del borde
|
||||||
screen->setBorderColor(stringToColor(options->palette, "black"));
|
screen->setBorderColor(stringToColor(options->palette, "black"));
|
||||||
|
|
||||||
|
// Inicializa la lista de sprites
|
||||||
|
iniSpriteList();
|
||||||
|
|
||||||
|
// Carga todos los sprites desde una lista
|
||||||
|
loadSprites();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
@@ -34,6 +40,12 @@ Ending2::~Ending2()
|
|||||||
delete eventHandler;
|
delete eventHandler;
|
||||||
delete text;
|
delete text;
|
||||||
JA_DeleteMusic(music);
|
JA_DeleteMusic(music);
|
||||||
|
|
||||||
|
for (auto sprite : sprites)
|
||||||
|
{
|
||||||
|
delete sprite;
|
||||||
|
}
|
||||||
|
sprites.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
@@ -51,7 +63,10 @@ void Ending2::update()
|
|||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
updateCounters();
|
updateCounters();
|
||||||
|
|
||||||
if (counter > 400)
|
// Actualiza los sprites
|
||||||
|
updateSprites();
|
||||||
|
|
||||||
|
if (counter > 4000)
|
||||||
{
|
{
|
||||||
section.name = SECTION_PROG_LOGO;
|
section.name = SECTION_PROG_LOGO;
|
||||||
}
|
}
|
||||||
@@ -67,7 +82,11 @@ void Ending2::render()
|
|||||||
// Limpia la pantalla
|
// Limpia la pantalla
|
||||||
screen->clean(stringToColor(options->palette, "black"));
|
screen->clean(stringToColor(options->palette, "black"));
|
||||||
|
|
||||||
text->write(0,0,std::to_string(counter));
|
// Dibuja los sprites
|
||||||
|
void renderSprites();
|
||||||
|
|
||||||
|
const std::string txt = std::to_string(preCounter) + " - " + std::to_string(counter);
|
||||||
|
text->write(0, 0, txt);
|
||||||
|
|
||||||
// Vuelca el contenido del renderizador en pantalla
|
// Vuelca el contenido del renderizador en pantalla
|
||||||
screen->blit();
|
screen->blit();
|
||||||
@@ -164,4 +183,92 @@ void Ending2::updateCounters()
|
|||||||
{
|
{
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inicializa la lista de sprites
|
||||||
|
void Ending2::iniSpriteList()
|
||||||
|
{
|
||||||
|
// Reinicia el vector
|
||||||
|
spriteList.clear();
|
||||||
|
|
||||||
|
// Añade los valores
|
||||||
|
spriteList.push_back("abad");
|
||||||
|
spriteList.push_back("abad_bell");
|
||||||
|
spriteList.push_back("amstrad_character_set");
|
||||||
|
spriteList.push_back("arounder_fly");
|
||||||
|
spriteList.push_back("arounder_stop");
|
||||||
|
spriteList.push_back("arounder_walk");
|
||||||
|
spriteList.push_back("arounders_door");
|
||||||
|
spriteList.push_back("arounders_machine");
|
||||||
|
spriteList.push_back("bat");
|
||||||
|
spriteList.push_back("batman_bell");
|
||||||
|
spriteList.push_back("batman_fire");
|
||||||
|
spriteList.push_back("batman");
|
||||||
|
spriteList.push_back("bell");
|
||||||
|
spriteList.push_back("bin");
|
||||||
|
spriteList.push_back("bird");
|
||||||
|
spriteList.push_back("breakout");
|
||||||
|
spriteList.push_back("bry");
|
||||||
|
spriteList.push_back("chip");
|
||||||
|
spriteList.push_back("code");
|
||||||
|
spriteList.push_back("demon");
|
||||||
|
spriteList.push_back("dimallas_v");
|
||||||
|
spriteList.push_back("dimallas");
|
||||||
|
spriteList.push_back("diskette");
|
||||||
|
spriteList.push_back("dong");
|
||||||
|
spriteList.push_back("heavy");
|
||||||
|
spriteList.push_back("jailbattle_alien");
|
||||||
|
spriteList.push_back("jailbattle_human");
|
||||||
|
spriteList.push_back("jailer");
|
||||||
|
spriteList.push_back("jailer2");
|
||||||
|
spriteList.push_back("jailer3");
|
||||||
|
spriteList.push_back("lamp");
|
||||||
|
spriteList.push_back("macaronni_ted");
|
||||||
|
spriteList.push_back("matatunos");
|
||||||
|
spriteList.push_back("mummy");
|
||||||
|
spriteList.push_back("paco");
|
||||||
|
spriteList.push_back("printer");
|
||||||
|
spriteList.push_back("qvoid");
|
||||||
|
spriteList.push_back("sam");
|
||||||
|
spriteList.push_back("sigmasua");
|
||||||
|
spriteList.push_back("spider");
|
||||||
|
spriteList.push_back("tuno");
|
||||||
|
spriteList.push_back("tv_panel");
|
||||||
|
spriteList.push_back("tv");
|
||||||
|
spriteList.push_back("wave_v");
|
||||||
|
spriteList.push_back("wave");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carga todos los sprites desde una lista
|
||||||
|
void Ending2::loadSprites()
|
||||||
|
{
|
||||||
|
for (auto sl : spriteList)
|
||||||
|
{
|
||||||
|
sprites.push_back(new AnimatedSprite(renderer, resource->getAnimation(sl + ".ani")));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)sprites.size(); ++i)
|
||||||
|
{
|
||||||
|
const int x = (i * 20) % 220;
|
||||||
|
const int y = (i / 11) * 20;
|
||||||
|
sprites.at(i)->setPos({x, y});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Actualiza los sprites
|
||||||
|
void Ending2::updateSprites()
|
||||||
|
{
|
||||||
|
for (auto sprite : sprites)
|
||||||
|
{
|
||||||
|
sprite->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dibuja los sprites
|
||||||
|
void Ending2::renderSprites()
|
||||||
|
{
|
||||||
|
for (auto sprite : sprites)
|
||||||
|
{
|
||||||
|
sprite->render();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,21 +20,23 @@ class Ending2
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
Asset *asset; // Objeto con los ficheros de recursos
|
Asset *asset; // Objeto con los ficheros de recursos
|
||||||
Resource *resource; // Objeto con los recursos
|
Resource *resource; // Objeto con los recursos
|
||||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||||
SDL_Event *eventHandler; // Manejador de eventos
|
SDL_Event *eventHandler; // Manejador de eventos
|
||||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||||
Text *text; // Objeto para escribir texto en pantalla
|
Text *text; // Objeto para escribir texto en pantalla
|
||||||
options_t *options; // Puntero a las opciones del juego
|
options_t *options; // Puntero a las opciones del juego
|
||||||
|
std::vector<AnimatedSprite *> sprites; // Vector con todos los sprites a dibujar
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int counter; // Contador
|
int counter; // Contador
|
||||||
int preCounter; // Contador previo
|
int preCounter; // Contador previo
|
||||||
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
|
||||||
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
Uint32 ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||||
JA_Music music; // Musica que suena durante el final
|
JA_Music music; // Musica que suena durante el final
|
||||||
|
std::vector<std::string> spriteList; // Lista con todos los sprites a dibujar
|
||||||
|
|
||||||
// Actualiza el objeto
|
// Actualiza el objeto
|
||||||
void update();
|
void update();
|
||||||
@@ -48,6 +50,18 @@ private:
|
|||||||
// Actualiza los contadores
|
// Actualiza los contadores
|
||||||
void updateCounters();
|
void updateCounters();
|
||||||
|
|
||||||
|
// Inicializa la lista de sprites
|
||||||
|
void iniSpriteList();
|
||||||
|
|
||||||
|
// Carga todos los sprites desde una lista
|
||||||
|
void loadSprites();
|
||||||
|
|
||||||
|
// Actualiza los sprites
|
||||||
|
void updateSprites();
|
||||||
|
|
||||||
|
// Dibuja los sprites
|
||||||
|
void renderSprites();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
Ending2(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *asset, options_t *options);
|
||||||
|
|||||||
Reference in New Issue
Block a user