forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en el titulo
This commit is contained in:
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
@@ -17,7 +17,7 @@ Director::Director(std::string path)
|
||||
}
|
||||
else
|
||||
{
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
}
|
||||
|
||||
@@ -234,6 +234,9 @@ void Director::runIntro()
|
||||
// Ejecuta la seccion de juego con el titulo y los menus
|
||||
void Director::runTitle()
|
||||
{
|
||||
title = new Title(renderer, screen, asset);
|
||||
setSection(title->run());
|
||||
delete title;
|
||||
}
|
||||
|
||||
// Ejecuta la seccion de juego donde se juega
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "input.h"
|
||||
#include "game.h"
|
||||
#include "logo.h"
|
||||
#include "title.h"
|
||||
#include "asset.h"
|
||||
#include "const.h"
|
||||
|
||||
@@ -24,6 +25,7 @@ private:
|
||||
Input *input; // Objeto Input para gestionar las entradas
|
||||
Game *game; // Objeto para gestionar la sección del juego
|
||||
Logo *logo; // Objeto para gestionar la sección del logo del programa
|
||||
Title *title; // Objeto para gestionar la pantalla de título
|
||||
Asset *asset; // Objeto que gestiona todos los ficheros de recursos
|
||||
|
||||
struct options_t *options; // Variable con todas las opciones del programa
|
||||
|
||||
@@ -96,7 +96,7 @@ void Logo::checkEventHandler()
|
||||
// Cualquier tecla pulsada
|
||||
if ((eventHandler->type == SDL_KEYDOWN) || (eventHandler->type == SDL_JOYBUTTONDOWN))
|
||||
{
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
}
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void Logo::update()
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter == endLogo + postLogo)
|
||||
{
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
177
source/title.cpp
177
source/title.cpp
@@ -10,25 +10,8 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
|
||||
// Reserva memoria para los punteros
|
||||
eventHandler = new SDL_Event();
|
||||
texture = new LTexture(renderer, asset->get("jailgames.png"));
|
||||
texture2 = new LTexture(renderer, asset->get("since_1998.png"));
|
||||
sprite2 = new Sprite((256 - texture2->getWidth()) / 2, 83 + texture->getHeight() + 5, texture2->getWidth(), texture2->getHeight(), texture2, renderer);
|
||||
sprite2->setSpriteClip(0, 0, texture2->getWidth(), texture2->getHeight());
|
||||
texture2->setColor(0, 0, 0);
|
||||
|
||||
for (int i = 0; i < texture->getHeight(); i++)
|
||||
{
|
||||
sprite.push_back(new Sprite(0, i, texture->getWidth(), 1, texture, renderer));
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
sprite[i]->setPosX(256 + (i * 3));
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite[i]->setPosX(-181 - (i * 3));
|
||||
}
|
||||
sprite[i]->setPosY(83 + i);
|
||||
}
|
||||
texture = new LTexture(renderer, asset->get("loading_screen2.png"));
|
||||
sprite = new Sprite(0,0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
||||
|
||||
// Inicializa variables
|
||||
counter = 0;
|
||||
@@ -36,47 +19,13 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
section.subsection = 0;
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
initFade = 300;
|
||||
endLogo = 400;
|
||||
postLogo = 20;
|
||||
|
||||
color_t c = stringToColor("black");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("blue");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("red");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("purple");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("green");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("cyan");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("yellow");
|
||||
color.push_back(c);
|
||||
|
||||
c = stringToColor("light_white");
|
||||
color.push_back(c);
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Title::~Title()
|
||||
{
|
||||
delete texture;
|
||||
delete texture2;
|
||||
|
||||
for (auto s : sprite)
|
||||
{
|
||||
delete s;
|
||||
}
|
||||
|
||||
delete sprite2;
|
||||
delete sprite;
|
||||
delete eventHandler;
|
||||
}
|
||||
|
||||
@@ -116,118 +65,6 @@ void Title::update()
|
||||
|
||||
// Incrementa el contador
|
||||
counter++;
|
||||
|
||||
// update de JAILGAMES
|
||||
if (counter > 30)
|
||||
{
|
||||
for (int i = 1; i < sprite.size(); i++)
|
||||
{
|
||||
const int speed = 8;
|
||||
const int dest = 37;
|
||||
if (sprite[i]->getPosX() != 37)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
sprite[i]->incPosX(-speed);
|
||||
if (sprite[i]->getPosX() < dest)
|
||||
{
|
||||
sprite[i]->setPosX(dest);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite[i]->incPosX(speed);
|
||||
if (sprite[i]->getPosX() > dest)
|
||||
{
|
||||
sprite[i]->setPosX(dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update de fade
|
||||
{
|
||||
const int ini = 70;
|
||||
const int inc = 4;
|
||||
|
||||
if (counter == ini + inc * 0)
|
||||
{
|
||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||
}
|
||||
else if (counter == ini + inc * 1)
|
||||
{
|
||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||
}
|
||||
else if (counter == ini + inc * 2)
|
||||
{
|
||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||
}
|
||||
else if (counter == ini + inc * 3)
|
||||
{
|
||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||
}
|
||||
else if (counter == ini + inc * 4)
|
||||
{
|
||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||
}
|
||||
else if (counter == ini + inc * 5)
|
||||
{
|
||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||
}
|
||||
else if (counter == ini + inc * 6)
|
||||
{
|
||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||
}
|
||||
|
||||
else if (counter == ini + inc * 7)
|
||||
{
|
||||
texture2->setColor(color[7].r, color[7].g, color[7].b);
|
||||
}
|
||||
|
||||
else if (counter == initFade + inc * 0)
|
||||
{
|
||||
texture->setColor(color[6].r, color[6].g, color[6].b);
|
||||
texture2->setColor(color[6].r, color[6].g, color[6].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 1)
|
||||
{
|
||||
texture->setColor(color[5].r, color[5].g, color[5].b);
|
||||
texture2->setColor(color[5].r, color[5].g, color[5].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 2)
|
||||
{
|
||||
texture->setColor(color[4].r, color[4].g, color[4].b);
|
||||
texture2->setColor(color[4].r, color[4].g, color[4].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 3)
|
||||
{
|
||||
texture->setColor(color[3].r, color[3].g, color[3].b);
|
||||
texture2->setColor(color[3].r, color[3].g, color[3].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 4)
|
||||
{
|
||||
texture->setColor(color[2].r, color[2].g, color[2].b);
|
||||
texture2->setColor(color[2].r, color[2].g, color[2].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 5)
|
||||
{
|
||||
texture->setColor(color[1].r, color[1].g, color[1].b);
|
||||
texture2->setColor(color[1].r, color[1].g, color[1].b);
|
||||
}
|
||||
else if (counter == initFade + inc * 6)
|
||||
{
|
||||
texture->setColor(color[0].r, color[0].g, color[0].b);
|
||||
texture2->setColor(color[0].r, color[0].g, color[0].b);
|
||||
}
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter == endLogo + postLogo)
|
||||
{
|
||||
section.name = SECTION_PROG_QUIT;
|
||||
section.subsection = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,11 +78,7 @@ void Title::render()
|
||||
screen->clean();
|
||||
|
||||
// Dibuja los objetos
|
||||
for (auto s : sprite)
|
||||
{
|
||||
s->render();
|
||||
}
|
||||
sprite2->render();
|
||||
sprite->render();
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
@@ -264,4 +97,4 @@ section_t Title::run()
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
}
|
||||
@@ -16,22 +16,16 @@
|
||||
class Title
|
||||
{
|
||||
private:
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto con los ficheros de recursos
|
||||
LTexture *texture; // Textura con los graficos "JAILGAMES"
|
||||
LTexture *texture2; // Textura con los graficos "Since 1998"
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
std::vector<Sprite *> sprite; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||
Sprite *sprite2; // Sprite para manejar la textura2
|
||||
std::vector<color_t> color; // Vector con los colores para el fade
|
||||
int counter; // Contador
|
||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
int initFade; // Tiempo del contador cuando inicia el fade a negro
|
||||
int endLogo; // Tiempo del contador para terminar el logo
|
||||
int postLogo; // Tiempo que dura el logo con el fade al maximo
|
||||
SDL_Renderer *renderer; // El renderizador de la ventana
|
||||
Screen *screen; // Objeto encargado de dibujar en pantalla
|
||||
Asset *asset; // Objeto con los ficheros de recursos
|
||||
SDL_Event *eventHandler; // Manejador de eventos
|
||||
LTexture *texture; // Textura con los graficos
|
||||
Sprite *sprite; // Sprite para manejar la textura
|
||||
int counter; // Contador
|
||||
section_t section; // Estado del bucle principal para saber si continua o se sale
|
||||
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user