corregides cridades a SDL3 i migrat casi tot de int a float. Falta jail_shader

This commit is contained in:
2025-10-15 12:16:50 +02:00
parent 7c102e42cc
commit e4a08d2ec7
52 changed files with 879 additions and 823 deletions

View File

@@ -174,7 +174,7 @@ void Credits::fillTexture() {
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 8, 256, 192};
SDL_FRect rect = {0, 8, 256, 192};
cover_surface_->fillRect(&rect, color);
}
@@ -236,7 +236,7 @@ void Credits::render() {
// Dibuja la textura que cubre el texto
const int offset = std::min(counter_ / 8, 192 / 2);
SDL_Rect srcRect = {0, 0, 256, 192 - (offset * 2)};
SDL_FRect srcRect = {0, 0, 256, 192 - (offset * 2)};
cover_surface_->render(0, offset * 2, &srcRect);
// Dibuja el sprite con el brillo

View File

@@ -190,7 +190,7 @@ void Ending::iniTexts() {
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 8, WIDTH, HEIGHT};
SDL_FRect rect = {0, 8, WIDTH, HEIGHT};
surface->fillRect(&rect, color);
// Crea el sprite
@@ -256,7 +256,7 @@ void Ending::iniPics() {
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 8, WIDTH, HEIGHT};
SDL_FRect rect = {0, 8, WIDTH, HEIGHT};
surface->fillRect(&rect, color);
// Crea el sprite
@@ -453,7 +453,7 @@ void Ending::fillCoverTexture() {
}
// El resto se rellena de color sólido
SDL_Rect rect = {0, 0, 256, options.game.height};
SDL_FRect rect = {0, 0, 256, options.game.height};
surface->fillRect(&rect, color);
Screen::get()->setRendererSurface(previuos_renderer);
@@ -464,8 +464,8 @@ void Ending::renderCoverTexture() {
if (cover_counter_ > 0) {
// Dibuja la textura que cubre el texto
const int OFFSET = std::min(cover_counter_, 100);
SDL_Rect srcRect = {0, 200 - (cover_counter_ * 2), 256, OFFSET * 2};
SDL_Rect dstRect = {0, 0, 256, OFFSET * 2};
SDL_FRect srcRect = {0, 200 - (cover_counter_ * 2), 256, OFFSET * 2};
SDL_FRect dstRect = {0, 0, 256, OFFSET * 2};
cover_surface_->render(&srcRect, &dstRect);
}
}

View File

@@ -343,20 +343,20 @@ void Ending2::renderTexts() {
// Coloca los sprites en su sito
void Ending2::placeSprites() {
for (int i = 0; i < static_cast<int>(sprites_.size()); ++i) {
const int X = i % 2 == 0 ? FIRST_COL_ : SECOND_COL_;
const int Y = (i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT_ + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE_) + options.game.height + 40;
const int W = sprites_.at(i)->getWidth();
const int H = sprites_.at(i)->getHeight();
const int DX = -(W / 2);
const int DY = sprite_max_height_ - H;
const float X = i % 2 == 0 ? FIRST_COL_ : SECOND_COL_;
const float Y = (i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT_ + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE_) + options.game.height + 40;
const float W = sprites_.at(i)->getWidth();
const float H = sprites_.at(i)->getHeight();
const float DX = -(W / 2);
const float DY = sprite_max_height_ - H;
sprites_.at(i)->setPos({X + DX, Y + DY, W, H});
sprites_.at(i)->setVelY(SPRITE_DESP_SPEED_);
}
// Recoloca el sprite del jugador, que es el último de la lista
const int X = (options.game.width - sprites_.back()->getWidth()) / 2;
const int Y = sprites_.back()->getPosY() + sprite_max_height_ * 2;
const float X = (options.game.width - sprites_.back()->getWidth()) / 2;
const float Y = sprites_.back()->getPosY() + sprite_max_height_ * 2;
sprites_.back()->setPos(X, Y);
sprites_.back()->setCurrentAnimation("walk");
}
@@ -364,7 +364,7 @@ void Ending2::placeSprites() {
// Crea los sprites con las texturas con los textos
void Ending2::createSpriteTexts() {
// Crea los sprites de texto a partir de la lista
for (int i = 0; i < static_cast<int>(sprite_list_.size()); ++i) {
for (size_t i = 0; i < sprite_list_.size(); ++i) {
auto text = Resource::get()->getText("smb2");
// Procesa y ajusta el texto del sprite actual
@@ -375,16 +375,16 @@ void Ending2::createSpriteTexts() {
}
// Calcula las dimensiones del texto
const int W = text->lenght(txt, 1);
const int H = text->getCharacterSize();
const float W = text->lenght(txt, 1);
const float H = text->getCharacterSize();
// Determina la columna y la posición X del texto
const int X = (i == static_cast<int>(sprite_list_.size()) - 1)
const float X = (i == sprite_list_.size() - 1)
? (GAMECANVAS_CENTER_X - (W / 2))
: ((i % 2 == 0 ? FIRST_COL_ : SECOND_COL_) - (W / 2));
// Calcula la posición Y del texto en base a la posición y altura del sprite
const int Y = sprites_.at(i)->getPosY() + sprites_.at(i)->getHeight() + DIST_SPRITE_TEXT_;
const float Y = sprites_.at(i)->getPosY() + sprites_.at(i)->getHeight() + DIST_SPRITE_TEXT_;
// Crea la surface
auto surface = std::make_shared<Surface>(W, H);
@@ -393,7 +393,7 @@ void Ending2::createSpriteTexts() {
text->write(0, 0, txt);
// Crea el sprite
SDL_Rect pos = {X, Y, W, H};
SDL_FRect pos = {X, Y, W, H};
sprite_texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer);
@@ -409,22 +409,22 @@ void Ending2::createTexts() {
auto text = Resource::get()->getText("smb2");
// Crea los sprites de texto a partir de la lista
for (int i = 0; i < (int)list.size(); ++i) {
for (size_t i = 0; i < list.size(); ++i) {
// Calcula constantes
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
const int y = options.game.height + (text->getCharacterSize() * (i * 2));
const float W = text->lenght(list[i], 1);
const float H = text->getCharacterSize();
const float X = GAMECANVAS_CENTER_X;
const float DX = -(W / 2);
const float Y = options.game.height + (text->getCharacterSize() * (i * 2));
// Crea la surface
auto surface = std::make_shared<Surface>(w, h);
auto surface = std::make_shared<Surface>(W, H);
auto previuos_renderer = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(surface);
text->write(0, 0, list[i]);
// Crea el sprite
SDL_Rect pos = {x + dx, y, w, h};
SDL_FRect pos = {X + DX, Y, W, H};
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer);
@@ -438,22 +438,22 @@ void Ending2::createTexts() {
list.push_back("FOR PLAYING!");
// Crea los sprites de texto a partir de la lista
for (int i = 0; i < (int)list.size(); ++i) {
for (size_t i = 0; i < list.size(); ++i) {
// Calcula constantes
const int w = text->lenght(list[i], 1);
const int h = text->getCharacterSize();
const int x = GAMECANVAS_CENTER_X;
const int dx = -(w / 2);
const int y = START + (text->getCharacterSize() * (i * 2));
const float W = text->lenght(list[i], 1);
const float H = text->getCharacterSize();
const float X = GAMECANVAS_CENTER_X;
const float DX = -(W / 2);
const float Y = START + (text->getCharacterSize() * (i * 2));
// Crea la surface
auto surface = std::make_shared<Surface>(w, h);
auto surface = std::make_shared<Surface>(W, H);
auto previuos_renderer = Screen::get()->getRendererSurface();
Screen::get()->setRendererSurface(surface);
text->write(0, 0, list[i]);
// Crea el sprite
SDL_Rect pos = {x + dx, y, w, h};
SDL_FRect pos = {X + DX, Y, W, H};
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
Screen::get()->setRendererSurface(previuos_renderer);

View File

@@ -70,8 +70,8 @@ class Ending2 {
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
std::vector<std::string> sprite_list_; // Lista con todos los sprites a dibujar
std::vector<Uint8> colors_; // Vector con los colores para el fade
int sprite_max_width_ = 0; // El valor de ancho del sprite mas ancho
int sprite_max_height_ = 0; // El valor de alto del sprite mas alto
float sprite_max_width_ = 0; // El valor de ancho del sprite mas ancho
float sprite_max_height_ = 0; // El valor de alto del sprite mas alto
State state_; // Controla el estado de la clase
// Actualiza el objeto

View File

@@ -193,7 +193,7 @@ void Game::renderDebugInfo() {
auto surface = Screen::get()->getRendererSurface();
// Borra el marcador
SDL_Rect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
SDL_FRect rect = {0, 18 * BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_HEIGHT - PLAY_AREA_HEIGHT};
surface->fillRect(&rect, static_cast<Uint8>(PaletteColor::BLACK));
// Pinta la rejilla

View File

@@ -63,7 +63,7 @@ class Game {
bool black_screen_ = false; // Indica si la pantalla está en negro. Se utiliza para la muerte del jugador
int black_screen_counter_ = 0; // Contador para temporizar la pantalla en negro
int total_items_; // Cantidad total de items que hay en el mapeado del juego
SDL_Rect room_name_rect_; // Rectangulo donde pintar la textura con el nombre de la habitación
SDL_FRect room_name_rect_; // Rectangulo donde pintar la textura con el nombre de la habitación
// Actualiza el juego, las variables, comprueba la entrada, etc.
void update();

View File

@@ -16,13 +16,13 @@ class LoadingScreen {
std::shared_ptr<Surface> screen_surface_; // Surface para dibujar la pantalla de carga
// Variables
int pre_counter_ = 0; // Contador previo para realizar una pausa inicial
int counter_ = 0; // Contador
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
int load_counter_ = 0; // Contador para controlar las cargas
bool loading_first_part_ = true; // Para saber en que parte de la carga se encuentra
int line_index_[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
SDL_Rect load_rect_ = {0, 0, 52, 1}; // Rectangulo para dibujar la pantalla de carga
int pre_counter_ = 0; // Contador previo para realizar una pausa inicial
int counter_ = 0; // Contador
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
int load_counter_ = 0; // Contador para controlar las cargas
bool loading_first_part_ = true; // Para saber en que parte de la carga se encuentra
int line_index_[192]; // El orden en el que se procesan las 192 lineas de la pantalla de carga
SDL_FRect load_rect_ = {0, 0, 52, 1}; // Rectangulo para dibujar la pantalla de carga
// Actualiza las variables
void update();

View File

@@ -64,9 +64,9 @@ void Title::checkEvents() {
globalEvents::check(event);
// Solo se comprueban estas teclas si no está activo el menu de logros
if (event.type == SDL_KEYDOWN) {
if (event.type == SDL_EVENT_KEY_DOWN) {
if (!show_cheevos_) {
switch (event.key.keysym.scancode) {
switch (event.key.key) {
case SDL_SCANCODE_1:
options.section.section = Section::GAME;
options.section.subsection = Subsection::NONE;
@@ -242,8 +242,8 @@ void Title::moveCheevosList(int direction) {
cheevos_surface_view_.y = direction == 0 ? cheevos_surface_view_.y - SPEED : cheevos_surface_view_.y + SPEED;
// Ajusta los limites
const int BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0, BOTTOM);
const float BOTTOM = cheevos_surface_->getHeight() - cheevos_surface_view_.h;
cheevos_surface_view_.y = std::clamp(cheevos_surface_view_.y, 0.0F, BOTTOM);
cheevos_sprite_->setClip(cheevos_surface_view_);
}

View File

@@ -38,7 +38,7 @@ class Title {
std::vector<TitleLetter> letters_; // Vector con las letras de la marquesina
int marquee_speed_ = 2; // Velocidad de desplazamiento de la marquesina
bool show_cheevos_ = false; // Indica si se muestra por pantalla el listado de logros
SDL_Rect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
SDL_FRect cheevos_surface_view_; // Zona visible de la surface con el listado de logros
TitleState state_; // Estado en el que se encuentra el bucle principal
// Actualiza las variables