Commitet pa valgrind, he aprofitat i posat mes make_unique i enum class

This commit is contained in:
2024-10-07 10:49:29 +02:00
parent 4f0ea9dcf2
commit cffa4c3c92
8 changed files with 105 additions and 107 deletions

View File

@@ -1,19 +1,25 @@
#pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16
#include <vector> // for vector
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16
#include <vector> // for vector
// Tipos de fundido
#define FADE_FULLSCREEN 0
#define FADE_CENTER 1
#define FADE_RANDOM_SQUARE 2
#define FADE_VENETIAN 3
enum class fadeType
{
FULLSCREEN = 0,
CENTER = 1,
RANDOM_SQUARE = 2,
VENETIAN = 3,
};
// Modos de fundido
#define FADE_IN 0
#define FADE_OUT 1
enum class fadeMode
{
IN = 0,
OUT = 1,
};
// Clase Fade
class Fade
@@ -24,17 +30,17 @@ private:
SDL_Texture *backbuffer; // Textura para usar como backbuffer con SDL_TEXTUREACCESS_TARGET
// Variables
Uint8 type; // Tipo de fade a realizar
Uint8 mode; // Modo de fade a realizar
fadeType type; // Tipo de fade a realizar
fadeMode mode; // Modo de fade a realizar
Uint16 counter; // Contador interno
bool enabled; // Indica si el fade está activo
bool finished; // Indica si ha terminado la transición
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
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FADE_RANDOM_SQUARE
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FADE_RANDOM_SQUARE
std::vector<SDL_Rect> square; // Vector con los indices de los cuadrados para el FADE_RANDOM_SQUARE
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el fadeType::RANDOM_SQUARE
int numSquaresHeight; // 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
int fadeRandomSquaresDelay; // Duración entre cada pintado de cuadrados
int fadeRandomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
int postDuration; // Duración posterior del fade tras finalizar
@@ -44,7 +50,7 @@ private:
void init();
// Limpia el backbuffer
void cleanBackbuffer(int r, int g, int b, int a);
void cleanBackbuffer(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
public:
// Constructor
@@ -66,16 +72,16 @@ public:
void activate();
// Comprueba si ha terminado la transicion
bool hasEnded();
bool hasEnded() const;
// Comprueba si está activo
bool isEnabled();
bool isEnabled() const;
// Establece el tipo de fade
void setType(Uint8 type);
void setType(fadeType type);
// Establece el modo de fade
void setMode(Uint8 mode);
void setMode(fadeMode mode);
// Establece el color del fade
void setColor(Uint8 r, Uint8 g, Uint8 b);