clang-format

This commit is contained in:
2026-03-21 23:19:15 +01:00
parent 55b58ded70
commit 366c00fd22
68 changed files with 5585 additions and 5603 deletions

View File

@@ -4,48 +4,48 @@
// Textos
namespace Texts {
constexpr const char* WINDOW_CAPTION = "© 2022 JailDoctor's Dilemma — JailDesigner";
constexpr const char* COPYRIGHT = "@2022 JailDesigner";
constexpr const char* VERSION = "1.10"; // Versión por defecto
constexpr const char* WINDOW_CAPTION = "© 2022 JailDoctor's Dilemma — JailDesigner";
constexpr const char* COPYRIGHT = "@2022 JailDesigner";
constexpr const char* VERSION = "1.10"; // Versión por defecto
} // namespace Texts
// Tamaño de bloque
namespace Tile {
constexpr int SIZE = 8;
constexpr int HALF_SIZE = SIZE / 2;
constexpr int SIZE = 8;
constexpr int HALF_SIZE = SIZE / 2;
} // namespace Tile
namespace PlayArea {
constexpr int TOP = (0 * Tile::SIZE);
constexpr int BOTTOM = (16 * Tile::SIZE);
constexpr int LEFT = (0 * Tile::SIZE);
constexpr int RIGHT = (32 * Tile::SIZE);
constexpr int WIDTH = RIGHT - LEFT;
constexpr int HEIGHT = BOTTOM - TOP;
constexpr int CENTER_X = LEFT + (WIDTH / 2);
constexpr int CENTER_FIRST_QUARTER_X = (WIDTH / 4);
constexpr int CENTER_THIRD_QUARTER_X = (WIDTH / 4) * 3;
constexpr int CENTER_Y = TOP + (HEIGHT / 2);
constexpr int FIRST_QUARTER_Y = HEIGHT / 4;
constexpr int THIRD_QUARTER_Y = (HEIGHT / 4) * 3;
constexpr int TOP = (0 * Tile::SIZE);
constexpr int BOTTOM = (16 * Tile::SIZE);
constexpr int LEFT = (0 * Tile::SIZE);
constexpr int RIGHT = (32 * Tile::SIZE);
constexpr int WIDTH = RIGHT - LEFT;
constexpr int HEIGHT = BOTTOM - TOP;
constexpr int CENTER_X = LEFT + (WIDTH / 2);
constexpr int CENTER_FIRST_QUARTER_X = (WIDTH / 4);
constexpr int CENTER_THIRD_QUARTER_X = (WIDTH / 4) * 3;
constexpr int CENTER_Y = TOP + (HEIGHT / 2);
constexpr int FIRST_QUARTER_Y = HEIGHT / 4;
constexpr int THIRD_QUARTER_Y = (HEIGHT / 4) * 3;
} // namespace PlayArea
namespace GameCanvas {
constexpr int WIDTH = 256;
constexpr int HEIGHT = 192;
constexpr int CENTER_X = WIDTH / 2;
constexpr int FIRST_QUARTER_X = WIDTH / 4;
constexpr int THIRD_QUARTER_X = (WIDTH / 4) * 3;
constexpr int CENTER_Y = HEIGHT / 2;
constexpr int FIRST_QUARTER_Y = HEIGHT / 4;
constexpr int THIRD_QUARTER_Y = (HEIGHT / 4) * 3;
constexpr int WIDTH = 256;
constexpr int HEIGHT = 192;
constexpr int CENTER_X = WIDTH / 2;
constexpr int FIRST_QUARTER_X = WIDTH / 4;
constexpr int THIRD_QUARTER_X = (WIDTH / 4) * 3;
constexpr int CENTER_Y = HEIGHT / 2;
constexpr int FIRST_QUARTER_Y = HEIGHT / 4;
constexpr int THIRD_QUARTER_Y = (HEIGHT / 4) * 3;
} // namespace GameCanvas
namespace Collision {
constexpr int NONE = -1;
constexpr int NONE = -1;
} // namespace Collision
namespace Flip {
constexpr SDL_FlipMode LEFT = SDL_FLIP_HORIZONTAL;
constexpr SDL_FlipMode RIGHT = SDL_FLIP_NONE;
constexpr SDL_FlipMode LEFT = SDL_FLIP_HORIZONTAL;
constexpr SDL_FlipMode RIGHT = SDL_FLIP_NONE;
} // namespace Flip

View File

@@ -5,24 +5,24 @@
#include <algorithm>
class DeltaTimer {
public:
DeltaTimer() noexcept;
public:
DeltaTimer() noexcept;
// Calcula delta en segundos y actualiza el contador interno
auto tick() noexcept -> float;
// Calcula delta en segundos y actualiza el contador interno
auto tick() noexcept -> float;
// Devuelve el delta estimado desde el último tick sin actualizar el contador
[[nodiscard]] auto peek() const noexcept -> float;
// Devuelve el delta estimado desde el último tick sin actualizar el contador
[[nodiscard]] auto peek() const noexcept -> float;
// Reinicia el contador al valor actual o al valor pasado (en performance counter ticks)
void reset(Uint64 counter = 0) noexcept;
// Reinicia el contador al valor actual o al valor pasado (en performance counter ticks)
void reset(Uint64 counter = 0) noexcept;
// Escala el tiempo retornado por tick/peek, por defecto 1.0f
void setTimeScale(float scale) noexcept;
[[nodiscard]] auto getTimeScale() const noexcept -> float;
// Escala el tiempo retornado por tick/peek, por defecto 1.0f
void setTimeScale(float scale) noexcept;
[[nodiscard]] auto getTimeScale() const noexcept -> float;
private:
Uint64 last_counter_;
double perf_freq_;
float time_scale_;
private:
Uint64 last_counter_;
double perf_freq_;
float time_scale_;
};

View File

@@ -22,230 +22,230 @@
namespace Easing {
// LINEAR
inline auto linear(float t) -> float {
return t;
}
// QUAD (Cuadrática: t^2)
inline auto quadIn(float t) -> float {
return t * t;
}
inline auto quadOut(float t) -> float {
return t * (2.0F - t);
}
inline auto quadInOut(float t) -> float {
if (t < 0.5F) {
return 2.0F * t * t;
}
return -1.0F + ((4.0F - 2.0F * t) * t);
}
// CUBIC (Cúbica: t^3)
inline auto cubicIn(float t) -> float {
return t * t * t;
}
inline auto cubicOut(float t) -> float {
const float F = t - 1.0F;
return (F * F * F) + 1.0F;
}
inline auto cubicInOut(float t) -> float {
if (t < 0.5F) {
return 4.0F * t * t * t;
}
const float F = ((2.0F * t) - 2.0F);
return (0.5F * F * F * F) + 1.0F;
}
// QUART (Cuártica: t^4)
inline auto quartIn(float t) -> float {
return t * t * t * t;
}
inline auto quartOut(float t) -> float {
const float F = t - 1.0F;
return 1.0F - (F * F * F * F);
}
inline auto quartInOut(float t) -> float {
if (t < 0.5F) {
return 8.0F * t * t * t * t;
}
const float F = t - 1.0F;
return 1.0F - (8.0F * F * F * F * F);
}
// QUINT (Quíntica: t^5)
inline auto quintIn(float t) -> float {
return t * t * t * t * t;
}
inline auto quintOut(float t) -> float {
const float F = t - 1.0F;
return (F * F * F * F * F) + 1.0F;
}
inline auto quintInOut(float t) -> float {
if (t < 0.5F) {
return 16.0F * t * t * t * t * t;
}
const float F = ((2.0F * t) - 2.0F);
return (0.5F * F * F * F * F * F) + 1.0F;
}
// SINE (Sinusoidal)
inline auto sineIn(float t) -> float {
return 1.0F - std::cos(t * std::numbers::pi_v<float> * 0.5F);
}
inline auto sineOut(float t) -> float {
return std::sin(t * std::numbers::pi_v<float> * 0.5F);
}
inline auto sineInOut(float t) -> float {
return 0.5F * (1.0F - std::cos(std::numbers::pi_v<float> * t));
}
// EXPO (Exponencial)
inline auto expoIn(float t) -> float {
if (t == 0.0F) {
return 0.0F;
}
return std::pow(2.0F, 10.0F * (t - 1.0F));
}
inline auto expoOut(float t) -> float {
if (t == 1.0F) {
return 1.0F;
}
return 1.0F - std::pow(2.0F, -10.0F * t);
}
inline auto expoInOut(float t) -> float {
if (t == 0.0F || t == 1.0F) {
// LINEAR
inline auto linear(float t) -> float {
return t;
}
if (t < 0.5F) {
return 0.5F * std::pow(2.0F, (20.0F * t) - 10.0F);
}
return 0.5F * (2.0F - std::pow(2.0F, (-20.0F * t) + 10.0F));
}
// CIRC (Circular)
inline auto circIn(float t) -> float {
return 1.0F - std::sqrt(1.0F - (t * t));
}
inline auto circOut(float t) -> float {
const float F = t - 1.0F;
return std::sqrt(1.0F - (F * F));
}
inline auto circInOut(float t) -> float {
if (t < 0.5F) {
return 0.5F * (1.0F - std::sqrt(1.0F - (4.0F * t * t)));
}
const float F = (2.0F * t) - 2.0F;
return 0.5F * (std::sqrt(1.0F - (F * F)) + 1.0F);
}
// BACK (Overshoot - retrocede antes de avanzar)
inline auto backIn(float t, float overshoot = 1.70158F) -> float {
return t * t * ((overshoot + 1.0F) * t - overshoot);
}
inline auto backOut(float t, float overshoot = 1.70158F) -> float {
const float F = t - 1.0F;
return (F * F * ((overshoot + 1.0F) * F + overshoot)) + 1.0F;
}
inline auto backInOut(float t, float overshoot = 1.70158F) -> float {
const float S = overshoot * 1.525F;
if (t < 0.5F) {
const float F = 2.0F * t;
return 0.5F * (F * F * ((S + 1.0F) * F - S));
// QUAD (Cuadrática: t^2)
inline auto quadIn(float t) -> float {
return t * t;
}
const float F = (2.0F * t) - 2.0F;
return 0.5F * (F * F * ((S + 1.0F) * F + S) + 2.0F);
}
// ELASTIC (Oscilación elástica - efecto de resorte)
inline auto elasticIn(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
inline auto quadOut(float t) -> float {
return t * (2.0F - t);
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
const float F = t - 1.0F;
return -(amplitude * std::pow(2.0F, 10.0F * F) *
std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period));
}
inline auto elasticOut(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
inline auto quadInOut(float t) -> float {
if (t < 0.5F) {
return 2.0F * t * t;
}
return -1.0F + ((4.0F - 2.0F * t) * t);
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
return (amplitude * std::pow(2.0F, -10.0F * t) *
std::sin((t - S) * (2.0F * std::numbers::pi_v<float>) / period)) +
1.0F;
}
inline auto elasticInOut(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
// CUBIC (Cúbica: t^3)
inline auto cubicIn(float t) -> float {
return t * t * t;
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
inline auto cubicOut(float t) -> float {
const float F = t - 1.0F;
return (F * F * F) + 1.0F;
}
inline auto cubicInOut(float t) -> float {
if (t < 0.5F) {
return 4.0F * t * t * t;
}
const float F = ((2.0F * t) - 2.0F);
return (0.5F * F * F * F) + 1.0F;
}
// QUART (Cuártica: t^4)
inline auto quartIn(float t) -> float {
return t * t * t * t;
}
inline auto quartOut(float t) -> float {
const float F = t - 1.0F;
return 1.0F - (F * F * F * F);
}
inline auto quartInOut(float t) -> float {
if (t < 0.5F) {
return 8.0F * t * t * t * t;
}
const float F = t - 1.0F;
return 1.0F - (8.0F * F * F * F * F);
}
// QUINT (Quíntica: t^5)
inline auto quintIn(float t) -> float {
return t * t * t * t * t;
}
inline auto quintOut(float t) -> float {
const float F = t - 1.0F;
return (F * F * F * F * F) + 1.0F;
}
inline auto quintInOut(float t) -> float {
if (t < 0.5F) {
return 16.0F * t * t * t * t * t;
}
const float F = ((2.0F * t) - 2.0F);
return (0.5F * F * F * F * F * F) + 1.0F;
}
// SINE (Sinusoidal)
inline auto sineIn(float t) -> float {
return 1.0F - std::cos(t * std::numbers::pi_v<float> * 0.5F);
}
inline auto sineOut(float t) -> float {
return std::sin(t * std::numbers::pi_v<float> * 0.5F);
}
inline auto sineInOut(float t) -> float {
return 0.5F * (1.0F - std::cos(std::numbers::pi_v<float> * t));
}
// EXPO (Exponencial)
inline auto expoIn(float t) -> float {
if (t == 0.0F) {
return 0.0F;
}
return std::pow(2.0F, 10.0F * (t - 1.0F));
}
inline auto expoOut(float t) -> float {
if (t == 1.0F) {
return 1.0F;
}
return 1.0F - std::pow(2.0F, -10.0F * t);
}
inline auto expoInOut(float t) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
}
if (t < 0.5F) {
return 0.5F * std::pow(2.0F, (20.0F * t) - 10.0F);
}
return 0.5F * (2.0F - std::pow(2.0F, (-20.0F * t) + 10.0F));
}
// CIRC (Circular)
inline auto circIn(float t) -> float {
return 1.0F - std::sqrt(1.0F - (t * t));
}
inline auto circOut(float t) -> float {
const float F = t - 1.0F;
return std::sqrt(1.0F - (F * F));
}
inline auto circInOut(float t) -> float {
if (t < 0.5F) {
return 0.5F * (1.0F - std::sqrt(1.0F - (4.0F * t * t)));
}
const float F = (2.0F * t) - 2.0F;
return 0.5F * (std::sqrt(1.0F - (F * F)) + 1.0F);
}
// BACK (Overshoot - retrocede antes de avanzar)
inline auto backIn(float t, float overshoot = 1.70158F) -> float {
return t * t * ((overshoot + 1.0F) * t - overshoot);
}
inline auto backOut(float t, float overshoot = 1.70158F) -> float {
const float F = t - 1.0F;
return (F * F * ((overshoot + 1.0F) * F + overshoot)) + 1.0F;
}
inline auto backInOut(float t, float overshoot = 1.70158F) -> float {
const float S = overshoot * 1.525F;
if (t < 0.5F) {
const float F = 2.0F * t;
return 0.5F * (F * F * ((S + 1.0F) * F - S));
}
const float F = (2.0F * t) - 2.0F;
return 0.5F * (F * F * ((S + 1.0F) * F + S) + 2.0F);
}
// ELASTIC (Oscilación elástica - efecto de resorte)
inline auto elasticIn(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
const float F = t - 1.0F;
return -(amplitude * std::pow(2.0F, 10.0F * F) *
std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period));
}
inline auto elasticOut(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
return (amplitude * std::pow(2.0F, -10.0F * t) *
std::sin((t - S) * (2.0F * std::numbers::pi_v<float>) / period)) +
1.0F;
}
inline auto elasticInOut(float t, float amplitude = 1.0F, float period = 0.3F) -> float {
if (t == 0.0F || t == 1.0F) {
return t;
}
const float S = period / (2.0F * std::numbers::pi_v<float>)*std::asin(1.0F / amplitude);
if (t < 0.5F) {
const float F = (2.0F * t) - 1.0F;
return -0.5F * (amplitude * std::pow(2.0F, 10.0F * F) * std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period));
}
if (t < 0.5F) {
const float F = (2.0F * t) - 1.0F;
return -0.5F * (amplitude * std::pow(2.0F, 10.0F * F) * std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period));
return (0.5F * amplitude * std::pow(2.0F, -10.0F * F) *
std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period)) +
1.0F;
}
const float F = (2.0F * t) - 1.0F;
return (0.5F * amplitude * std::pow(2.0F, -10.0F * F) *
std::sin((F - S) * (2.0F * std::numbers::pi_v<float>) / period)) +
1.0F;
}
// BOUNCE (Rebote - simula física de rebote)
inline auto bounceOut(float t) -> float {
const float N1 = 7.5625F;
const float D1 = 2.75F;
// BOUNCE (Rebote - simula física de rebote)
inline auto bounceOut(float t) -> float {
const float N1 = 7.5625F;
const float D1 = 2.75F;
if (t < 1.0F / D1) {
return N1 * t * t;
}
if (t < 2.0F / D1) {
const float F = t - (1.5F / D1);
return (N1 * F * F) + 0.75F;
}
if (t < 2.5F / D1) {
const float F = t - (2.25F / D1);
return (N1 * F * F) + 0.9375F;
}
const float F = t - (2.625F / D1);
return (N1 * F * F) + 0.984375F;
}
if (t < 1.0F / D1) {
return N1 * t * t;
inline auto bounceIn(float t) -> float {
return 1.0F - bounceOut(1.0F - t);
}
if (t < 2.0F / D1) {
const float F = t - (1.5F / D1);
return (N1 * F * F) + 0.75F;
}
if (t < 2.5F / D1) {
const float F = t - (2.25F / D1);
return (N1 * F * F) + 0.9375F;
}
const float F = t - (2.625F / D1);
return (N1 * F * F) + 0.984375F;
}
inline auto bounceIn(float t) -> float {
return 1.0F - bounceOut(1.0F - t);
}
inline auto bounceInOut(float t) -> float {
if (t < 0.5F) {
return 0.5F * bounceIn(2.0F * t);
inline auto bounceInOut(float t) -> float {
if (t < 0.5F) {
return 0.5F * bounceIn(2.0F * t);
}
return (0.5F * bounceOut((2.0F * t) - 1.0F)) + 0.5F;
}
return (0.5F * bounceOut((2.0F * t) - 1.0F)) + 0.5F;
}
} // namespace Easing

View File

@@ -35,42 +35,42 @@ enum class PaletteColor : Uint8 {
// Estructura para definir un circulo
struct Circle {
int x{0};
int y{0};
int r{0};
int x{0};
int y{0};
int r{0};
};
// Estructura para definir una linea horizontal
struct LineHorizontal {
int x1{0}, x2{0}, y{0};
int x1{0}, x2{0}, y{0};
};
// Estructura para definir una linea vertical
struct LineVertical {
int x{0}, y1{0}, y2{0};
int x{0}, y1{0}, y2{0};
};
// Estructura para definir una linea diagonal
struct LineDiagonal {
int x1{0}, y1{0}, x2{0}, y2{0};
int x1{0}, y1{0}, x2{0}, y2{0};
};
// Estructura para definir una linea
struct Line {
int x1{0}, y1{0}, x2{0}, y2{0};
int x1{0}, y1{0}, x2{0}, y2{0};
};
// Estructura para definir un color
struct Color {
Uint8 r{0};
Uint8 g{0};
Uint8 b{0};
Uint8 r{0};
Uint8 g{0};
Uint8 b{0};
// Constructor
Color(Uint8 red, Uint8 green, Uint8 blue)
: r(red),
g(green),
b(blue) {}
// Constructor
Color(Uint8 red, Uint8 green, Uint8 blue)
: r(red),
g(green),
b(blue) {}
};
// COLISIONES Y GEOMETRÍA