migrant a SDL3

This commit is contained in:
2025-03-25 14:13:58 +01:00
parent 9cc41aaf53
commit f1b0303474
71 changed files with 303 additions and 360 deletions

View File

@@ -1,9 +1,9 @@
// IWYU pragma: no_include <bits/std_abs.h>
#include "credits.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para max, min, clamp
#include <cstdlib> // Para abs
#include <stdexcept> // Para runtime_error
@@ -123,7 +123,7 @@ void Credits::render()
Screen::get()->start();
// Copia la textura con la zona de juego a la pantalla
SDL_RenderCopy(Screen::get()->getRenderer(), canvas_, nullptr, nullptr);
SDL_RenderTexture(Screen::get()->getRenderer(), canvas_, nullptr, nullptr);
// Vuelca el contenido del renderizador en pantalla
Screen::get()->render();
@@ -262,10 +262,10 @@ void Credits::fillCanvas()
}
// Dibuja los titulos de credito
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &credits_rect_src_, &credits_rect_dst_);
SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &credits_rect_src_, &credits_rect_dst_);
// Dibuja el mini_logo
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
// Dibuja los rectangulos negros
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0, 0, 0, 0xFF);
@@ -276,12 +276,12 @@ void Credits::fillCanvas()
// Dibuja el rectangulo rojo
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0, 0, 0xFF);
SDL_RenderDrawRect(Screen::get()->getRenderer(), &red_rect);
SDL_RenderRect(Screen::get()->getRenderer(), &red_rect);
// Si el mini_logo está en su destino, lo dibuja encima de lo anterior
if (mini_logo_on_position_)
{
SDL_RenderCopy(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
SDL_RenderTexture(Screen::get()->getRenderer(), text_texture_, &mini_logo_rect_src_, &mini_logo_rect_dst_);
}
// Dibuja el fade sobre el resto de elementos
@@ -408,11 +408,11 @@ void Credits::updateBlackRects()
if (counter_ % 4 == 0)
{
// Incrementa la altura del rectangulo superior
top_black_rect_.h = std::min(top_black_rect_.h + 1, param.game.game_area.center_y - 1);
top_black_rect_.h = std::min(static_cast<int>(top_black_rect_.h) + 1, param.game.game_area.center_y - 1);
// Incrementa la altura y modifica la posición del rectangulo inferior
++bottom_black_rect_.h;
bottom_black_rect_.y = std::max(bottom_black_rect_.y - 1, param.game.game_area.center_y + 1);
bottom_black_rect_.y = std::max(static_cast<int>(bottom_black_rect_.y) - 1, param.game.game_area.center_y + 1);
--current_step;
setVolume(static_cast<int>(initial_volume_ * current_step / steps_));
@@ -426,11 +426,11 @@ void Credits::updateBlackRects()
constexpr int SPEED = 2;
// Si los rectangulos izquierdo y derecho no han llegado al centro
// Incrementa la anchura del rectangulo situado a la izquierda
left_black_rect_.w = std::min(left_black_rect_.w + SPEED, param.game.game_area.center_x);
left_black_rect_.w = std::min(static_cast<int>(left_black_rect_.w) + SPEED, param.game.game_area.center_x);
// Incrementa la anchura y modifica la posición del rectangulo situado a la derecha
right_black_rect_.w += SPEED;
right_black_rect_.x = std::max(right_black_rect_.x - SPEED, param.game.game_area.center_x);
right_black_rect_.x = std::max(static_cast<int>(right_black_rect_.x) - SPEED, param.game.game_area.center_x);
--current_step;
setVolume(static_cast<int>(initial_volume_ * current_step / steps_));