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();
|
||||
|
||||
Reference in New Issue
Block a user