Codi preparat per als dibuixets nous per a la intro

This commit is contained in:
2025-03-09 18:30:14 +01:00
parent 72cb39da78
commit e0c10f83d6
13 changed files with 82 additions and 91 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

BIN
data/gfx/intro/intro1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
data/gfx/intro/intro3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
data/gfx/intro/intro4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
data/gfx/intro/intro5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
data/gfx/intro/intro6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -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

View File

@@ -17,87 +17,89 @@
#include "utils.h" // Para Zone, BLOCK, Color, bg_color
#include "writer.h" // Para Writer
#include "mouse.h"
#include <array>
// 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<std::string, 6> 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<SmartSprite>(texture_);
auto ss = std::make_unique<SmartSprite>(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<Writer>(text_);
auto w = std::make_unique<Writer>(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;
}

View File

@@ -18,9 +18,6 @@ class Intro
{
private:
// Objetos
std::shared_ptr<Texture> texture_; // Textura con los graficos
std::shared_ptr<Text> text_; // Textos de la intro
std::vector<std::unique_ptr<SmartSprite>> bitmaps_; // Vector con los sprites inteligentes para los dibujos de la intro
std::vector<std::unique_ptr<Writer>> 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();

View File

@@ -28,7 +28,7 @@ MovingSprite::MovingSprite(std::shared_ptr<Texture> 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()

View File

@@ -2,10 +2,6 @@
#include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 2-2
// Constructor
SmartSprite::SmartSprite(std::shared_ptr<Texture> texture)
: AnimatedSprite(texture) {}
// Actualiza la posición y comprueba si ha llegado a su destino
void SmartSprite::update()
{

View File

@@ -24,7 +24,8 @@ private:
public:
// Constructor
explicit SmartSprite(std::shared_ptr<Texture> texture);
explicit SmartSprite(std::shared_ptr<Texture> texture)
: AnimatedSprite(texture) {}
// Destructor
~SmartSprite() = default;