Afegida musica als credits
Els globos ara tenen definida una play_area Opció de canviar la paleta al text
This commit is contained in:
@@ -5,19 +5,28 @@
|
||||
#include "jail_audio.h" // Para JA_StopMusic
|
||||
#include "screen.h" // Para Screen
|
||||
#include "balloon_manager.h" // Para BalloonManager
|
||||
#include "param.h"
|
||||
#include "resource.h"
|
||||
#include "text.h"
|
||||
|
||||
// Constructor
|
||||
Credits::Credits()
|
||||
: balloon_manager_(std::make_unique<BalloonManager>())
|
||||
|
||||
: balloon_manager_(std::make_unique<BalloonManager>()),
|
||||
text_texture_(SDL_CreateTexture(Screen::get()->getRenderer(), SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
|
||||
tiled_bg_(std::make_unique<TiledBG>((SDL_Rect){0, 0, param.game.width, param.game.height}, TiledBGMode::DIAGONAL))
|
||||
{
|
||||
section::name = section::Name::CREDITS;
|
||||
balloon_manager_->setPlayArea(param.game.game_area.rect);
|
||||
balloon_manager_->createTwoBigBalloons();
|
||||
SDL_SetTextureBlendMode(text_texture_, SDL_BLENDMODE_BLEND);
|
||||
fillTextTexture();
|
||||
JA_PlayMusic(Resource::get()->getMusic("credits.ogg"));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
Credits::~Credits()
|
||||
{
|
||||
SDL_DestroyTexture(text_texture_);
|
||||
}
|
||||
|
||||
// Bucle principal
|
||||
@@ -40,7 +49,9 @@ void Credits::update()
|
||||
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
|
||||
{
|
||||
ticks_ = SDL_GetTicks();
|
||||
tiled_bg_->update();
|
||||
balloon_manager_->update();
|
||||
Screen::get()->update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +64,9 @@ void Credits::render()
|
||||
// Limpia la pantalla
|
||||
Screen::get()->clean();
|
||||
|
||||
tiled_bg_->render();
|
||||
balloon_manager_->render();
|
||||
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, nullptr, nullptr);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
Screen::get()->blit();
|
||||
@@ -84,11 +97,74 @@ void Credits::checkInput()
|
||||
if (Input::get()->checkAnyButtonPressed())
|
||||
{
|
||||
JA_StopMusic();
|
||||
section::name = section::Name::TITLE;
|
||||
section::options = section::Options::TITLE_1;
|
||||
section::name = section::Name::LOGO;
|
||||
return;
|
||||
}
|
||||
|
||||
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
|
||||
globalInputs::check();
|
||||
}
|
||||
|
||||
// Crea la textura con el texto
|
||||
void Credits::fillTextTexture()
|
||||
{
|
||||
auto text = Resource::get()->getText("smb2");
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), text_texture_);
|
||||
|
||||
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0);
|
||||
SDL_RenderClear(Screen::get()->getRenderer());
|
||||
|
||||
std::vector<std::string> texts = {
|
||||
"PROGRAMACIO I DISSENY",
|
||||
"GRAFICS",
|
||||
"MUSICA",
|
||||
"SONS",
|
||||
"JAILDESIGNER",
|
||||
"JAILDOCTOR (INTRO)",
|
||||
"ERIC MATYAS (SOUNDIMAGE.ORG)",
|
||||
"WWW.THEMOTIONMONKEY.CO.UK",
|
||||
"WWW.KENNEY.NL",
|
||||
"JAILDOCTOR"};
|
||||
|
||||
const int space_post_title = 3 + text->getCharacterSize();
|
||||
const int space_pre_title = text->getCharacterSize() * 3;
|
||||
const int texts_height = 1 * text->getCharacterSize() + 7 * space_post_title + 3 * space_pre_title;
|
||||
|
||||
int y = (param.game.height - texts_height) / 2;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(0), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(1), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(4), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(2), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(5), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(6), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
y += space_pre_title;
|
||||
text->setPalette(1);
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(3), 1, no_color, 1, shdw_txt_color);
|
||||
text->setPalette(0);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(7), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(8), 1, no_color, 1, shdw_txt_color);
|
||||
y += space_post_title;
|
||||
text->writeDX(TEXT_CENTER | TEXT_SHADOW, param.game.width / 2, y, texts.at(9), 1, no_color, 1, shdw_txt_color);
|
||||
|
||||
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
|
||||
}
|
||||
Reference in New Issue
Block a user