|
|
|
@@ -1,12 +1,11 @@
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
|
|
#include "credits.h"
|
|
|
|
#include "credits.h"
|
|
|
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
|
|
|
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
|
|
|
|
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
|
|
|
|
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
|
|
|
|
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
|
|
|
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
|
|
|
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
|
|
|
#include <SDL2/SDL_rect.h> // Para SDL_Rect
|
|
|
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
|
|
|
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <string> // Para basic_string, string
|
|
|
|
#include <string> // Para basic_string, string
|
|
|
|
#include <vector> // Para vector
|
|
|
|
#include <vector> // Para vector
|
|
|
|
#include "balloon_manager.h" // Para BalloonManager
|
|
|
|
#include "balloon_manager.h" // Para BalloonManager
|
|
|
|
@@ -22,6 +21,7 @@
|
|
|
|
#include "utils.h" // Para Color, no_color, shdw_txt_color, Zone
|
|
|
|
#include "utils.h" // Para Color, no_color, shdw_txt_color, Zone
|
|
|
|
#include "player.h"
|
|
|
|
#include "player.h"
|
|
|
|
#include "fade.h"
|
|
|
|
#include "fade.h"
|
|
|
|
|
|
|
|
#include "lang.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Textos
|
|
|
|
// Textos
|
|
|
|
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";
|
|
|
|
constexpr const char TEXT_COPYRIGHT[] = "@2020,2024 JailDesigner";
|
|
|
|
@@ -34,6 +34,10 @@ Credits::Credits()
|
|
|
|
fade_in_(std::make_unique<Fade>()),
|
|
|
|
fade_in_(std::make_unique<Fade>()),
|
|
|
|
fade_out_(std::make_unique<Fade>())
|
|
|
|
fade_out_(std::make_unique<Fade>())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!text_texture_)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw std::runtime_error("Failed to create SDL texture for text.");
|
|
|
|
|
|
|
|
}
|
|
|
|
section::name = section::Name::CREDITS;
|
|
|
|
section::name = section::Name::CREDITS;
|
|
|
|
top_black_rect_ = {play_area_.x, 0, play_area_.w, black_bars_size_};
|
|
|
|
top_black_rect_ = {play_area_.x, 0, play_area_.w, black_bars_size_};
|
|
|
|
bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_};
|
|
|
|
bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_};
|
|
|
|
@@ -49,7 +53,6 @@ Credits::Credits()
|
|
|
|
initPlayers();
|
|
|
|
initPlayers();
|
|
|
|
SDL_SetTextureBlendMode(text_texture_, SDL_BLENDMODE_BLEND);
|
|
|
|
SDL_SetTextureBlendMode(text_texture_, SDL_BLENDMODE_BLEND);
|
|
|
|
fillTextTexture();
|
|
|
|
fillTextTexture();
|
|
|
|
// JA_PlayMusic(Resource::get()->getMusic("credits.ogg"));
|
|
|
|
|
|
|
|
steps_ = std::abs((top_black_rect_.h - param.game.game_area.center_y - 1) + ((left_black_rect_.w - param.game.game_area.center_x) / 4));
|
|
|
|
steps_ = std::abs((top_black_rect_.h - param.game.game_area.center_y - 1) + ((left_black_rect_.w - param.game.game_area.center_x) / 4));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -116,20 +119,19 @@ void Credits::render()
|
|
|
|
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
|
|
|
|
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
|
|
|
|
|
|
|
|
|
|
|
|
// Dibuja los rectangulos negros
|
|
|
|
// Dibuja los rectangulos negros
|
|
|
|
// SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0x27, 0x27, 0x36, 255);
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 255);
|
|
|
|
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 255);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &top_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &top_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &bottom_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &bottom_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &left_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &left_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &right_black_rect_);
|
|
|
|
SDL_RenderFillRect(Screen::get()->getRenderer(), &right_black_rect_);
|
|
|
|
|
|
|
|
|
|
|
|
// Si el mini_logo está en su destino, lo dibuja encima del resto
|
|
|
|
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior
|
|
|
|
if (mini_logo_on_position_)
|
|
|
|
if (mini_logo_on_position_)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
|
|
|
|
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Dibuja el fade sobre el resto
|
|
|
|
// Dibuja el fade sobre el resto de elementos
|
|
|
|
fade_in_->render();
|
|
|
|
fade_in_->render();
|
|
|
|
fade_out_->render();
|
|
|
|
fade_out_->render();
|
|
|
|
|
|
|
|
|
|
|
|
@@ -188,10 +190,10 @@ void Credits::fillTextTexture()
|
|
|
|
SDL_RenderClear(Screen::get()->getRenderer());
|
|
|
|
SDL_RenderClear(Screen::get()->getRenderer());
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<std::string> texts = {
|
|
|
|
std::vector<std::string> texts = {
|
|
|
|
"PROGRAMACIO I DISSENY",
|
|
|
|
lang::getText(121),
|
|
|
|
"GRAFICS",
|
|
|
|
lang::getText(122),
|
|
|
|
"MUSICA",
|
|
|
|
lang::getText(123),
|
|
|
|
"SONS",
|
|
|
|
lang::getText(124),
|
|
|
|
"JAILDESIGNER",
|
|
|
|
"JAILDESIGNER",
|
|
|
|
"JAILDOCTOR (INTRO)",
|
|
|
|
"JAILDOCTOR (INTRO)",
|
|
|
|
"ERIC MATYAS (SOUNDIMAGE.ORG)",
|
|
|
|
"ERIC MATYAS (SOUNDIMAGE.ORG)",
|
|
|
|
@@ -257,10 +259,11 @@ void Credits::fillTextTexture()
|
|
|
|
y += mini_logo_sprite->getHeight() + 3;
|
|
|
|
y += mini_logo_sprite->getHeight() + 3;
|
|
|
|
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXT_COPYRIGHT, 1, no_color, 1, shdw_txt_color);
|
|
|
|
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.game_area.center_x, y, TEXT_COPYRIGHT, 1, no_color, 1, shdw_txt_color);
|
|
|
|
|
|
|
|
|
|
|
|
mini_logo_rect_dst_.h = mini_logo_rect_src_.h = mini_logo_sprite->getHeight() + 3 + text->getCharacterSize();
|
|
|
|
// Resetea el renderizador
|
|
|
|
|
|
|
|
|
|
|
|
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
|
|
|
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Actualiza las variables
|
|
|
|
|
|
|
|
mini_logo_rect_dst_.h = mini_logo_rect_src_.h = mini_logo_sprite->getHeight() + 3 + text->getCharacterSize();
|
|
|
|
credits_rect_dst_.y = param.game.game_area.rect.h;
|
|
|
|
credits_rect_dst_.y = param.game.game_area.rect.h;
|
|
|
|
mini_logo_rect_dst_.y = credits_rect_dst_.y + credits_rect_dst_.h + 30;
|
|
|
|
mini_logo_rect_dst_.y = credits_rect_dst_.y + credits_rect_dst_.h + 30;
|
|
|
|
mini_logo_final_pos_ = param.game.game_area.center_y - mini_logo_rect_src_.h / 2;
|
|
|
|
mini_logo_final_pos_ = param.game.game_area.center_y - mini_logo_rect_src_.h / 2;
|
|
|
|
@@ -312,7 +315,9 @@ void Credits::throwBalloons()
|
|
|
|
const std::vector<int> sets = {0, 63, 25, 67, 17, 75, 13, 50};
|
|
|
|
const std::vector<int> sets = {0, 63, 25, 67, 17, 75, 13, 50};
|
|
|
|
|
|
|
|
|
|
|
|
if (counter_ > ((sets.size() - 1) * speed) * 3)
|
|
|
|
if (counter_ > ((sets.size() - 1) * speed) * 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (counter_ % speed == 0)
|
|
|
|
if (counter_ % speed == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|