forked from jaildesigner-jailgames/jaildoctors_dilemma
Trabajando en los creditos
This commit is contained in:
@@ -23,9 +23,38 @@ Credits::Credits(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
screen->setBorderColor(stringToColor("black"));
|
||||
|
||||
// Inicializa los textos
|
||||
texts.push_back("ESTE ES UN TEXTO DE PRUEBA");
|
||||
texts.push_back("PARA VER COMO FUNCIONA LA CLASE");
|
||||
texts.push_back("Y TENGO QUE PONER ALGUN TEXTO PARA PROBAR");
|
||||
texts.push_back("");
|
||||
texts.push_back("INSTRUCTIONS:");
|
||||
texts.push_back("");
|
||||
texts.push_back("HELP JAILDOC TO GET BACK ALL HIS");
|
||||
texts.push_back("PROJECTS AND GO TO THE JAIL TO");
|
||||
texts.push_back("FINISH THEM");
|
||||
texts.push_back("");
|
||||
texts.push_back("");
|
||||
texts.push_back("KEYS:");
|
||||
texts.push_back("");
|
||||
texts.push_back("USE CURSORS TO MOVE AND JUMP");
|
||||
texts.push_back("F1-F4 TO CHANGE WINDOWS SIZE");
|
||||
texts.push_back("F TO SWITCH TO FULLSCREEN");
|
||||
texts.push_back("B TO DE/ACTIVATE THE BORDER SC.");
|
||||
texts.push_back("M TO TURN ON/OFF THE MUSIC");
|
||||
texts.push_back("ESC TO EXIT GAME");
|
||||
texts.push_back("");
|
||||
texts.push_back("");
|
||||
texts.push_back("A GAME BY JAILDESIGNER");
|
||||
texts.push_back("MADE ON SUMMER/FALL 2022");
|
||||
texts.push_back("");
|
||||
texts.push_back("");
|
||||
texts.push_back("LOVE JAILGAMES!");
|
||||
texts.push_back("");
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
textTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (textTexture == NULL)
|
||||
printf("Error: textTexture could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
|
||||
// Escribe el texto en la textura
|
||||
fillTexture();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -69,6 +98,23 @@ void Credits::checkEventHandler()
|
||||
}
|
||||
}
|
||||
|
||||
// Escribe el texto en la textura
|
||||
void Credits::fillTexture()
|
||||
{
|
||||
SDL_SetRenderTarget(renderer, textTexture);
|
||||
SDL_SetTextureBlendMode(textTexture, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Escribe el texto en la textura
|
||||
for (int i = 0; i < texts.size(); ++i)
|
||||
{
|
||||
text->write(0, i * 8, texts[i]);
|
||||
}
|
||||
|
||||
SDL_SetRenderTarget(renderer, nullptr);
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
void Credits::update()
|
||||
{
|
||||
@@ -85,7 +131,7 @@ void Credits::update()
|
||||
counter++;
|
||||
|
||||
// Comprueba si ha terminado la sección
|
||||
if (counter>1000)
|
||||
if (counter > 1000)
|
||||
{
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
}
|
||||
@@ -101,13 +147,11 @@ void Credits::render()
|
||||
// Limpia la pantalla
|
||||
screen->clean();
|
||||
|
||||
// Dibuja el contenido de la sección
|
||||
//const color_t color = stringToColor("black");
|
||||
//SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, 255);
|
||||
//SDL_RenderFillRect(renderer)
|
||||
text->write(8,8,texts[0]);
|
||||
text->write(8,16,texts[1]);
|
||||
text->write(8,24,texts[2]);
|
||||
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
||||
|
||||
// Dibuja la textura con el mapa en pantalla
|
||||
SDL_RenderCopy(renderer, textTexture, &rect, NULL);
|
||||
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
|
||||
@@ -24,16 +24,17 @@ private:
|
||||
bool enabled; // Solo se escriben y mueven si estan habilitadas
|
||||
};
|
||||
|
||||
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
|
||||
Text *text; // Objeto para escribir texto en pantalla
|
||||
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
|
||||
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
|
||||
Text *text; // Objeto para escribir texto en pantalla
|
||||
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
|
||||
std::vector<std::string> texts; // Vector con las letras de la marquesina
|
||||
SDL_Texture *textTexture; // Textura para dibujar el texto
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
@@ -44,11 +45,8 @@ private:
|
||||
// Comprueba el manejador de eventos
|
||||
void checkEventHandler();
|
||||
|
||||
// Actualiza la marquesina
|
||||
void updateMarquee();
|
||||
|
||||
// Dibuja la marquesina
|
||||
void renderMarquee();
|
||||
// Escribe el texto en la textura
|
||||
void fillTexture();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
@@ -17,7 +17,7 @@ Director::Director(std::string path)
|
||||
}
|
||||
else
|
||||
{
|
||||
section.name = SECTION_PROG_GAME;
|
||||
section.name = SECTION_PROG_CREDITS;
|
||||
section.subsection = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
/*
|
||||
Cada habitación se crea y destruye cada vez que se entra o sale de la misma
|
||||
Cada habitacion tiene lo siguiente:
|
||||
- ID (numerico)
|
||||
- NOMBRE (texto)
|
||||
- COLOR DE FONDO (texto)
|
||||
- COLOR DEL BORDE (texto)
|
||||
|
||||
Reference in New Issue
Block a user