diff --git a/data/gfx/intro/intro.png b/data/gfx/intro/intro.png deleted file mode 100644 index 4d0964b..0000000 Binary files a/data/gfx/intro/intro.png and /dev/null differ diff --git a/data/gfx/intro/intro1.png b/data/gfx/intro/intro1.png new file mode 100644 index 0000000..356b996 Binary files /dev/null and b/data/gfx/intro/intro1.png differ diff --git a/data/gfx/intro/intro2.png b/data/gfx/intro/intro2.png index 36f343f..6d5649a 100644 Binary files a/data/gfx/intro/intro2.png and b/data/gfx/intro/intro2.png differ diff --git a/data/gfx/intro/intro3.png b/data/gfx/intro/intro3.png new file mode 100644 index 0000000..ad6a6b8 Binary files /dev/null and b/data/gfx/intro/intro3.png differ diff --git a/data/gfx/intro/intro4.png b/data/gfx/intro/intro4.png new file mode 100644 index 0000000..4f8bd03 Binary files /dev/null and b/data/gfx/intro/intro4.png differ diff --git a/data/gfx/intro/intro5.png b/data/gfx/intro/intro5.png new file mode 100644 index 0000000..abfee5e Binary files /dev/null and b/data/gfx/intro/intro5.png differ diff --git a/data/gfx/intro/intro6.png b/data/gfx/intro/intro6.png new file mode 100644 index 0000000..1717646 Binary files /dev/null and b/data/gfx/intro/intro6.png differ diff --git a/source/director.cpp b/source/director.cpp index d76c862..5e78936 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -474,7 +474,12 @@ void Director::setFileList() } { // Intro + Asset::get()->add(prefix + "/data/gfx/intro/intro1.png", AssetType::BITMAP); Asset::get()->add(prefix + "/data/gfx/intro/intro2.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/gfx/intro/intro3.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/gfx/intro/intro4.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/gfx/intro/intro5.png", AssetType::BITMAP); + Asset::get()->add(prefix + "/data/gfx/intro/intro6.png", AssetType::BITMAP); } { // Logo diff --git a/source/intro.cpp b/source/intro.cpp index 39036af..558f580 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -17,87 +17,89 @@ #include "utils.h" // Para Zone, BLOCK, Color, bg_color #include "writer.h" // Para Writer #include "mouse.h" +#include // Constructor Intro::Intro() - : texture_(Resource::get()->getTexture("intro2.png")), - text_(Resource::get()->getText("04b_25_metal")) { - // Inicializa variables section::name = section::Name::INTRO; section::options = section::Options::NONE; - const int BITMAP_WIDTH = texture_->getWidth() / 2; - const int BITMAP_HEIGHT = texture_->getHeight() / 3; + const std::array BITMAP_LIST = { + "intro1.png", + "intro2.png", + "intro3.png", + "intro4.png", + "intro5.png", + "intro6.png"}; + + auto texture = Resource::get()->getTexture(BITMAP_LIST.front()); + const int BITMAP_WIDTH = texture->getWidth(); + const int BITMAP_HEIGHT = texture->getHeight(); // Inicializa los bitmaps de la intro constexpr int TOTAL_BITMAPS = 6; for (int i = 0; i < TOTAL_BITMAPS; ++i) { - auto ss = std::make_unique(texture_); + auto ss = std::make_unique(Resource::get()->getTexture(BITMAP_LIST.at(i))); ss->setWidth(BITMAP_WIDTH); ss->setHeight(BITMAP_HEIGHT); + ss->setSpriteClip(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT); ss->setFinishedCounter(20); ss->setDestX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); ss->setDestY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); bitmaps_.push_back(std::move(ss)); } - bitmaps_[0]->setPosX(-BITMAP_WIDTH); - bitmaps_[0]->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); - bitmaps_[0]->setVelX(0.0f); - bitmaps_[0]->setVelY(0.0f); - bitmaps_[0]->setAccelX(0.6f); - bitmaps_[0]->setAccelY(0.0f); - bitmaps_[0]->setSpriteClip(0, 0, BITMAP_WIDTH, BITMAP_HEIGHT); + bitmaps_.at(0)->setPosX(-BITMAP_WIDTH); + bitmaps_.at(0)->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); + bitmaps_.at(0)->setVelX(0.0f); + bitmaps_.at(0)->setVelY(0.0f); + bitmaps_.at(0)->setAccelX(0.6f); + bitmaps_.at(0)->setAccelY(0.0f); - bitmaps_[1]->setPosX(param.game.width); - bitmaps_[1]->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); - bitmaps_[1]->setVelX(-1.0f); - bitmaps_[1]->setVelY(0.0f); - bitmaps_[1]->setAccelX(-0.3f); - bitmaps_[1]->setAccelY(0.0f); - bitmaps_[1]->setSpriteClip(BITMAP_WIDTH, 0, BITMAP_WIDTH, BITMAP_HEIGHT); + bitmaps_.at(1)->setPosX(param.game.width); + bitmaps_.at(1)->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); + bitmaps_.at(1)->setVelX(-1.0f); + bitmaps_.at(1)->setVelY(0.0f); + bitmaps_.at(1)->setAccelX(-0.3f); + bitmaps_.at(1)->setAccelY(0.0f); - bitmaps_[2]->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); - bitmaps_[2]->setPosY(-BITMAP_HEIGHT); - bitmaps_[2]->setVelX(0.0f); - bitmaps_[2]->setVelY(3.0f); - bitmaps_[2]->setAccelX(0.1f); - bitmaps_[2]->setAccelY(0.3f); - bitmaps_[2]->setSpriteClip(0, BITMAP_HEIGHT, BITMAP_WIDTH, BITMAP_HEIGHT); - bitmaps_[2]->setFinishedCounter(250); + bitmaps_.at(2)->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); + bitmaps_.at(2)->setPosY(-BITMAP_HEIGHT); + bitmaps_.at(2)->setVelX(0.0f); + bitmaps_.at(2)->setVelY(3.0f); + bitmaps_.at(2)->setAccelX(0.1f); + bitmaps_.at(2)->setAccelY(0.3f); + bitmaps_.at(2)->setFinishedCounter(250); - bitmaps_[3]->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); - bitmaps_[3]->setPosY(param.game.height); - bitmaps_[3]->setVelX(0.0f); - bitmaps_[3]->setVelY(-0.7f); - bitmaps_[3]->setAccelX(0.0f); - bitmaps_[3]->setAccelY(0.0f); - bitmaps_[3]->setSpriteClip(BITMAP_WIDTH, BITMAP_HEIGHT, BITMAP_WIDTH, BITMAP_HEIGHT); + bitmaps_.at(3)->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); + bitmaps_.at(3)->setPosY(param.game.height); + bitmaps_.at(3)->setVelX(0.0f); + bitmaps_.at(3)->setVelY(-0.7f); + bitmaps_.at(3)->setAccelX(0.0f); + bitmaps_.at(3)->setAccelY(0.0f); - bitmaps_[4]->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); - bitmaps_[4]->setPosY(-BITMAP_HEIGHT); - bitmaps_[4]->setVelX(0.0f); - bitmaps_[4]->setVelY(3.0f); - bitmaps_[4]->setAccelX(0.1f); - bitmaps_[4]->setAccelY(0.3f); - bitmaps_[4]->setSpriteClip(0, BITMAP_HEIGHT * 2, BITMAP_WIDTH, BITMAP_HEIGHT); + bitmaps_.at(4)->setPosX(param.game.game_area.center_x - (BITMAP_WIDTH / 2)); + bitmaps_.at(4)->setPosY(-BITMAP_HEIGHT); + bitmaps_.at(4)->setVelX(0.0f); + bitmaps_.at(4)->setVelY(3.0f); + bitmaps_.at(4)->setAccelX(0.1f); + bitmaps_.at(4)->setAccelY(0.3f); - bitmaps_[5]->setPosX(param.game.width); - bitmaps_[5]->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); - bitmaps_[5]->setVelX(-0.7f); - bitmaps_[5]->setVelY(0.0f); - bitmaps_[5]->setAccelX(0.0f); - bitmaps_[5]->setAccelY(0.0f); - bitmaps_[5]->setSpriteClip(BITMAP_WIDTH, BITMAP_HEIGHT * 2, BITMAP_WIDTH, BITMAP_HEIGHT); + bitmaps_.at(5)->setPosX(param.game.width); + bitmaps_.at(5)->setPosY(param.game.game_area.first_quarter_y - (BITMAP_HEIGHT / 4)); + bitmaps_.at(5)->setVelX(-0.7f); + bitmaps_.at(5)->setVelY(0.0f); + bitmaps_.at(5)->setAccelX(0.0f); + bitmaps_.at(5)->setAccelY(0.0f); // Inicializa los textos de la intro - constexpr int totalTexts = 9; - for (int i = 0; i < totalTexts; ++i) + constexpr int TOTAL_TEXTS = 9; + for (int i = 0; i < TOTAL_TEXTS; ++i) { - auto w = std::make_unique(text_); + auto w = std::make_unique(Resource::get()->getText("04b_25_metal")); w->setPosX(BLOCK * 0); w->setPosY(param.game.height - (BLOCK * 6)); w->setKerning(-2); @@ -107,40 +109,40 @@ Intro::Intro() } // Un dia qualsevol de l'any 2000 - texts_[0]->setCaption(lang::getText(27)); - texts_[0]->setSpeed(8); + texts_.at(0)->setCaption(lang::getText(27)); + texts_.at(0)->setSpeed(8); // Tot esta tranquil a la UPV - texts_[1]->setCaption(lang::getText(28)); - texts_[1]->setSpeed(8); + texts_.at(1)->setCaption(lang::getText(28)); + texts_.at(1)->setSpeed(8); // Fins que un desaprensiu... - texts_[2]->setCaption(lang::getText(29)); - texts_[2]->setSpeed(12); + texts_.at(2)->setCaption(lang::getText(29)); + texts_.at(2)->setSpeed(12); // HEY! ME ANE A FERME UN CORTAET... - texts_[3]->setCaption(lang::getText(30)); - texts_[3]->setSpeed(8); + texts_.at(3)->setCaption(lang::getText(30)); + texts_.at(3)->setSpeed(8); // UAAAAAAAAAAAAA!!! - texts_[4]->setCaption(lang::getText(31)); - texts_[4]->setSpeed(1); + texts_.at(4)->setCaption(lang::getText(31)); + texts_.at(4)->setSpeed(1); // Espera un moment... - texts_[5]->setCaption(lang::getText(32)); - texts_[5]->setSpeed(16); + texts_.at(5)->setCaption(lang::getText(32)); + texts_.at(5)->setSpeed(16); // Si resulta que no tinc solt! - texts_[6]->setCaption(lang::getText(33)); - texts_[6]->setSpeed(2); + texts_.at(6)->setCaption(lang::getText(33)); + texts_.at(6)->setSpeed(2); // MERDA DE MAQUINA! - texts_[7]->setCaption(lang::getText(34)); - texts_[7]->setSpeed(3); + texts_.at(7)->setCaption(lang::getText(34)); + texts_.at(7)->setSpeed(3); // Blop... blop... blop... - texts_[8]->setCaption(lang::getText(35)); - texts_[8]->setSpeed(16); + texts_.at(8)->setCaption(lang::getText(35)); + texts_.at(8)->setSpeed(16); for (auto &text : texts_) { @@ -148,13 +150,6 @@ Intro::Intro() } } -// Recarga todas las texturas -void Intro::reloadTextures() -{ - texture_->reLoad(); - text_->reLoadTexture(); -} - // Comprueba los eventos void Intro::checkEvents() { @@ -176,7 +171,7 @@ void Intro::checkEvents() { if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { - reloadTextures(); + // reloadTextures(); } break; } diff --git a/source/intro.h b/source/intro.h index 670a04f..8454381 100644 --- a/source/intro.h +++ b/source/intro.h @@ -18,9 +18,6 @@ class Intro { private: // Objetos - std::shared_ptr texture_; // Textura con los graficos - std::shared_ptr text_; // Textos de la intro - std::vector> bitmaps_; // Vector con los sprites inteligentes para los dibujos de la intro std::vector> texts_; // Textos de la intro @@ -43,9 +40,6 @@ private: // Actualiza las escenas de la intro void updateScenes(); - // Recarga todas las texturas - void reloadTextures(); - public: // Constructor Intro(); diff --git a/source/moving_sprite.cpp b/source/moving_sprite.cpp index 91d029b..e675326 100644 --- a/source/moving_sprite.cpp +++ b/source/moving_sprite.cpp @@ -28,7 +28,7 @@ MovingSprite::MovingSprite(std::shared_ptr texture) rotate_(Rotate()), zoom_w_(1.0f), zoom_h_(1.0f), - flip_(SDL_FLIP_NONE) { Sprite::clear(); } + flip_(SDL_FLIP_NONE) {Sprite::clear(); } // Reinicia todas las variables void MovingSprite::clear() diff --git a/source/smart_sprite.cpp b/source/smart_sprite.cpp index bf2a790..281d4f7 100644 --- a/source/smart_sprite.cpp +++ b/source/smart_sprite.cpp @@ -2,10 +2,6 @@ #include "moving_sprite.h" // Para MovingSprite class Texture; // lines 2-2 -// Constructor -SmartSprite::SmartSprite(std::shared_ptr texture) - : AnimatedSprite(texture) {} - // Actualiza la posición y comprueba si ha llegado a su destino void SmartSprite::update() { diff --git a/source/smart_sprite.h b/source/smart_sprite.h index 321239d..9dd43f0 100644 --- a/source/smart_sprite.h +++ b/source/smart_sprite.h @@ -24,7 +24,8 @@ private: public: // Constructor - explicit SmartSprite(std::shared_ptr texture); + explicit SmartSprite(std::shared_ptr texture) + : AnimatedSprite(texture) {} // Destructor ~SmartSprite() = default; @@ -40,7 +41,7 @@ public: int getDestY() const { return dest_y_; } bool isOnDestination() const { return on_destination_; } bool hasFinished() const { return finished_; } - + // Setters void setFinishedCounter(int value) { finished_counter_ = value; } void setDestX(int x) { dest_x_ = x; }