forked from jaildesigner-jailgames/jaildoctors_dilemma
Arreglos en la estructura i format del codi
This commit is contained in:
@@ -18,30 +18,22 @@
|
||||
|
||||
// Constructor
|
||||
LoadingScreen::LoadingScreen()
|
||||
: screen_(Screen::get()),
|
||||
renderer_(Screen::get()->getRenderer()),
|
||||
resource_(Resource::get()),
|
||||
asset_(Asset::get()),
|
||||
input_(Input::get())
|
||||
{
|
||||
// Reserva memoria para los punteros
|
||||
if (options.video.palette == Palette::ZXSPECTRUM)
|
||||
{
|
||||
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn.png");
|
||||
color_loading_screen_texture_ = resource_->getTexture("loading_screen_color.png");
|
||||
mono_loading_screen_texture_ = Resource::get()->getTexture("loading_screen_bn.png");
|
||||
color_loading_screen_texture_ = Resource::get()->getTexture("loading_screen_color.png");
|
||||
}
|
||||
else if (options.video.palette == Palette::ZXARNE)
|
||||
{
|
||||
mono_loading_screen_texture_ = resource_->getTexture("loading_screen_bn_zxarne.png");
|
||||
color_loading_screen_texture_ = resource_->getTexture("loading_screen_color_zxarne.png");
|
||||
mono_loading_screen_texture_ = Resource::get()->getTexture("loading_screen_bn_zxarne.png");
|
||||
color_loading_screen_texture_ = Resource::get()->getTexture("loading_screen_color_zxarne.png");
|
||||
}
|
||||
mono_loading_screen_sprite_ = std::make_shared<Sprite>(mono_loading_screen_texture_, 0, 0, mono_loading_screen_texture_->getWidth(), mono_loading_screen_texture_->getHeight());
|
||||
color_loading_screen_sprite_ = std::make_shared<Sprite>(color_loading_screen_texture_, 0, 0, color_loading_screen_texture_->getWidth(), color_loading_screen_texture_->getHeight());
|
||||
loading_sound1_ = resource_->getMusic("loading_sound1.ogg");
|
||||
loading_sound2_ = resource_->getMusic("loading_sound2.ogg");
|
||||
loading_sound3_ = resource_->getMusic("loading_sound3.ogg");
|
||||
|
||||
texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, options.game.width, options.game.height);
|
||||
texture_ = SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, options.game.width, options.game.height);
|
||||
if (texture_ == nullptr)
|
||||
{
|
||||
if (options.console)
|
||||
@@ -73,7 +65,7 @@ LoadingScreen::LoadingScreen()
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
screen_->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -125,7 +117,7 @@ void LoadingScreen::updateLoad()
|
||||
load_rect_ = {0, 0, 16, 8};
|
||||
color_loading_screen_sprite_->setClip(load_rect_);
|
||||
color_loading_screen_sprite_->setPosition(load_rect_);
|
||||
JA_PlayMusic(loading_sound3_);
|
||||
JA_PlayMusic(Resource::get()->getMusic("loading_sound3.ogg"));
|
||||
}
|
||||
}
|
||||
// Segunda parte de la carga, la parte de los bloques en color
|
||||
@@ -154,7 +146,7 @@ void LoadingScreen::updateCounter()
|
||||
|
||||
if (counter_ == 1)
|
||||
{
|
||||
JA_PlayMusic(loading_sound2_);
|
||||
JA_PlayMusic(Resource::get()->getMusic("loading_sound2.ogg"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,12 +161,12 @@ void LoadingScreen::renderBorder()
|
||||
{
|
||||
// Pinta el borde de colro azul
|
||||
Color color = stringToColor(options.video.palette, "blue");
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
// Añade lineas amarillas
|
||||
color = stringToColor(options.video.palette, "yellow");
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), color.r, color.g, color.b, 0xFF);
|
||||
const int WIDTH = options.game.width + (options.video.border.width * 2);
|
||||
const int HEIGHT = options.game.height + (options.video.border.height * 2);
|
||||
bool drawEnabled = rand() % 2 == 0 ? true : false;
|
||||
@@ -187,7 +179,7 @@ void LoadingScreen::renderBorder()
|
||||
{
|
||||
for (int i = row; i < row + ROW_HEIGHT; ++i)
|
||||
{
|
||||
SDL_RenderDrawLine(renderer_, 0, i, WIDTH, i);
|
||||
SDL_RenderDrawLine(Screen::get()->getRenderer(), 0, i, WIDTH, i);
|
||||
}
|
||||
}
|
||||
row += ROW_HEIGHT;
|
||||
@@ -206,7 +198,7 @@ void LoadingScreen::update()
|
||||
updateCounter();
|
||||
updateLoad();
|
||||
fillTexture();
|
||||
screen_->update();
|
||||
Screen::get()->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,20 +208,20 @@ void LoadingScreen::render()
|
||||
if (options.video.border.enabled)
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura del borde
|
||||
screen_->startDrawOnBorder();
|
||||
Screen::get()->startDrawOnBorder();
|
||||
|
||||
// Dibuja el efecto de carga en el borde
|
||||
renderBorder();
|
||||
}
|
||||
|
||||
// Prepara para empezar a dibujar en la textura de juego
|
||||
screen_->start();
|
||||
Screen::get()->start();
|
||||
|
||||
// Copila la textura a la pantalla
|
||||
SDL_RenderCopy(renderer_, texture_, nullptr, nullptr);
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), texture_, nullptr, nullptr);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen_->render();
|
||||
Screen::get()->render();
|
||||
}
|
||||
|
||||
// Bucle para el logo del juego
|
||||
@@ -237,12 +229,12 @@ void LoadingScreen::run()
|
||||
{
|
||||
// Inicia el sonido de carga
|
||||
JA_SetVolume(64);
|
||||
JA_PlayMusic(loading_sound1_);
|
||||
JA_PlayMusic(Resource::get()->getMusic("loading_sound1.ogg"));
|
||||
|
||||
// Limpia la pantalla
|
||||
screen_->start();
|
||||
screen_->clean();
|
||||
screen_->render();
|
||||
Screen::get()->start();
|
||||
Screen::get()->clean();
|
||||
Screen::get()->render();
|
||||
|
||||
while (options.section.section == Section::LOADING_SCREEN)
|
||||
{
|
||||
@@ -258,27 +250,27 @@ void LoadingScreen::run()
|
||||
void LoadingScreen::fillTexture()
|
||||
{
|
||||
// Empieza a dibujar en la textura
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, texture_);
|
||||
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), texture_);
|
||||
|
||||
// Dibuja la pantalla de carga
|
||||
renderLoad();
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
|
||||
}
|
||||
|
||||
// Limpia la textura
|
||||
void LoadingScreen::clearTexture()
|
||||
{
|
||||
// Empieza a dibujar en la textura
|
||||
auto temp = SDL_GetRenderTarget(renderer_);
|
||||
SDL_SetRenderTarget(renderer_, texture_);
|
||||
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), texture_);
|
||||
|
||||
// Limpia
|
||||
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0x00, 0x00, 0x00, 0xFF);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
SDL_SetRenderTarget(renderer_, temp);
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
|
||||
}
|
||||
Reference in New Issue
Block a user