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,7 +1,7 @@
# CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(coffee_crisis_arcade_edition VERSION 0.01)
project(coffee_crisis_arcade_edition VERSION 2.00)
# Establece las políticas
cmake_policy(SET CMP0072 NEW)
@@ -31,18 +31,18 @@ if(NOT SOURCES)
message(FATAL_ERROR "No se encontraron archivos fuente en ${DIR_SOURCES}. Verifica que el directorio existe y contiene archivos .cpp.")
endif()
# Configuración de SDL2
find_package(SDL2 REQUIRED)
if(SDL2_FOUND)
message(STATUS "SDL2 encontrado: ${SDL2_INCLUDE_DIRS}")
include_directories(${SDL2_INCLUDE_DIRS})
link_directories(${SDL2_LIBDIR})
# Configuración de SDL3
find_package(SDL3 REQUIRED)
if(SDL3_FOUND)
message(STATUS "SDL3 encontrado: ${SDL3_INCLUDE_DIRS}")
include_directories(${SDL3_INCLUDE_DIRS})
link_directories(${SDL3_LIBDIR})
else()
message(FATAL_ERROR "SDL2 no encontrado")
message(FATAL_ERROR "SDL3 no encontrado")
endif()
# Incluye rutas de SDL2 obtenidas con pkg-config
include_directories(/usr/local/include /usr/local/include/SDL2)
# Incluye rutas de SDL3 obtenidas con pkg-config
include_directories(/usr/local/include /usr/local/include/SDL3)
link_directories(/usr/local/lib)
# Definir las bibliotecas comunes

View File

@@ -29,16 +29,15 @@ ifeq ($(OS),Windows_NT)
SOURCES := source/*.cpp
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -static-libstdc++ -Wl,-subsystem,windows
CXXFLAGS_DEBUG := -std=c++20 -Wall -g
LDFLAGS := -lmingw32 -lws2_32 -lSDL2main -lSDL2 -lopengl32
LDFLAGS := -lmingw32 -lws2_32 -lSDL3 -lopengl32
RM := del /Q
MKDIR := mkdir
else
FixPath = $1
SOURCES := $(shell find $(DIR_SOURCES) -name '*.cpp')
SOURCES := source/*.cpp
CXXFLAGS := -std=c++20 -Wall -Os -ffunction-sections -fdata-sections
CXXFLAGS_DEBUG := -std=c++20 -Wall -g
LDFLAGS := -lSDL2
LDFLAGS := -lSDL3
RMFILE := rm -f
RMDIR := rm -rdf
MKDIR := mkdir -p

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,6 +1,6 @@
#include "background.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <algorithm> // Para clamp, max
#include <cmath>
#include "moving_sprite.h" // Para MovingSprite
@@ -22,7 +22,7 @@ Background::Background()
sun_texture_(Resource::get()->getTexture("game_sun.png")),
moon_texture_(Resource::get()->getTexture("game_moon.png")),
rect_({0, 0, gradients_texture_->getWidth() / 2, gradients_texture_->getHeight() / 2}),
rect_(SDL_FRect{0, 0, static_cast<float>(gradients_texture_->getWidth() / 2), static_cast<float>(gradients_texture_->getHeight() / 2)}),
src_rect_({0, 0, 320, 240}),
dst_rect_({0, 0, 320, 240}),
base_(rect_.h),
@@ -42,25 +42,25 @@ Background::Background()
gradient_rect_[2] = {0, rect_.h, rect_.w, rect_.h};
gradient_rect_[3] = {rect_.w, rect_.h, rect_.w, rect_.h};
const int top_clouds_texture_height = top_clouds_texture_->getHeight() / 4;
const int bottom_clouds_texture_height = bottom_clouds_texture_->getHeight() / 4;
const float TOP_CLOUDS_TEXTURE_HEIGHT = top_clouds_texture_->getHeight() / 4;
const float BOTTOM_CLOUDS_TEXTURE_HEIGHT = bottom_clouds_texture_->getHeight() / 4;
for (int i = 0; i < 4; ++i)
{
top_clouds_rect_[i] = {0, i * top_clouds_texture_height, top_clouds_texture_->getWidth(), top_clouds_texture_height};
bottom_clouds_rect_[i] = {0, i * bottom_clouds_texture_height, bottom_clouds_texture_->getWidth(), bottom_clouds_texture_height};
top_clouds_rect_[i] = {0, i * TOP_CLOUDS_TEXTURE_HEIGHT, top_clouds_texture_->getWidth(), TOP_CLOUDS_TEXTURE_HEIGHT};
bottom_clouds_rect_[i] = {0, i * BOTTOM_CLOUDS_TEXTURE_HEIGHT, bottom_clouds_texture_->getWidth(), BOTTOM_CLOUDS_TEXTURE_HEIGHT};
}
}
// Crea los sprites
{
const int top_clouds_y = base_ - 165;
const int bottom_clouds_y = base_ - 101;
const float TOP_CLOUDS_Y = base_ - 165;
const float BOTTOM_CLOUDS_Y = base_ - 101;
top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){0, top_clouds_y, rect_.w, top_clouds_texture_->getHeight()});
top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){rect_.w, top_clouds_y, rect_.w, top_clouds_texture_->getHeight()});
top_clouds_sprite_a_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){0, TOP_CLOUDS_Y, rect_.w, top_clouds_texture_->getHeight()});
top_clouds_sprite_b_ = std::make_unique<MovingSprite>(top_clouds_texture_, (SDL_Rect){rect_.w, TOP_CLOUDS_Y, rect_.w, top_clouds_texture_->getHeight()});
bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){0, bottom_clouds_y, rect_.w, bottom_clouds_texture_->getHeight()});
bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){rect_.w, bottom_clouds_y, rect_.w, bottom_clouds_texture_->getHeight()});
bottom_clouds_sprite_a_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){0, BOTTOM_CLOUDS_Y, rect_.w, bottom_clouds_texture_->getHeight()});
bottom_clouds_sprite_b_ = std::make_unique<MovingSprite>(bottom_clouds_texture_, (SDL_Rect){rect_.w, BOTTOM_CLOUDS_Y, rect_.w, bottom_clouds_texture_->getHeight()});
buildings_sprite_ = std::make_unique<Sprite>(buildings_texture_);
gradient_sprite_ = std::make_unique<Sprite>(gradients_texture_, 0, 0, rect_.w, rect_.h);
@@ -220,10 +220,10 @@ void Background::fillCanvas()
void Background::render()
{
// Fondo
SDL_RenderCopy(renderer_, canvas_, &src_rect_, &dst_rect_);
SDL_RenderTexture(renderer_, canvas_, &src_rect_, &dst_rect_);
// Atenuación
SDL_RenderCopy(renderer_, color_texture_, &src_rect_, &dst_rect_);
SDL_RenderTexture(renderer_, color_texture_, &src_rect_, &dst_rect_);
}
// Ajusta el valor de la variable
@@ -245,7 +245,7 @@ void Background::setTransition(float value)
}
// Establece la posición del objeto
void Background::setPos(SDL_Rect pos)
void Background::setPos(SDL_FRect pos)
{
dst_rect_ = pos;

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL3/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <stddef.h> // Para size_t
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
@@ -71,17 +71,17 @@ private:
SDL_Texture *color_texture_; // Textura para atenuar el fondo
// Variables
SDL_Rect gradient_rect_[4]; // Vector con las coordenadas de los 4 degradados para el cielo
SDL_Rect top_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de arriba
SDL_Rect bottom_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de abajo
SDL_FRect gradient_rect_[4]; // Vector con las coordenadas de los 4 degradados para el cielo
SDL_FRect top_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de arriba
SDL_FRect bottom_clouds_rect_[4]; // Vector con las coordenadas de los 4 nubes de abajo
int gradient_number_ = 0; // Indica el número de degradado de fondo que se va a dibujar
int alpha_ = 0; // Transparencia entre los dos degradados
float clouds_speed_ = 0; // Velocidad a la que se desplazan las nubes
float transition_ = 0; // Nivel de transición del fondo 0..1
int counter_ = 0; // Contador interno
SDL_Rect rect_; // Tamaño del objeto fondo
SDL_Rect src_rect_; // Parte del objeto fondo que se va a dibujará en pantalla
SDL_Rect dst_rect_; // Posición donde dibujar la parte del objeto fondo que se dibujará en pantalla
SDL_FRect rect_; // Tamaño del objeto fondo
SDL_FRect src_rect_; // Parte del objeto fondo que se va a dibujará en pantalla
SDL_FRect dst_rect_; // Posición donde dibujar la parte del objeto fondo que se dibujará en pantalla
int base_; // Linea de fondo coincidente con el area inferior de la zona de juego
Color attenuate_color_; // Color para atenuar el fondo
int alpha_color_text_; // Alpha para atenuar el fondo
@@ -129,7 +129,7 @@ public:
void render();
// Establece la posición del objeto
void setPos(SDL_Rect pos);
void setPos(SDL_FRect pos);
// Ajusta el valor de la variable
void setCloudsSpeed(float value);

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector
@@ -32,7 +32,7 @@ private:
bool power_ball_enabled_ = false; // Indica si hay una powerball ya activa
int power_ball_counter_ = 0; // Contador de formaciones enemigas entre la aparicion de una PowerBall y otra
int last_balloon_deploy_ = 0; // Guarda cual ha sido la última formación desplegada para no repetir;
SDL_Rect play_area_ = param.game.play_area.rect; // Zona por donde se moveran los globos
SDL_FRect play_area_ = param.game.play_area.rect; // Zona por donde se moveran los globos
bool creation_time_enabled_ = true; // Indica si los globos se crean con tiempo
bool can_deploy_balloons_ = true; // Indica si creará globos
@@ -124,7 +124,7 @@ public:
// Setters
void setDefaultBalloonSpeed(float speed) { default_balloon_speed_ = speed; }
void resetBalloonSpeed() { setBalloonSpeed(default_balloon_speed_); }
void setPlayArea(SDL_Rect play_area) { play_area_ = play_area; }
void setPlayArea(SDL_FRect play_area) { play_area_ = play_area; }
void setCreationTimeEnabled(bool value) { creation_time_enabled_ = value; }
void setDeployBalloons(bool value) { can_deploy_balloons_ = value; }
};

View File

@@ -1,5 +1,5 @@
#include "bullet.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <memory> // Para unique_ptr, make_unique, shared_ptr
#include "param.h" // Para Param, ParamGame, param
#include "sprite.h" // Para Sprite

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL3/SDL_stdinc.h> // Para Uint8
#include <memory> // Para shared_ptr, unique_ptr
#include "sprite.h" // Para Sprite
#include "utils.h" // Para Circle

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_));

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Texture
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Texture
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
#include "options.h" // Para Options, OptionsAudio, OptionsMusic
@@ -41,20 +41,20 @@ private:
int steps_ = 0; // Cantidad de pasos a dar para ir reduciendo el audio
// Rectangulos
SDL_Rect credits_rect_src_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (origen)
SDL_Rect credits_rect_dst_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (destino)
SDL_Rect mini_logo_rect_src_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (origen)
SDL_Rect mini_logo_rect_dst_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (destino)
SDL_Rect play_area_ = {
SDL_FRect credits_rect_src_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (origen)
SDL_FRect credits_rect_dst_ = param.game.game_area.rect; // Rectangulo con el texto de los créditos (destino)
SDL_FRect mini_logo_rect_src_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (origen)
SDL_FRect mini_logo_rect_dst_ = param.game.game_area.rect; // Rectangulo con el mini logo de JailGames y el texto de copyright (destino)
SDL_FRect play_area_ = {
param.game.game_area.rect.x,
param.game.game_area.rect.y + black_bars_size_,
param.game.game_area.rect.w,
PLAY_AREA_HEIGHT}; // Area visible para los creditos
SDL_Rect top_black_rect_ = {play_area_.x, param.game.game_area.rect.y, play_area_.w, black_bars_size_}; // Rectangulo negro superior
SDL_Rect bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_}; // Rectangulo negro inferior
SDL_Rect left_black_rect_ = {play_area_.x, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la izquierda
SDL_Rect right_black_rect_ = {play_area_.x + play_area_.w, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la derecha
SDL_Rect red_rect = play_area_; // Rectangulo rojo para delimitar la ventana
SDL_FRect top_black_rect_ = {play_area_.x, param.game.game_area.rect.y, play_area_.w, black_bars_size_}; // Rectangulo negro superior
SDL_FRect bottom_black_rect_ = {play_area_.x, param.game.game_area.rect.h - black_bars_size_, play_area_.w, black_bars_size_}; // Rectangulo negro inferior
SDL_FRect left_black_rect_ = {play_area_.x, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la izquierda
SDL_FRect right_black_rect_ = {play_area_.x + play_area_.w, param.game.game_area.center_y - 1, 0, 2}; // Rectangulo negro situado a la derecha
SDL_FRect red_rect = play_area_; // Rectangulo rojo para delimitar la ventana
// Actualiza las variables
void update();

View File

@@ -1,45 +0,0 @@
#include "dbgtxt.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromMem
#include <SDL2/SDL_surface.h> // Para SDL_LoadBMP_RW
namespace
{
SDL_Texture *dbg_tex = nullptr;
SDL_Renderer *dbg_ren = nullptr;
}
void dbg_init(SDL_Renderer *renderer)
{
dbg_ren = renderer;
Uint8 font[448] = {0x42, 0x4D, 0xC0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x01, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x18, 0xF3, 0x83, 0x83, 0xCF, 0x83, 0x87, 0x00, 0x00, 0xF3, 0x39, 0x39, 0xCF, 0x79, 0xF3, 0x00, 0x00, 0x01, 0xF9, 0x39, 0xCF, 0x61, 0xF9, 0x00, 0x00, 0x33, 0xF9, 0x03, 0xE7, 0x87, 0x81, 0x00, 0x00, 0x93, 0x03, 0x3F, 0xF3, 0x1B, 0x39, 0x00, 0x00, 0xC3, 0x3F, 0x9F, 0x39, 0x3B, 0x39, 0x00, 0x41, 0xE3, 0x03, 0xC3, 0x01, 0x87, 0x83, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xE7, 0x01, 0xC7, 0x81, 0x01, 0x83, 0x00, 0x00, 0xE7, 0x1F, 0x9B, 0xE7, 0x1F, 0x39, 0x00, 0x00, 0xE7, 0x8F, 0x39, 0xE7, 0x87, 0xF9, 0x00, 0x00, 0xC3, 0xC7, 0x39, 0xE7, 0xC3, 0xC3, 0x00, 0x00, 0x99, 0xE3, 0x39, 0xE7, 0xF1, 0xE7, 0x00, 0x00, 0x99, 0xF1, 0xB3, 0xC7, 0x39, 0xF3, 0x00, 0x00, 0x99, 0x01, 0xC7, 0xE7, 0x83, 0x81, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x83, 0xE7, 0x83, 0xEF, 0x39, 0x39, 0x00, 0x00, 0x39, 0xE7, 0x39, 0xC7, 0x11, 0x11, 0x00, 0x00, 0xF9, 0xE7, 0x39, 0x83, 0x01, 0x83, 0x00, 0x00, 0x83, 0xE7, 0x39, 0x11, 0x01, 0xC7, 0x00, 0x00, 0x3F, 0xE7, 0x39, 0x39, 0x29, 0x83, 0x00, 0x00, 0x33, 0xE7, 0x39, 0x39, 0x39, 0x11, 0x00, 0x00, 0x87, 0x81, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x39, 0x39, 0x83, 0x3F, 0x85, 0x31, 0x00, 0x00, 0x39, 0x31, 0x39, 0x3F, 0x33, 0x23, 0x00, 0x00, 0x29, 0x21, 0x39, 0x03, 0x21, 0x07, 0x00, 0x00, 0x01, 0x01, 0x39, 0x39, 0x39, 0x31, 0x00, 0x00, 0x01, 0x09, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0x11, 0x19, 0x39, 0x39, 0x39, 0x39, 0x00, 0x00, 0x39, 0x39, 0x83, 0x03, 0x83, 0x03, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xC1, 0x39, 0x81, 0x83, 0x31, 0x01, 0x00, 0x00, 0x99, 0x39, 0xE7, 0x39, 0x23, 0x3F, 0x00, 0x00, 0x39, 0x39, 0xE7, 0xF9, 0x07, 0x3F, 0x00, 0x00, 0x31, 0x01, 0xE7, 0xF9, 0x0F, 0x3F, 0x00, 0x00, 0x3F, 0x39, 0xE7, 0xF9, 0x27, 0x3F, 0x00, 0x00, 0x9F, 0x39, 0xE7, 0xF9, 0x33, 0x3F, 0x00, 0x00, 0xC1, 0x39, 0x81, 0xF9, 0x39, 0x3F, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x39, 0x03, 0xC3, 0x07, 0x01, 0x3F, 0x00, 0x00, 0x39, 0x39, 0x99, 0x33, 0x3F, 0x3F, 0x00, 0x00, 0x01, 0x39, 0x3F, 0x39, 0x3F, 0x3F, 0x00, 0x00, 0x39, 0x03, 0x3F, 0x39, 0x03, 0x03, 0x00, 0x00, 0x39, 0x39, 0x3F, 0x39, 0x3F, 0x3F, 0x00, 0x00, 0x93, 0x39, 0x99, 0x33, 0x3F, 0x3F, 0x00, 0x00, 0xC7, 0x03, 0xC3, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00};
dbg_tex = SDL_CreateTextureFromSurface(dbg_ren, SDL_LoadBMP_RW(SDL_RWFromMem(font, 448), 1));
}
void dbg_print(int x, int y, const char *text, Uint8 r, Uint8 g, Uint8 b)
{
int cc = 0;
SDL_SetTextureColorMod(dbg_tex, r, g, b);
SDL_Rect src = {0, 0, 8, 8};
SDL_Rect dst = {x, y, 8, 8};
while (text[cc] != 0)
{
if (text[cc] != 32)
{
if (text[cc] >= 65)
{
src.x = ((text[cc] - 65) % 6) * 8;
src.y = ((text[cc] - 65) / 6) * 8;
}
else
{
src.x = ((text[cc] - 22) % 6) * 8;
src.y = ((text[cc] - 22) / 6) * 8;
}
SDL_RenderCopy(dbg_ren, dbg_tex, &src, &dst);
}
cc++;
dst.x += 8;
}
}

View File

@@ -1,7 +0,0 @@
#pragma once
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint8
void dbg_init(SDL_Renderer *renderer);
void dbg_print(int x, int y, const char *text, Uint8 r, Uint8 g, Uint8 b);

View File

@@ -35,7 +35,7 @@ void DefineButtons::render()
}
// Comprueba el botón que se ha pulsado
void DefineButtons::doControllerButtonDown(const SDL_ControllerButtonEvent &event)
void DefineButtons::doControllerButtonDown(const SDL_GamepadButtonEvent &event)
{
// Solo pilla botones del mando que toca
if (input_->getJoyIndex(event.which) != static_cast<int>(index_controller_))
@@ -43,7 +43,7 @@ void DefineButtons::doControllerButtonDown(const SDL_ControllerButtonEvent &even
return;
}
const auto button = static_cast<SDL_GameControllerButton>(event.button);
const auto button = static_cast<SDL_GamepadButton>(event.button);
if (checkButtonNotInUse(button))
{
buttons_.at(index_button_).button = button;
@@ -63,9 +63,9 @@ void DefineButtons::bindButtons()
// Comprueba los eventos
void DefineButtons::checkEvents(const SDL_Event &event)
{
if (enabled_ && event.type == SDL_CONTROLLERBUTTONDOWN)
if (enabled_ && event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN)
{
doControllerButtonDown(event.cbutton);
doControllerButtonDown(event.gbutton);
}
}
@@ -119,7 +119,7 @@ void DefineButtons::saveBindingsToOptions()
}
// Comprueba que un botón no esté ya asignado
bool DefineButtons::checkButtonNotInUse(SDL_GameControllerButton button)
bool DefineButtons::checkButtonNotInUse(SDL_GamepadButton button)
{
for (const auto &b : buttons_)
{
@@ -135,9 +135,9 @@ bool DefineButtons::checkButtonNotInUse(SDL_GameControllerButton button)
void DefineButtons::clearButtons()
{
buttons_.clear();
buttons_.emplace_back(lang::getText(95), InputAction::FIRE_LEFT, SDL_CONTROLLER_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(96), InputAction::FIRE_CENTER, SDL_CONTROLLER_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(97), InputAction::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(98), InputAction::START, SDL_CONTROLLER_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(99), InputAction::SERVICE, SDL_CONTROLLER_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(95), InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(96), InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(97), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(98), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
buttons_.emplace_back(lang::getText(99), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_events.h> // Para SDL_ControllerButtonEvent
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
#include <SDL3/SDL_events.h> // Para SDL_ControllerButtonEvent
#include <SDL3/SDL.h> // Para SDL_GamepadButton
#include <stddef.h> // Para size_t
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
@@ -14,10 +14,10 @@ struct DefineButtonsButton
{
std::string label; // Texto en pantalla para el botón
InputAction input; // Input asociado
SDL_GameControllerButton button; // Botón del mando correspondiente
SDL_GamepadButton button; // Botón del mando correspondiente
// Constructor
DefineButtonsButton(const std::string &lbl, InputAction inp, SDL_GameControllerButton btn)
DefineButtonsButton(const std::string &lbl, InputAction inp, SDL_GamepadButton btn)
: label(lbl), input(inp), button(btn) {}
};
@@ -42,7 +42,7 @@ private:
void incIndexButton();
// Comprueba el botón que se ha pulsado
void doControllerButtonDown(const SDL_ControllerButtonEvent &event);
void doControllerButtonDown(const SDL_GamepadButtonEvent &event);
// Asigna los botones definidos al input
void bindButtons();
@@ -51,7 +51,7 @@ private:
void saveBindingsToOptions();
// Comprueba que un botón no esté ya asignado
bool checkButtonNotInUse(SDL_GameControllerButton button);
bool checkButtonNotInUse(SDL_GamepadButton button);
// Limpia la asignación de botones
void clearButtons();

View File

@@ -1,15 +1,15 @@
// IWYU pragma: no_include <bits/chrono.h>
#include "director.h"
#include <SDL2/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_EV...
#include <SDL2/SDL_audio.h> // Para AUDIO_S16
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_events.h> // Para SDL_DISABLE
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // Para Uint32, SDL_bool
#include <SDL3/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_EV...
#include <SDL3/SDL_audio.h> // Para AUDIO_S16
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_events.h> // Para SDL_DISABLE
#include <SDL3/SDL.h> // Para SDL_GAMEPAD_BUTTON_B, SDL_CO...
#include <SDL3/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL3/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL3/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL3/SDL_stdinc.h> // Para Uint32, SDL_bool
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // Para printf, perror
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU
@@ -101,7 +101,7 @@ void Director::init()
// Inicializa y crea el resto de objetos
initSDL();
SDL_ShowCursor(SDL_DISABLE);
SDL_HideCursor();
initJailAudio();
dbg_init(renderer_);
lang::loadFromFile(getLangFile(static_cast<lang::Code>(options.game.language)));
@@ -202,19 +202,19 @@ void Director::bindInputs()
for (int i = 0; i < NUM_GAMEPADS; ++i)
{
// Mando - Movimiento del jugador
Input::get()->bindGameControllerButton(i, InputAction::UP, SDL_CONTROLLER_BUTTON_DPAD_UP);
Input::get()->bindGameControllerButton(i, InputAction::DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN);
Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT);
Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT);
Input::get()->bindGameControllerButton(i, InputAction::UP, SDL_GAMEPAD_BUTTON_DPAD_UP);
Input::get()->bindGameControllerButton(i, InputAction::DOWN, SDL_GAMEPAD_BUTTON_DPAD_DOWN);
Input::get()->bindGameControllerButton(i, InputAction::LEFT, SDL_GAMEPAD_BUTTON_DPAD_LEFT);
Input::get()->bindGameControllerButton(i, InputAction::RIGHT, SDL_GAMEPAD_BUTTON_DPAD_RIGHT);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_LEFT, SDL_CONTROLLER_BUTTON_X);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_CENTER, SDL_CONTROLLER_BUTTON_Y);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_RIGHT, SDL_CONTROLLER_BUTTON_B);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_LEFT, SDL_GAMEPAD_BUTTON_WEST);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_CENTER, SDL_GAMEPAD_BUTTON_NORTH);
Input::get()->bindGameControllerButton(i, InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_EAST);
Input::get()->bindGameControllerButton(i, InputAction::START, SDL_CONTROLLER_BUTTON_START);
Input::get()->bindGameControllerButton(i, InputAction::START, SDL_GAMEPAD_BUTTON_START);
// Mando - Control del programa
Input::get()->bindGameControllerButton(i, InputAction::SERVICE, SDL_CONTROLLER_BUTTON_BACK);
Input::get()->bindGameControllerButton(i, InputAction::SERVICE, SDL_GAMEPAD_BUTTON_BACK);
}
// Mapea las asignaciones a los botones desde el archivo de configuración, si se da el caso
@@ -270,7 +270,7 @@ void Director::bindInputs()
// Inicializa JailAudio
void Director::initJailAudio()
{
JA_Init(48000, AUDIO_S16, 2);
JA_Init(48000, SDL_AUDIO_S16LE, 2);
if (options.audio.enabled)
{
JA_SetMusicVolume(to_JA_volume(options.audio.music.volume));
@@ -290,7 +290,7 @@ bool Director::initSDL()
auto success = true;
// Inicializa SDL
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
if (!SDL_Init(SDL_INIT_VIDEO))
{
std::cout << "SDL could not initialize!\nSDL Error: " << SDL_GetError() << std::endl;
success = false;
@@ -298,22 +298,21 @@ bool Director::initSDL()
else
{
// Obtiene información sobre la pantalla
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
auto DM= SDL_GetCurrentDisplayMode(0);
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
options.video.window.max_zoom = std::min(DM.w / param.game.width, DM.h / param.game.height);
options.video.window.max_zoom = std::min(DM->w / param.game.width, DM->h / param.game.height);
options.video.window.zoom = std::min(options.video.window.zoom, options.video.window.max_zoom);
// Muestra información sobre el tamaño de la pantalla y de la ventana de juego
std::cout << "\nCurrent display mode: " << DM.w << "x" << DM.h << " @ " << DM.refresh_rate << "Hz" << std::endl;
std::cout << "\nCurrent display mode: " << DM->w << "x" << DM->h << " @ " << DM->refresh_rate << "Hz" << std::endl;
std::cout << "Window resolution : " << param.game.width << "x" << param.game.height << " x" << options.video.window.zoom << std::endl;
// Establece el filtro de la textura
if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
/*if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, std::to_string(static_cast<int>(options.video.filter)).c_str()))
{
std::cout << "Warning: texture filtering not enabled!\n";
}
}*/
if (!SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"))
{
@@ -321,7 +320,7 @@ bool Director::initSDL()
}
// Crea la ventana
window_ = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, param.game.width * options.video.window.zoom, param.game.height * options.video.window.zoom, SDL_WINDOW_HIDDEN);
window_ = SDL_CreateWindow(WINDOW_CAPTION, param.game.width * options.video.window.zoom, param.game.height * options.video.window.zoom, SDL_WINDOW_OPENGL);
if (!window_)
{
std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
@@ -333,13 +332,13 @@ bool Director::initSDL()
Uint32 flags = 0;
if (options.video.v_sync)
{
flags = SDL_RENDERER_PRESENTVSYNC;
//flags = SDL_RENDERER_PRESENTVSYNC;
}
// La aceleración se activa según el define
flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
//flags = flags | SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
renderer_ = SDL_CreateRenderer(window_, -1, flags);
renderer_ = SDL_CreateRenderer(window_, nullptr);
if (!renderer_)
{
@@ -349,8 +348,7 @@ bool Director::initSDL()
else
{
SDL_SetRenderDrawColor(renderer_, 0x00, 0x00, 0x00, 0xFF);
SDL_RenderSetLogicalSize(renderer_, param.game.width, param.game.height);
SDL_RenderSetIntegerScale(renderer_, static_cast<SDL_bool>(options.video.integer_scale));
SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
SDL_SetWindowFullscreen(window_, static_cast<Uint32>(options.video.mode));
SDL_SetRenderDrawBlendMode(renderer_, SDL_BLENDMODE_BLEND);
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_video.h> // Para SDL_Window
#include <SDL3/SDL_render.h> // Para SDL_Renderer
#include <SDL3/SDL_video.h> // Para SDL_Window
#include <string> // Para string
namespace lang
{

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_);

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint16
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL3/SDL_stdinc.h> // Para Uint8, Uint16
#include <vector> // Para vector
// Tipos de fundido
@@ -45,11 +45,11 @@ private:
FadeState state_ = FadeState::NOT_ENABLED; // Estado actual del objeto
Uint16 counter_; // Contador interno
Uint8 r_, g_, b_, a_; // Colores para el fade
SDL_Rect rect1_; // Rectangulo usado para crear los efectos de transición
SDL_Rect rect2_; // Rectangulo usado para crear los efectos de transición
SDL_FRect rect1_; // Rectangulo usado para crear los efectos de transición
SDL_FRect rect2_; // Rectangulo usado para crear los efectos de transición
int num_squares_width_; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
int num_squares_height_; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
std::vector<SDL_Rect> square_; // Vector con los indices de los cuadrados para el FadeType::RANDOM_SQUARE
std::vector<SDL_FRect> square_; // Vector con los indices de los cuadrados para el FadeType::RANDOM_SQUARE
int fade_random_squares_delay_; // Duración entre cada pintado de cuadrados
int fade_random_squares_mult_; // Cantidad de cuadrados que se pintaran cada vez
int post_duration_ = 0; // Duración posterior del fade tras finalizar

View File

@@ -1,10 +1,10 @@
#include "game.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_Event, SDL_PollEvent, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_events.h> // Para SDL_Event, SDL_PollEvent, SDL_KEYDOWN
#include <SDL3/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_video.h> // Para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
#include <stdlib.h> // Para rand, size_t
#include <algorithm> // Para find_if, clamp, min
#include <functional> // Para function
@@ -1066,7 +1066,7 @@ void Game::render()
screen_->start();
// Copia la textura con la zona de juego a la pantalla
SDL_RenderCopy(renderer_, canvas_, nullptr, &param.game.play_area.rect);
SDL_RenderTexture(renderer_, canvas_, nullptr, &param.game.play_area.rect);
// Dibuja el marcador
scoreboard_->render();

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL3/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,5 +1,5 @@
#include "game_logo.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL
#include <SDL3/SDL_render.h> // Para SDL_FLIP_HORIZONTAL
#include <algorithm> // Para max
#include "animated_sprite.h" // Para AnimatedSprite
#include "jail_audio.h" // Para JA_PlaySound

View File

@@ -1,5 +1,5 @@
#include "global_events.h"
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <SDL3/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <iostream> // Para char_traits, basic_ostream, operator<<
#include "mouse.h" // Para handleEvent
#include "section.h" // Para Name, Options, name, options

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_events.h>
#include <SDL3/SDL_events.h>
namespace globalEvents
{

View File

@@ -1,6 +1,6 @@
#include "global_inputs.h"
#include <SDL2/SDL_render.h> // Para SDL_RenderSetIntegerScale
#include <SDL2/SDL_stdinc.h> // Para SDL_FALSE, SDL_TRUE
#include <SDL3/SDL_render.h> // Para SDL_RenderSetIntegerScale
#include <SDL3/SDL_stdinc.h> // Para SDL_FALSE, SDL_TRUE
#include <string> // Para operator+, string, to_string, basic_string
#include <vector> // Para vector
#include "asset.h" // Para Asset

View File

@@ -1,8 +1,8 @@
#include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#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
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand, size_t
#include <algorithm> // Para max
#include <functional> // Para function
@@ -125,7 +125,7 @@ void HiScoreTable::render()
view_area_.y = std::max(0, param.game.height - counter_ + 100);
// Copia el backbuffer al renderizador
SDL_RenderCopy(renderer_, backbuffer_, nullptr, &view_area_);
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_area_);
// Renderiza el fade
fade_->render();

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // Para Uint16, Uint32, Uint8
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL3/SDL_stdinc.h> // Para Uint16, Uint32, Uint8
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,8 +1,8 @@
#include "input.h"
#include <SDL2/SDL.h> // Para SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_events.h> // Para SDL_ENABLE
#include <SDL2/SDL_keyboard.h> // Para SDL_GetKeyboardState
#include <SDL3/SDL.h> // Para SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_events.h> // Para SDL_ENABLE
#include <SDL3/SDL_keyboard.h> // Para SDL_GetKeyboardState
#include <algorithm> // Para find
#include <iostream> // Para basic_ostream, operator<<, cout, endl
#include <iterator> // Para distance

View File

@@ -1,9 +1,9 @@
#pragma once
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton, SDL_G...
#include <SDL2/SDL_joystick.h> // Para SDL_Joystick
#include <SDL2/SDL_scancode.h> // Para SDL_Scancode
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL3/SDL.h> // Para SDL_GamepadButton, SDL_G...
#include <SDL3/SDL_joystick.h> // Para SDL_Joystick
#include <SDL3/SDL_scancode.h> // Para SDL_Scancode
#include <SDL3/SDL_stdinc.h> // Para Uint8
#include <string> // Para string, basic_string
#include <vector> // Para vector
@@ -80,17 +80,17 @@ private:
struct ControllerBindings
{
SDL_GameControllerButton button; // GameControllerButton asociado
SDL_GamepadButton button; // GameControllerButton asociado
bool active; // Indica si está activo
bool axis_active; // Estado del eje
// Constructor
explicit ControllerBindings(SDL_GameControllerButton btn = SDL_CONTROLLER_BUTTON_INVALID, bool act = false, bool axis_act = false)
explicit ControllerBindings(SDL_GamepadButton btn = SDL_GAMEPAD_BUTTON_INVALID, bool act = false, bool axis_act = false)
: button(btn), active(act), axis_active(axis_act) {}
};
// Variables
std::vector<SDL_GameController *> connected_controllers_; // Vector con todos los mandos conectados
std::vector<SDL_Gamepad *> connected_controllers_; // Vector con todos los mandos conectados
std::vector<SDL_Joystick *> joysticks_; // Vector con todos los joysticks conectados
std::vector<KeyBindings> key_bindings_; // Vector con las teclas asociadas a los inputs predefinidos
std::vector<std::vector<ControllerBindings>> controller_bindings_; // Vector con los botones asociadas a los inputs predefinidos para cada mando
@@ -123,7 +123,7 @@ public:
void bindKey(InputAction input, SDL_Scancode code);
// Asigna inputs a botones del mando
void bindGameControllerButton(int controller_index, InputAction input, SDL_GameControllerButton button);
void bindGameControllerButton(int controller_index, InputAction input, SDL_GamepadButton button);
void bindGameControllerButton(int controller_index, InputAction inputTarget, InputAction inputSource);
// Comprueba si un input esta activo
@@ -153,8 +153,8 @@ public:
// Muestra por consola los controles asignados
void printBindings(InputDeviceToUse device = InputDeviceToUse::KEYBOARD, int controller_index = 0) const;
// Obtiene el SDL_GameControllerButton asignado a un input
SDL_GameControllerButton getControllerBinding(int controller_index, InputAction input) const;
// Obtiene el SDL_GamepadButton asignado a un input
SDL_GamepadButton getControllerBinding(int controller_index, InputAction input) const;
// Convierte un InputAction a std::string
std::string to_string(InputAction input) const;

View File

@@ -1,8 +1,8 @@
#include "instructions.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#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
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para max
#include <utility> // Para move
#include <vector> // Para vector
@@ -186,7 +186,7 @@ void Instructions::fillBackbuffer()
SDL_RenderClear(renderer_);
// Coloca el texto de fondo
SDL_RenderCopy(renderer_, texture_, nullptr, nullptr);
SDL_RenderTexture(renderer_, texture_, nullptr, nullptr);
// Dibuja los sprites
for (auto &sprite : sprites_)
@@ -251,7 +251,7 @@ void Instructions::render()
if (view_.y == 0)
renderLines(renderer_, backbuffer_, lines_);
else
SDL_RenderCopy(renderer_, backbuffer_, nullptr, &view_);
SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_);
fade_->render();
@@ -340,7 +340,7 @@ void Instructions::renderLines(SDL_Renderer *renderer, SDL_Texture *texture, con
{
SDL_Rect srcRect = {0, line.y, 320, 1};
SDL_Rect dstRect = {static_cast<int>(line.x), line.y, 320, 1};
SDL_RenderCopy(renderer, texture, &srcRect, &dstRect);
SDL_RenderTexture(renderer, texture, &srcRect, &dstRect);
}
}

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector
class Fade; // lines 8-8

View File

@@ -1,10 +1,10 @@
#include "intro.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_SetTextureBlendMode, SDL_GetRend...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_SetTextureBlendMode, SDL_GetRend...
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <array> // Para array
#include <functional> // Para function
#include <string> // Para basic_string, string
@@ -354,10 +354,10 @@ void Intro::initSprites()
SDL_SetRenderDrawColor(Screen::get()->getRenderer(), 0xFF, 0x00, 0x00, 0xFF);
SDL_RenderClear(Screen::get()->getRenderer());
SDL_Rect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT};
SDL_FRect rect = {BORDER / 2, BORDER / 2, SPRITE_WIDTH, SPRITE_HEIGHT};
auto inner_texture = Resource::get()->getTexture(TEXTURE_LIST.at(i))->getSDLTexture();
SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_MOD);
SDL_RenderCopy(Screen::get()->getRenderer(), inner_texture, nullptr, &rect);
SDL_RenderTexture(Screen::get()->getRenderer(), inner_texture, nullptr, &rect);
SDL_SetTextureBlendMode(inner_texture, SDL_BLENDMODE_NONE);
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL3/SDL_stdinc.h> // Para Uint32, Uint8
#include <memory> // Para unique_ptr
#include <vector> // Para vector
#include "path_sprite.h" // Para PathSprite

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint16
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_stdinc.h> // Para Uint16
#include <memory> // Para shared_ptr, unique_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,7 +1,7 @@
#ifndef JA_USESDLMIXER
#include "jail_audio.h"
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromMem
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_rwops.h> // Para SDL_RWFromMem
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stdint.h> // Para uint8_t, uint32_t
#include <stdio.h> // Para NULL, fseek, fclose, fopen, fread, ftell
#include <stdlib.h> // Para free, malloc

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_audio.h> // Para SDL_AudioFormat
#include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL3/SDL_audio.h> // Para SDL_AudioFormat
#include <SDL3/SDL_stdinc.h> // Para Uint32, Uint8
struct JA_Music_t; // lines 4-4
struct JA_Sound_t; // lines 5-5

View File

@@ -1,6 +1,6 @@
#include "jail_shader.h"
#include <SDL2/SDL_rect.h> // Para SDL_Point
#include <SDL2/SDL_stdinc.h> // Para SDL_bool
#include <SDL3/SDL_rect.h> // Para SDL_Point
#include <SDL3/SDL_stdinc.h> // Para SDL_bool
#include <cstring> // Para strncmp
#include <iostream> // Para basic_ostream, operator<<, endl, cout
#include <stdexcept> // Para runtime_error
@@ -15,7 +15,7 @@
#include <OpenGL/gl.h> // Para OpenGL (compatibilidad) en macOS
#endif // ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
#else // SI NO ES __APPLE__
#include <SDL2/SDL_opengl.h> // Para GLuint, glTexCoord2f, glVertex2f, GLfloat
#include <SDL3/SDL_opengl.h> // Para GLuint, glTexCoord2f, glVertex2f, GLfloat
#endif // __APPLE__
namespace shader
@@ -287,7 +287,7 @@ namespace shader
}
else
{
SDL_RenderCopy(renderer, backBuffer, nullptr, nullptr);
SDL_RenderTexture(renderer, backBuffer, nullptr, nullptr);
SDL_RenderPresent(renderer);
}
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_render.h> // Para SDL_Texture
#include <SDL2/SDL_video.h> // Para SDL_Window
#include <SDL3/SDL_render.h> // Para SDL_Texture
#include <SDL3/SDL_video.h> // Para SDL_Window
#include <string>
namespace shader

View File

@@ -1,6 +1,6 @@
#include "logo.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <utility> // Para move
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Point
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Point
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <memory> // Para shared_ptr, unique_ptr
#include <vector> // Para vector
class Sprite; // lines 8-8

View File

@@ -1,6 +1,6 @@
#include "manage_hiscore_table.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <algorithm> // Para find_if, sort
#include <iostream> // Para basic_ostream, operator<<, cout, endl
#include <iterator> // Para distance

View File

@@ -1,6 +1,6 @@
#include "mouse.h"
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
namespace Mouse
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_events.h> // Para SDL_Event
#include <SDL3/SDL_stdinc.h> // Para Uint32
namespace Mouse
{

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_RendererFlip
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL3/SDL_render.h> // Para SDL_RendererFlip
#include <memory> // Para shared_ptr
#include <algorithm>
#include "sprite.h" // Para Sprite

View File

@@ -1,6 +1,6 @@
#include "notifier.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <string> // Para string
#include <algorithm>
#include <vector>

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Renderer
#include <memory> // Para shared_ptr
#include <string> // Para string, basic_string
#include <vector> // Para vector

View File

@@ -1,6 +1,6 @@
#include "on_screen_help.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <memory> // Para make_unique, unique_ptr
#include "lang.h" // Para getText
#include "param.h" // Para Param, ParamGame, param
@@ -82,7 +82,7 @@ void OnScreenHelp::render()
{
if (state != OnScreenHelpStatus::hidden)
{
SDL_RenderCopy(Screen::get()->getRenderer(), texture, nullptr, &dest);
SDL_RenderTexture(Screen::get()->getRenderer(), texture, nullptr, &dest);
}
}

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Texture
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Texture
#include <vector> // Para vector
class Sprite;
class Text;

View File

@@ -1,5 +1,5 @@
#include "options.h"
#include <SDL2/SDL_gamecontroller.h> // Para SDL_GameControllerButton
#include <SDL3/SDL_gamecontroller.h> // Para SDL_GameControllerButton
#include <algorithm> // Para clamp
#include <fstream> // Para basic_ostream, operator<<, basi...
#include <iostream> // Para cout

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <string> // Para string
#include <vector> // Para vector
#include "input.h" // Para InputAction, InputDeviceToUse

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <string> // Para string
#include <vector> // Para vector
#include "utils.h" // Para Color, Zone

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Point
#include <SDL3/SDL_rect.h> // Para SDL_Point
#include <functional> // Para function
#include <memory> // Para shared_ptr
#include <vector> // Para vector

View File

@@ -1,6 +1,6 @@
#include "player.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL...
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand
#include <algorithm> // Para clamp, max, min
#include "animated_sprite.h" // Para AnimatedSprite

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,7 +1,7 @@
#include "scoreboard.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#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_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <math.h> // Para roundf
#include <iomanip> // Para operator<<, setfill, setw
#include <sstream> // Para basic_ostream, basic_ostringstream
@@ -120,7 +120,7 @@ void Scoreboard::update()
// Pinta el marcador
void Scoreboard::render()
{
SDL_RenderCopy(renderer_, background_, nullptr, &rect_);
SDL_RenderTexture(renderer_, background_, nullptr, &rect_);
}
// Establece el valor de la variable
@@ -296,7 +296,7 @@ void Scoreboard::fillPanelTextures()
// NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
/* TEXTO CENTRADO */
//text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
// text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
/* TEXTO A LA IZQUIERDA */
text_scoreboard_->writeColored(enter_name_pos_.x, enter_name_pos_.y, record_name_[i], getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
@@ -340,7 +340,7 @@ void Scoreboard::fillBackgroundTexture()
// Copia las texturas de los paneles
for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i)
{
SDL_RenderCopy(renderer_, panel_texture_[i], nullptr, &panel_[i].pos);
SDL_RenderTexture(renderer_, panel_texture_[i], nullptr, &panel_[i].pos);
}
// Dibuja la linea que separa la zona de juego del marcador

View File

@@ -1,9 +1,9 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Texture, SDL_Renderer
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stddef.h> // Para size_t
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string

View File

@@ -1,6 +1,6 @@
#include "screen.h"
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para max, min
#include <fstream> // Para basic_ifstream, ifstream
#include <iterator> // Para istreambuf_iterator, operator==
@@ -32,13 +32,12 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
: window_(window),
renderer_(renderer),
game_canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
src_rect_({0, 0, param.game.width, param.game.height}),
dst_rect_({0, 0, param.game.width, param.game.height})
src_rect_(SDL_FRect{0, 0, static_cast<float>(param.game.width), static_cast<float>(param.game.height)}),
dst_rect_(SDL_FRect{0, 0, static_cast<float>(param.game.width), static_cast<float>(param.game.height)})
{
// Inicializa variables
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
info_resolution_ = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ";
auto DM = SDL_GetCurrentDisplayMode(0);
info_resolution_ = std::to_string(DM->w) + " X " + std::to_string(DM->h) + " AT " + std::to_string(DM->refresh_rate) + " HZ";
adjustRenderLogicalSize();
// Muestra la ventana
@@ -85,7 +84,7 @@ void Screen::renderScreen()
}
else
{
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
SDL_RenderPresent(renderer_);
}
}
@@ -100,7 +99,7 @@ void Screen::setVideoMode(ScreenVideoMode mode)
Uint32 flags = SDL_GetWindowFlags(window_);
if (flags != static_cast<Uint32>(options.video.mode))
{
SDL_SetWindowFullscreen(window_, static_cast<Uint32>(options.video.mode));
SDL_SetWindowFullscreen(window_, static_cast<bool>(options.video.mode));
}
initShaders();
@@ -192,11 +191,11 @@ void Screen::renderShake()
// Vuelca game_canvas_ a la textura temporal
SDL_SetRenderTarget(renderer_, temp_texture);
SDL_RenderCopy(renderer_, game_canvas_, nullptr, nullptr);
SDL_RenderTexture(renderer_, game_canvas_, nullptr, nullptr);
// Vuelca textura temporal a game_canvas_
SDL_SetRenderTarget(renderer_, game_canvas_);
SDL_RenderCopy(renderer_, temp_texture, &src_rect_, &dst_rect_);
SDL_RenderTexture(renderer_, temp_texture, &src_rect_, &dst_rect_);
// Elimina la textura temporal
SDL_DestroyTexture(temp_texture);
@@ -261,7 +260,7 @@ void Screen::adjustWindowSize()
const int NEW_POS_Y = old_pos_y + (old_height - HEIGHT) / 2;
SDL_Rect viewport = {0, 0, WIDTH, HEIGHT};
SDL_RenderSetViewport(renderer_, &viewport);
SDL_SetRenderViewport(renderer_, &viewport);
SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS_), std::max(NEW_POS_Y, 0));
SDL_SetWindowSize(window_, WIDTH, HEIGHT);
@@ -274,11 +273,10 @@ void Screen::adjustWindowSize()
int Screen::getMaxZoom()
{
// Obtiene información sobre la pantalla
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
auto DM = SDL_GetCurrentDisplayMode(0);
// Calcula el máximo factor de zoom que se puede aplicar a la pantalla
const int MAX_ZOOM = std::min(DM.w / param.game.width, (DM.h - WINDOWS_DECORATIONS_) / param.game.height);
const int MAX_ZOOM = std::min(DM->w / param.game.width, (DM->h - WINDOWS_DECORATIONS_) / param.game.height);
// Normaliza los valores de zoom
options.video.window.zoom = std::min(options.video.window.zoom, MAX_ZOOM);

View File

@@ -1,10 +1,10 @@
#pragma once
#include <SDL2/SDL_blendmode.h> // Para SDL_BlendMode
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_video.h> // Para SDL_Window
#include <SDL3/SDL_blendmode.h> // Para SDL_BlendMode
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_video.h> // Para SDL_Window
#include <string> // Para string
#include "param.h" // Para Param, ParamGame, param
#include "utils.h" // Para Color
@@ -16,10 +16,10 @@ enum class ScreenFilter : int
LINEAL = 1,
};
enum class ScreenVideoMode : Uint32
enum class ScreenVideoMode : bool
{
WINDOW = 0,
FULLSCREEN = SDL_WINDOW_FULLSCREEN_DESKTOP,
WINDOW = false,
FULLSCREEN = true,
};
class Screen
@@ -92,7 +92,7 @@ private:
: desp(dp), delay(dl), counter(cnt), lenght(len), remaining(rem), original_pos(origPos), original_width(origWidth), enabled(en) {}
// Método para habilitar el efecto
void enable(SDL_Rect &src_rect, SDL_Rect &dst_rect)
void enable(SDL_FRect &src_rect, SDL_FRect &dst_rect)
{
if (!enabled)
{
@@ -112,7 +112,7 @@ private:
}
// Método para actualizar el efecto de movimiento/agitación
void update(SDL_Rect &src_rect, SDL_Rect &dst_rect)
void update(SDL_FRect &src_rect, SDL_FRect &dst_rect)
{
if (enabled)
{
@@ -162,8 +162,8 @@ private:
SDL_Texture *game_canvas_; // Textura donde se dibuja todo antes de volcarse al renderizador
// Variables
SDL_Rect src_rect_; // Coordenadas de donde va a pillar la textura del juego para dibujarla
SDL_Rect dst_rect_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
SDL_FRect src_rect_; // Coordenadas de donde va a pillar la textura del juego para dibujarla
SDL_FRect dst_rect_; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana
FPS fps_; // Variable para gestionar los frames por segundo
std::string info_resolution_; // Texto con la informacion de la pantalla
std::string shader_source_; // Almacena el contenido del archivo GLSL
@@ -199,7 +199,7 @@ private:
void adjustWindowSize();
// Ajusta el tamaño lógico del renderizador
void adjustRenderLogicalSize() { SDL_RenderSetLogicalSize(renderer_, param.game.width, param.game.height); }
void adjustRenderLogicalSize() { SDL_SetRenderLogicalPresentation(renderer_, param.game.width, param.game.height, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); }
// Obtiene el tamaño máximo de zoom posible para la ventana
int getMaxZoom();

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <memory> // Para shared_ptr
class Texture;

View File

@@ -1,6 +1,6 @@
// IWYU pragma: no_include <bits/std_abs.h>
#include "tabe.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <SDL3/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <stdlib.h> // Para rand, abs
#include <algorithm> // Para max
#include "jail_audio.h" // Para JA_PlaySound

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand
#include <memory> // Para unique_ptr
#include "animated_sprite.h" // Para AnimatedSprite

View File

@@ -1,8 +1,8 @@
#include "text.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_TEXTUREACCESS_TARGET
#include <SDL3/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_TEXTUREACCESS_TARGET
#include <stddef.h> // Para size_t
#include <fstream> // Para basic_ifstream, basic_istream, basic...
#include <iostream> // Para cerr

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL3/SDL_stdinc.h> // Para Uint8
#include <memory> // Para unique_ptr, shared_ptr
#include <string> // Para string
#include "sprite.h" // Para Sprite

View File

@@ -1,6 +1,6 @@
#include "texture.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
#include <SDL3/SDL_error.h> // Para SDL_GetError
#include <SDL3/SDL_surface.h> // Para SDL_CreateRGBSurfaceWithFormatFrom
#include <stdint.h> // Para uint32_t
#include <cstring> // Para memcpy, size_t
#include <fstream> // Para basic_ostream, operator<<, basic_ifstream

View File

@@ -1,10 +1,10 @@
#pragma once
#include <SDL2/SDL_blendmode.h> // Para SDL_BlendMode
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888, SDL_PixelF...
#include <SDL2/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_FLIP_NONE, SDL_TEX...
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <SDL3/SDL_blendmode.h> // Para SDL_BlendMode
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888, SDL_PixelF...
#include <SDL3/SDL_rect.h> // Para SDL_Point, SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_FLIP_NONE, SDL_TEX...
#include <SDL3/SDL_stdinc.h> // Para Uint8, Uint16, Uint32
#include <memory> // Para shared_ptr
#include <string> // Para string
#include <vector> // Para vector

View File

@@ -1,5 +1,5 @@
#include "tiled_bg.h"
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL3/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // Para rand
#include <cmath> // Para sin
#include <memory> // Para unique_ptr, make_unique
@@ -81,7 +81,7 @@ void TiledBG::fillTexture()
// Pinta la clase en pantalla
void TiledBG::render()
{
SDL_RenderCopy(renderer_, canvas_, &window_, &pos_);
SDL_RenderTexture(renderer_, canvas_, &window_, &pos_);
}
// Actualiza la lógica de la clase

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include <SDL3/SDL_rect.h> // Para SDL_Rect
#include <SDL3/SDL_render.h> // Para SDL_Renderer, SDL_Texture
#include "utils.h"
// Modos de funcionamiento para el tileado de fondo

View File

@@ -1,7 +1,7 @@
#include "title.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL3/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL3/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5
#include <SDL3/SDL_timer.h> // Para SDL_GetTicks
#include <stddef.h> // Para size_t
#include <string> // Para char_traits, operator+, basic_string
#include <vector> // Para vector

View File

@@ -1,6 +1,6 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL3/SDL_stdinc.h> // Para Uint32
#include <memory> // Para unique_ptr, shared_ptr
#include "section.h" // Para Options
class DefineButtons; // lines 5-5

View File

@@ -1,5 +1,5 @@
#include "utils.h"
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <SDL3/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <stddef.h> // Para size_t
#include <algorithm> // Para min, clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace

View File

@@ -1,8 +1,8 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint8
#include <SDL3/SDL_rect.h> // Para SDL_Rect, SDL_Point
#include <SDL3/SDL_render.h> // Para SDL_Renderer
#include <SDL3/SDL_stdinc.h> // Para Uint8
#include <stdint.h> // Para int32_t
#include <algorithm> // Para max, min
#include <string> // Para string
@@ -116,7 +116,7 @@ struct Demo
// Posiciones dentro de un rectangulo
struct Zone
{
SDL_Rect rect; // Rectangulo que define la zona
SDL_FRect rect; // Rectangulo que define la zona
int center_x; // Anclaje al 50% del eje X
int first_quarter_x; // Anclaje al 25% del eje X
int third_quarter_x; // Anclaje al 75% del eje X