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,6 +1,6 @@
#include "fade.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // Para rand
#include <algorithm> // Para min, max
#include "param.h" // Para Param, param, ParamGame, ParamFade
@@ -56,7 +56,7 @@ void Fade::render()
{
if (state_ != FadeState::NOT_ENABLED)
{
SDL_RenderCopy(renderer_, backbuffer_, nullptr, nullptr);
SDL_RenderTexture(renderer_, backbuffer_, nullptr, nullptr);
}
}
@@ -191,7 +191,7 @@ void Fade::update()
for (size_t i = 0; i < square_.size(); ++i)
{
// A partir del segundo rectangulo se pinta en función del anterior
square_.at(i).h = i == 0 ? h : std::max(square_.at(i - 1).h - 2, 0);
square_.at(i).h = i == 0 ? h : std::max(static_cast<int>(square_.at(i - 1).h) - 2, 0);
}
int completed = 0;
@@ -259,15 +259,15 @@ void Fade::activate()
case FadeType::CENTER:
{
rect1_ = {0, 0, param.game.width, 0};
rect2_ = {0, 0, param.game.width, 0};
rect1_ = {0, 0, static_cast<float>(param.game.width), 0};
rect2_ = {0, 0, static_cast<float>(param.game.width), 0};
a_ = 64;
break;
}
case FadeType::RANDOM_SQUARE:
{
rect1_ = {0, 0, param.game.width / num_squares_width_, param.game.height / num_squares_height_};
rect1_ = {0, 0, static_cast<float>(param.game.width / num_squares_width_), static_cast<float>(param.game.height / num_squares_height_)};
square_.clear();
// Añade los cuadrados al vector
@@ -283,7 +283,7 @@ void Fade::activate()
while (num > 1)
{
auto num_arreu = rand() % num;
SDL_Rect temp = square_[num_arreu];
SDL_FRect temp = square_[num_arreu];
square_[num_arreu] = square_[num - 1];
square_[num - 1] = temp;
num--;
@@ -310,10 +310,10 @@ void Fade::activate()
// Añade los cuadrados al vector
square_.clear();
rect1_ = {0, 0, param.game.width, 0};
const int max = param.game.height / param.fade.venetian_size;
rect1_ = {0, 0, static_cast<float>(param.game.width), 0};
const int MAX = param.game.height / param.fade.venetian_size;
for (int i = 0; i < max; ++i)
for (int i = 0; i < MAX; ++i)
{
rect1_.y = i * param.fade.venetian_size;
square_.push_back(rect1_);