forked from jaildesigner-jailgames/jaildoctors_dilemma
fix: s'havien fotut els dos finals, pero ja estan corregits
This commit is contained in:
@@ -1,55 +1,38 @@
|
||||
#include "credits.h"
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <algorithm> // for min
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
#include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
|
||||
#include "global_events.h" // for check
|
||||
#include "global_inputs.h" // for check
|
||||
#include "options.h" // for Options, options, OptionsVideo, Sect...
|
||||
#include "resource.h" // for Resource
|
||||
#include "screen.h" // for Screen
|
||||
#include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_error.h> // for SDL_GetError
|
||||
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_rect.h> // for SDL_Rect
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <algorithm> // for min
|
||||
#include <iostream> // for basic_ostream, operator<<, cout, endl
|
||||
#include "animated_sprite.h" // for AnimatedSprite
|
||||
#include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
|
||||
#include "global_events.h" // for check
|
||||
#include "global_inputs.h" // for check
|
||||
#include "options.h" // for Options, options, OptionsVideo, Sect...
|
||||
#include "resource.h" // for Resource
|
||||
#include "screen.h" // for Screen
|
||||
#include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR
|
||||
|
||||
// Constructor
|
||||
Credits::Credits()
|
||||
: shining_sprite_(std::make_shared<AnimatedSprite>(Resource::get()->getTexture("shine.png"), Resource::get()->getAnimations("shine.ani")))
|
||||
{
|
||||
// Reserva memoria para los punteros
|
||||
sprite_ = std::make_shared<AnimatedSprite>(Resource::get()->getTexture("shine.png"), Resource::get()->getAnimations("shine.ani"));
|
||||
|
||||
// Inicializa variables
|
||||
options.section.section = Section::CREDITS;
|
||||
options.section.subsection = Subsection::NONE;
|
||||
sprite_->setPosition({194, 174, 8, 8});
|
||||
shining_sprite_->setPosition({194, 174, 8, 8});
|
||||
|
||||
// Cambia el color del borde
|
||||
Screen::get()->setBorderColor(stringToColor(options.video.palette, "black"));
|
||||
|
||||
// Crea la textura para el texto que se escribe en pantalla
|
||||
text_texture_ = SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (text_texture_ == nullptr)
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
SDL_SetTextureBlendMode(text_texture_, SDL_BLENDMODE_BLEND);
|
||||
text_texture_ = createTexture(Screen::get()->getRenderer(), options.game.width, options.game.height);
|
||||
|
||||
// Crea la textura para cubrir el rexto
|
||||
cover_texture_ = SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);
|
||||
if (cover_texture_ == nullptr)
|
||||
{
|
||||
if (options.console)
|
||||
{
|
||||
std::cout << "Error: textTexture could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
}
|
||||
cover_texture_ = createTexture(Screen::get()->getRenderer(), options.game.width, options.game.height);
|
||||
SDL_SetTextureBlendMode(cover_texture_, SDL_BLENDMODE_BLEND);
|
||||
|
||||
// Escribe el texto en la textura
|
||||
@@ -190,7 +173,7 @@ void Credits::fillTexture()
|
||||
text->writeColored(POS_X, 176, "}", stringToColor(options.video.palette, "bright_red"));
|
||||
|
||||
// Recoloca el sprite del brillo
|
||||
sprite_->setPosX(POS_X + 2);
|
||||
shining_sprite_->setPosX(POS_X + 2);
|
||||
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
|
||||
@@ -268,7 +251,7 @@ void Credits::update()
|
||||
// Actualiza el sprite con el brillo
|
||||
if (counter_ > 770)
|
||||
{
|
||||
sprite_->update();
|
||||
shining_sprite_->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -294,7 +277,7 @@ void Credits::render()
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), cover_texture_, &srcRect, &dstRect);
|
||||
|
||||
// Dibuja el sprite con el brillo
|
||||
sprite_->render();
|
||||
shining_sprite_->render();
|
||||
}
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
|
||||
Reference in New Issue
Block a user