forked from jaildesigner-jailgames/jaildoctors_dilemma
Ya colorea la intro
This commit is contained in:
@@ -13,7 +13,9 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
texture = new LTexture(renderer, asset->get("loading_screen1.png"));
|
||||
texture2 = new LTexture(renderer, asset->get("loading_screen2.png"));
|
||||
sprite = new Sprite(0, 0, texture->getWidth(), texture->getHeight(), texture, renderer);
|
||||
sprite2 = new Sprite(0, 0, texture2->getWidth(), texture2->getHeight(), texture, renderer);
|
||||
sprite2 = new Sprite(0, 0, texture2->getWidth(), texture2->getHeight(), texture2, renderer);
|
||||
|
||||
text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer);
|
||||
|
||||
// Inicializa variables
|
||||
counter = 0;
|
||||
@@ -22,6 +24,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset)
|
||||
ticks = 0;
|
||||
ticksSpeed = 15;
|
||||
counterLoad1 = 0;
|
||||
counterLoad2 = 0;
|
||||
|
||||
color_t c = stringToColor("black");
|
||||
color.push_back(c);
|
||||
@@ -56,6 +59,8 @@ Intro::~Intro()
|
||||
delete sprite;
|
||||
delete sprite2;
|
||||
delete eventHandler;
|
||||
|
||||
delete text;
|
||||
}
|
||||
|
||||
// Comprueba el manejador de eventos
|
||||
@@ -83,17 +88,24 @@ void Intro::checkEventHandler()
|
||||
// Gestiona la primera parte de la carga
|
||||
void Intro::updateLoad1()
|
||||
{
|
||||
counterLoad1 = std::min(counter / 3, 64);
|
||||
counterLoad1 = std::min(counter / 3, 65);
|
||||
}
|
||||
|
||||
// Gestiona la segunda parte de la carga
|
||||
void Intro::updateLoad2()
|
||||
{
|
||||
if (counterLoad1 == 65)
|
||||
{
|
||||
counterLoad2 += 2;
|
||||
counterLoad2 = std::min(counterLoad2, 768);
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja la pantalla de carga
|
||||
void Intro::renderLoad()
|
||||
{
|
||||
if (counterLoad1 <= 64)
|
||||
{
|
||||
sprite->render();
|
||||
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
||||
|
||||
@@ -105,6 +117,20 @@ void Intro::renderLoad()
|
||||
|
||||
rect.y += 64;
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite->render();
|
||||
SDL_Rect rect = {0, 0, 8, 8};
|
||||
for (int i = 0; i < counterLoad2; i++)
|
||||
{
|
||||
rect.x = (i * 8) % 256;
|
||||
rect.y = (i / 32) * 8;
|
||||
sprite2->setPos(rect);
|
||||
sprite2->setSpriteClip(rect);
|
||||
sprite2->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza las variables
|
||||
@@ -128,8 +154,8 @@ void Intro::update()
|
||||
// Gestiona la segunda parte de la carga
|
||||
updateLoad2();
|
||||
|
||||
// Comprueba si ha terminado el logo
|
||||
if (counter == 1000)
|
||||
// Comprueba si ha terminado la intro
|
||||
if (counterLoad2 >= 768)
|
||||
{
|
||||
section.name = SECTION_PROG_TITLE;
|
||||
section.subsection = 0;
|
||||
@@ -148,6 +174,8 @@ void Intro::render()
|
||||
|
||||
// Dibuja la pantalla de carga
|
||||
renderLoad();
|
||||
text->write(0, 0, std::to_string(counterLoad1));
|
||||
text->write(0, 8, std::to_string(counterLoad2));
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->blit();
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
#include "jail_audio.h"
|
||||
#include <vector>
|
||||
|
||||
#include <string>
|
||||
#include "text.h"
|
||||
|
||||
#ifndef INTRO_H
|
||||
#define INTRO_H
|
||||
|
||||
@@ -30,6 +33,9 @@ private:
|
||||
int ticks; // Contador de ticks para ajustar la velocidad del programa
|
||||
int ticksSpeed; // Velocidad a la que se repiten los bucles del programa
|
||||
int counterLoad1;
|
||||
int counterLoad2;
|
||||
|
||||
Text *text;
|
||||
|
||||
// Actualiza las variables
|
||||
void update();
|
||||
|
||||
Reference in New Issue
Block a user