Lint: rename públicos al inglés + refactor cognitive-complexity + unused-includes
Identifier-naming: rename de métodos públicos y cross-file al inglés
(camelBack), traducción de campos y locales en el proceso (TitleShip,
StageManager, SpawnController, ShipAnimator, helpers de PlayArea, etc.).
Refactor por cognitive-complexity (>25): GameScene::draw (59→3) con 9
helpers de estado, PhysicsWorld::resolveBodyCollisions (35→5) extrayendo
resolveBodyPair, Options::load{Window,Physics,Audio}ConfigFromYaml
(32/49/57→5/2/3) con templates readField, TitleScene::update (68→4) con
5 sub-pasos por estado + handleSkipInput/handleStartInput +
triggerExitForJoinedPlayers, DebrisManager::explode (39→3) con
extractSegments/spawnDebris/applyAngularVelocity/applyVisualRotation.
use-anyofallof: bucles → std::ranges::any_of/all_of en Input,
ShipAnimator y SpawnController.
readability-static-accessed-through-instance: Director::run y
VectorText::getTextWidth/Height invocados por clase.
readability-convert-member-functions-to-static: ResourcePack::decryptData.
unused-includes: eliminación de <utility>, <cstdint>, <vector>,
<iostream>, defaults.hpp y otros no usados directamente en headers y
unidades de traducción. Restablecido core/defaults.hpp en title_scene.cpp
(falsa "unused" del header).
Bug fix: eliminado isActive() duplicado en Bullet (redeclaración tras
rename de esta_activa→isActive que chocaba con el override de Entity).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,6 @@
|
||||
#include <functional> // Para std::function
|
||||
#include <memory> // Para std::unique_ptr
|
||||
#include <string> // Para string
|
||||
#include <utility> // Para move
|
||||
|
||||
// Forward-declares per no incloure core/audio/jail_audio.hpp al header. Els
|
||||
// tres símbols (Music/Sound para el punter que exposa la API i Engine per al
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <numbers>
|
||||
|
||||
namespace Defaults {
|
||||
@@ -439,16 +438,16 @@ constexpr float CENTER_Y = Game::HEIGHT / 2.0F; // auto-derivado de Game::HEIGH
|
||||
// Posicions target (calculades dinàmicament des dels parámetros base)
|
||||
// Nota: std::cos/sin no són constexpr en C++20, pero funcionen en runtime
|
||||
// Les funciones inline són optimitzades por el compilador (zero overhead)
|
||||
inline auto P1_TARGET_X() -> float {
|
||||
inline auto p1TargetX() -> float {
|
||||
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_8_ANGLE));
|
||||
}
|
||||
inline auto P1_TARGET_Y() -> float {
|
||||
inline auto p1TargetY() -> float {
|
||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||
}
|
||||
inline auto P2_TARGET_X() -> float {
|
||||
inline auto p2TargetX() -> float {
|
||||
return CENTER_X + (CLOCK_RADIUS * std::cos(CLOCK_4_ANGLE));
|
||||
}
|
||||
inline auto P2_TARGET_Y() -> float {
|
||||
inline auto p2TargetY() -> float {
|
||||
return CENTER_Y + ((Game::HEIGHT / 2.0F) * TARGET_Y_RATIO);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,11 @@ class Shape {
|
||||
auto parseFile(const std::string& contingut) -> bool;
|
||||
|
||||
// Getters
|
||||
[[nodiscard]] auto get_primitives() const -> const std::vector<ShapePrimitive>& {
|
||||
[[nodiscard]] auto getPrimitives() const -> const std::vector<ShapePrimitive>& {
|
||||
return primitives_;
|
||||
}
|
||||
[[nodiscard]] auto getCenter() const -> const Vec2& { return center_; }
|
||||
[[nodiscard]] auto get_escala_defecte() const -> float { return escala_defecte_; }
|
||||
[[nodiscard]] auto getDefaultScale() const -> float { return escala_defecte_; }
|
||||
[[nodiscard]] auto isValid() const -> bool { return !primitives_.empty(); }
|
||||
|
||||
// Info de depuració
|
||||
|
||||
@@ -10,13 +10,12 @@
|
||||
namespace Graphics {
|
||||
|
||||
// Inicialización de variables estàtiques
|
||||
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache_;
|
||||
std::string ShapeLoader::base_path_ = "data/shapes/";
|
||||
std::unordered_map<std::string, std::shared_ptr<Shape>> ShapeLoader::cache;
|
||||
|
||||
auto ShapeLoader::load(const std::string& filename) -> std::shared_ptr<Shape> {
|
||||
// Check cache first
|
||||
auto it = cache_.find(filename);
|
||||
if (it != cache_.end()) {
|
||||
auto it = cache.find(filename);
|
||||
if (it != cache.end()) {
|
||||
std::cout << "[ShapeLoader] Cache hit: " << filename << '\n';
|
||||
return it->second; // Cache hit
|
||||
}
|
||||
@@ -56,17 +55,17 @@ auto ShapeLoader::load(const std::string& filename) -> std::shared_ptr<Shape> {
|
||||
std::cout << "[ShapeLoader] Carregat: " << normalized << " (" << shape->getName()
|
||||
<< ", " << shape->getNumPrimitives() << " primitives)" << '\n';
|
||||
|
||||
cache_[filename] = shape;
|
||||
cache[filename] = shape;
|
||||
return shape;
|
||||
}
|
||||
|
||||
void ShapeLoader::clear_cache() {
|
||||
std::cout << "[ShapeLoader] Netejant caché (" << cache_.size() << " formes)"
|
||||
void ShapeLoader::clearCache() {
|
||||
std::cout << "[ShapeLoader] Netejant caché (" << cache.size() << " formes)"
|
||||
<< '\n';
|
||||
cache_.clear();
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
auto ShapeLoader::get_cache_size() -> size_t { return cache_.size(); }
|
||||
auto ShapeLoader::getCacheSize() -> size_t { return cache.size(); }
|
||||
|
||||
auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||
// Si es un path absolut (comença con '/'), usar-lo directament
|
||||
@@ -75,12 +74,12 @@ auto ShapeLoader::resolvePath(const std::string& filename) -> std::string {
|
||||
}
|
||||
|
||||
// Si ya conté el prefix base_path, usar-lo directament
|
||||
if (filename.starts_with(base_path_)) {
|
||||
if (filename.starts_with(BASE_PATH)) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
// Altrament, añadir base_path (ara suporta subdirectoris)
|
||||
return base_path_ + filename;
|
||||
return std::string(BASE_PATH) + filename;
|
||||
}
|
||||
|
||||
} // namespace Graphics
|
||||
|
||||
@@ -23,14 +23,14 @@ class ShapeLoader {
|
||||
static auto load(const std::string& filename) -> std::shared_ptr<Shape>;
|
||||
|
||||
// Netejar caché (útil per debug/recàrrega)
|
||||
static void clear_cache();
|
||||
static void clearCache();
|
||||
|
||||
// Estadístiques (debug)
|
||||
static auto get_cache_size() -> size_t;
|
||||
static auto getCacheSize() -> size_t;
|
||||
|
||||
private:
|
||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache_;
|
||||
static std::string base_path_; // "data/shapes/"
|
||||
static std::unordered_map<std::string, std::shared_ptr<Shape>> cache;
|
||||
static constexpr const char* BASE_PATH = "data/shapes/";
|
||||
|
||||
// Helpers privats
|
||||
static auto resolvePath(const std::string& filename) -> std::string;
|
||||
|
||||
@@ -137,7 +137,7 @@ void Starfield::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Establir multiplicador de brightness
|
||||
void Starfield::set_brightness(float multiplier) {
|
||||
void Starfield::setBrightness(float multiplier) {
|
||||
multiplicador_brightness_ = std::max(0.0F, multiplier); // Evitar valors negatius
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ void Starfield::draw() {
|
||||
float brightness = computeBrightness(estrella);
|
||||
|
||||
// Renderizar estrella sin rotación
|
||||
Rendering::render_shape(
|
||||
Rendering::renderShape(
|
||||
renderer_,
|
||||
shape_estrella_,
|
||||
estrella.position,
|
||||
|
||||
@@ -43,8 +43,8 @@ class Starfield {
|
||||
void draw();
|
||||
|
||||
// Setters per ajustar parámetros en time real
|
||||
void set_punt_fuga(const Vec2& point) { punt_fuga_ = point; }
|
||||
void set_brightness(float multiplier);
|
||||
void setVanishingPoint(const Vec2& point) { punt_fuga_ = point; }
|
||||
void setBrightness(float multiplier);
|
||||
|
||||
private:
|
||||
// Estructura interna per cada estrella
|
||||
|
||||
@@ -175,7 +175,7 @@ auto VectorText::getShapeFilename(char c) -> std::string {
|
||||
}
|
||||
}
|
||||
|
||||
auto VectorText::is_supported(char c) const -> bool {
|
||||
auto VectorText::isSupported(char c) const -> bool {
|
||||
return chars_.contains(c);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
// Ajustar X e Y para que position represente esquina superior izquierda
|
||||
// (render_shape espera el centro, así que sumamos la mitad de ancho y altura)
|
||||
Vec2 char_pos = {.x = current_x + (CHAR_WIDTH_SCALED / 2.0F), .y = position.y + (CHAR_HEIGHT_SCALED / 2.0F)};
|
||||
Rendering::render_shape(renderer_, it->second, char_pos, 0.0F, scale, 1.0F, brightness);
|
||||
Rendering::renderShape(renderer_, it->second, char_pos, 0.0F, scale, 1.0F, brightness);
|
||||
|
||||
// Avanzar posición
|
||||
current_x += CHAR_WIDTH_SCALED + SPACING_SCALED;
|
||||
@@ -236,8 +236,8 @@ void VectorText::render(const std::string& text, const Vec2& position, float sca
|
||||
|
||||
void VectorText::renderCentered(const std::string& text, const Vec2& centre_punt, float scale, float spacing, float brightness) const {
|
||||
// Calcular dimensions del text
|
||||
float text_width = get_text_width(text, scale, spacing);
|
||||
float text_height = get_text_height(scale);
|
||||
float text_width = getTextWidth(text, scale, spacing);
|
||||
float text_height = getTextHeight(scale);
|
||||
|
||||
// Calcular posición de l'esquina superior izquierda
|
||||
// restant la meitat de las dimensions del point central
|
||||
@@ -249,7 +249,7 @@ void VectorText::renderCentered(const std::string& text, const Vec2& centre_punt
|
||||
render(text, posicio_esquerra, scale, spacing, brightness);
|
||||
}
|
||||
|
||||
auto VectorText::get_text_width(const std::string& text, float scale, float spacing) -> float {
|
||||
auto VectorText::getTextWidth(const std::string& text, float scale, float spacing) -> float {
|
||||
if (text.empty()) {
|
||||
return 0.0F;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ auto VectorText::get_text_width(const std::string& text, float scale, float spac
|
||||
return (visual_chars * CHAR_WIDTH_SCALED) + ((visual_chars - 1) * SPACING_SCALED);
|
||||
}
|
||||
|
||||
auto VectorText::get_text_height(float scale) -> float {
|
||||
auto VectorText::getTextHeight(float scale) -> float {
|
||||
return BASE_CHAR_HEIGHT * scale;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ class VectorText {
|
||||
// Calcular ancho total de un string (útil para centrado).
|
||||
// Es estático: no depende del estado del VectorText (el ancho viene de
|
||||
// las constantes BASE_CHAR_WIDTH/BASE_CHAR_HEIGHT del archivo .cpp).
|
||||
[[nodiscard]] static auto get_text_width(const std::string& text, float scale = 1.0F, float spacing = 2.0F) -> float;
|
||||
[[nodiscard]] static auto getTextWidth(const std::string& text, float scale = 1.0F, float spacing = 2.0F) -> float;
|
||||
|
||||
// Calcular altura del texto (útil para centrado vertical).
|
||||
[[nodiscard]] static auto get_text_height(float scale = 1.0F) -> float;
|
||||
[[nodiscard]] static auto getTextHeight(float scale = 1.0F) -> float;
|
||||
|
||||
// Verificar si un carácter está soportado
|
||||
[[nodiscard]] auto is_supported(char c) const -> bool;
|
||||
[[nodiscard]] auto isSupported(char c) const -> bool;
|
||||
|
||||
private:
|
||||
Rendering::Renderer* renderer_;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <SDL3/SDL.h> // Para SDL_GetGamepadAxis, SDL_GamepadAxis, SDL_GamepadButton, SDL_GetError, SDL_JoystickID, SDL_AddGamepadMappingsFromFile, SDL_Event, SDL_EventType, SDL_GetGamepadButton, SDL_GetKeyboardState, SDL_INIT_GAMEPAD, SDL_InitSubSystem, SDL_LogError, SDL_OpenGamepad, SDL_PollEvent, SDL_WasInit, Sint16, SDL_Gamepad, SDL_LogCategory, SDL_Scancode
|
||||
|
||||
#include <algorithm> // Para std::ranges::any_of
|
||||
#include <iostream> // Para basic_ostream, operator<<, cout, cerr
|
||||
#include <memory> // Para shared_ptr, __shared_ptr_access, allocator, operator==, make_shared
|
||||
#include <ranges> // Para __find_if_fn, find_if
|
||||
#include <unordered_map> // Para unordered_map, _Node_iterator, operator==, _Node_iterator_base, _Node_const_iterator
|
||||
#include <utility> // Para pair, move
|
||||
#include <utility> // Para move
|
||||
|
||||
#include "game/options.hpp" // Para Options::controls
|
||||
|
||||
@@ -190,12 +190,9 @@ auto Input::checkAnyButton(bool repeat) -> bool {
|
||||
|
||||
// Comprueba si algún player (P1 o P2) presionó alguna acción de una lista
|
||||
auto Input::checkAnyPlayerAction(const std::span<const InputAction>& actions, bool repeat) -> bool {
|
||||
for (const auto& action : actions) {
|
||||
if (checkActionPlayer1(action, repeat) || checkActionPlayer2(action, repeat)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return std::ranges::any_of(actions, [this, repeat](const InputAction& action) {
|
||||
return checkActionPlayer1(action, repeat) || checkActionPlayer2(action, repeat);
|
||||
});
|
||||
}
|
||||
|
||||
// Comprueba si hay algun mando conectado
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <span> // Para span
|
||||
#include <string> // Para string, basic_string
|
||||
#include <unordered_map> // Para unordered_map
|
||||
#include <utility> // Para pair
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/input/input_types.hpp" // for InputAction
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "input_types.hpp"
|
||||
|
||||
#include <utility> // Para pair
|
||||
|
||||
// Definición de los mapas
|
||||
const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
|
||||
{InputAction::LEFT, "LEFT"},
|
||||
|
||||
@@ -8,21 +8,21 @@ namespace Easing {
|
||||
// Ease-out quadratic: empieza rápido, desacelera suavemente
|
||||
// t = progreso normalizado [0.0 - 1.0]
|
||||
// retorna value interpolado [0.0 - 1.0]
|
||||
inline auto ease_out_quad(float t) -> float {
|
||||
inline auto easeOutQuad(float t) -> float {
|
||||
return 1.0F - ((1.0F - t) * (1.0F - t));
|
||||
}
|
||||
|
||||
// Ease-in quadratic: empieza lento, acelera
|
||||
// t = progreso normalizado [0.0 - 1.0]
|
||||
// retorna value interpolado [0.0 - 1.0]
|
||||
inline auto ease_in_quad(float t) -> float {
|
||||
inline auto easeInQuad(float t) -> float {
|
||||
return t * t;
|
||||
}
|
||||
|
||||
// Ease-in-out quadratic: acelera al inicio, desacelera al final
|
||||
// t = progreso normalizado [0.0 - 1.0]
|
||||
// retorna value interpolado [0.0 - 1.0]
|
||||
inline auto ease_in_out_quad(float t) -> float {
|
||||
inline auto easeInOutQuad(float t) -> float {
|
||||
return (t < 0.5F)
|
||||
? 2.0F * t * t
|
||||
: 1.0F - ((-2.0F * t + 2.0F) * (-2.0F * t + 2.0F) / 2.0F);
|
||||
@@ -31,7 +31,7 @@ inline auto ease_in_out_quad(float t) -> float {
|
||||
// Ease-out cubic: desaceleración más suave que quadratic
|
||||
// t = progreso normalizado [0.0 - 1.0]
|
||||
// retorna value interpolado [0.0 - 1.0]
|
||||
inline auto ease_out_cubic(float t) -> float {
|
||||
inline auto easeOutCubic(float t) -> float {
|
||||
float t1 = 1.0F - t;
|
||||
return 1.0F - (t1 * t1 * t1);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
namespace Physics {
|
||||
|
||||
// Comprobación genèrica de colisión entre dues entidades
|
||||
inline auto check_collision(const Entities::Entity& a, const Entities::Entity& b, float amplifier = 1.0F) -> bool {
|
||||
inline auto checkCollision(const Entities::Entity& a, const Entities::Entity& b, float amplifier = 1.0F) -> bool {
|
||||
// Comprovar si ambdós són col·lisionables
|
||||
if (!a.isCollidable() || !b.isCollidable()) {
|
||||
return false;
|
||||
|
||||
@@ -121,58 +121,61 @@ void PhysicsWorld::resolveBodyCollisions() {
|
||||
for (std::size_t j = i + 1; j < COUNT; ++j) {
|
||||
auto* a = bodies_[i];
|
||||
auto* b = bodies_[j];
|
||||
if (a == nullptr || b == nullptr) {
|
||||
continue;
|
||||
}
|
||||
// Dos cuerpos estáticos no necesitan resolución
|
||||
if (a->isStatic() && b->isStatic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const Vec2 DELTA = b->position - a->position;
|
||||
const float DIST_SQ = DELTA.lengthSquared();
|
||||
const float SUM_R = a->radius + b->radius;
|
||||
if (DIST_SQ > SUM_R * SUM_R || DIST_SQ <= 0.0F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const float DIST = std::sqrt(DIST_SQ);
|
||||
const Vec2 NORMAL = DELTA / DIST; // de A hacia B
|
||||
|
||||
// Corrección posicional (resolver penetración)
|
||||
const float PENETRATION = SUM_R - DIST;
|
||||
const float TOTAL_INV_MASS = a->inverse_mass + b->inverse_mass;
|
||||
if (TOTAL_INV_MASS > 0.0F) {
|
||||
const Vec2 CORRECTION = NORMAL * (PENETRATION / TOTAL_INV_MASS);
|
||||
if (!a->isStatic()) {
|
||||
a->position -= CORRECTION * a->inverse_mass;
|
||||
}
|
||||
if (!b->isStatic()) {
|
||||
b->position += CORRECTION * b->inverse_mass;
|
||||
}
|
||||
}
|
||||
|
||||
// Velocidad relativa proyectada sobre la normal
|
||||
const Vec2 V_REL = b->velocity - a->velocity;
|
||||
const float VEL_ALONG_NORMAL = V_REL.dot(NORMAL);
|
||||
// Si se están separando, no aplicar impulso
|
||||
if (VEL_ALONG_NORMAL > 0.0F) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Restitución promedio (Box2D usa max; promedio es más permisivo)
|
||||
const float E = (a->restitution + b->restitution) * 0.5F;
|
||||
const float J = -(1.0F + E) * VEL_ALONG_NORMAL / TOTAL_INV_MASS;
|
||||
const Vec2 IMPULSE = NORMAL * J;
|
||||
|
||||
if (!a->isStatic()) {
|
||||
a->velocity -= IMPULSE * a->inverse_mass;
|
||||
}
|
||||
if (!b->isStatic()) {
|
||||
b->velocity += IMPULSE * b->inverse_mass;
|
||||
if (a != nullptr && b != nullptr) {
|
||||
resolveBodyPair(*a, *b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsWorld::resolveBodyPair(RigidBody& a, RigidBody& b) {
|
||||
// Dos cuerpos estáticos no necesitan resolución
|
||||
if (a.isStatic() && b.isStatic()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const Vec2 DELTA = b.position - a.position;
|
||||
const float DIST_SQ = DELTA.lengthSquared();
|
||||
const float SUM_R = a.radius + b.radius;
|
||||
if (DIST_SQ > SUM_R * SUM_R || DIST_SQ <= 0.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float DIST = std::sqrt(DIST_SQ);
|
||||
const Vec2 NORMAL = DELTA / DIST; // de A hacia B
|
||||
|
||||
// Corrección posicional (resolver penetración)
|
||||
const float PENETRATION = SUM_R - DIST;
|
||||
const float TOTAL_INV_MASS = a.inverse_mass + b.inverse_mass;
|
||||
if (TOTAL_INV_MASS > 0.0F) {
|
||||
const Vec2 CORRECTION = NORMAL * (PENETRATION / TOTAL_INV_MASS);
|
||||
if (!a.isStatic()) {
|
||||
a.position -= CORRECTION * a.inverse_mass;
|
||||
}
|
||||
if (!b.isStatic()) {
|
||||
b.position += CORRECTION * b.inverse_mass;
|
||||
}
|
||||
}
|
||||
|
||||
// Velocidad relativa proyectada sobre la normal
|
||||
const Vec2 V_REL = b.velocity - a.velocity;
|
||||
const float VEL_ALONG_NORMAL = V_REL.dot(NORMAL);
|
||||
// Si se están separando, no aplicar impulso
|
||||
if (VEL_ALONG_NORMAL > 0.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Restitución promedio (Box2D usa max; promedio es más permisivo)
|
||||
const float E = (a.restitution + b.restitution) * 0.5F;
|
||||
const float J = -(1.0F + E) * VEL_ALONG_NORMAL / TOTAL_INV_MASS;
|
||||
const Vec2 IMPULSE = NORMAL * J;
|
||||
|
||||
if (!a.isStatic()) {
|
||||
a.velocity -= IMPULSE * a.inverse_mass;
|
||||
}
|
||||
if (!b.isStatic()) {
|
||||
b.velocity += IMPULSE * b.inverse_mass;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Physics
|
||||
|
||||
@@ -59,6 +59,9 @@ class PhysicsWorld {
|
||||
void integrate(float dt);
|
||||
void resolveBoundsCollisions();
|
||||
void resolveBodyCollisions();
|
||||
// Resol un únic parell (a, b): correcció posicional + impulso elàstic.
|
||||
// Estàtic: només toca els dos cossos rebuts, no consulta el world.
|
||||
static void resolveBodyPair(RigidBody& a, RigidBody& b);
|
||||
};
|
||||
|
||||
} // namespace Physics
|
||||
|
||||
@@ -11,21 +11,21 @@ namespace Rendering {
|
||||
extern float g_current_scale_factor;
|
||||
|
||||
// Transforma coordenada lógica a física con arrodoniment
|
||||
inline auto transform_x(int logical_x, float scale) -> int {
|
||||
inline auto transformX(int logical_x, float scale) -> int {
|
||||
return static_cast<int>(std::round(logical_x * scale));
|
||||
}
|
||||
|
||||
inline auto transform_y(int logical_y, float scale) -> int {
|
||||
inline auto transformY(int logical_y, float scale) -> int {
|
||||
return static_cast<int>(std::round(logical_y * scale));
|
||||
}
|
||||
|
||||
// Variant que usa el factor de scale global
|
||||
inline auto transform_x(int logical_x) -> int {
|
||||
return transform_x(logical_x, g_current_scale_factor);
|
||||
inline auto transformX(int logical_x) -> int {
|
||||
return transformX(logical_x, g_current_scale_factor);
|
||||
}
|
||||
|
||||
inline auto transform_y(int logical_y) -> int {
|
||||
return transform_y(logical_y, g_current_scale_factor);
|
||||
inline auto transformY(int logical_y) -> int {
|
||||
return transformY(logical_y, g_current_scale_factor);
|
||||
}
|
||||
|
||||
} // namespace Rendering
|
||||
|
||||
@@ -362,7 +362,7 @@ void GpuFrameRenderer::compositePass() {
|
||||
ubo.flicker_amplitude = FLICKER_AMPLITUDE;
|
||||
ubo.flicker_frequency_hz = postfx_params_.flicker_frequency_hz;
|
||||
ubo.background_pulse_freq_hz = postfx_params_.background_pulse_freq_hz;
|
||||
ubo.pad_a_ = 0.0F;
|
||||
ubo.pad_a = 0.0F;
|
||||
ubo.background_min_r = BG_MIN_R;
|
||||
ubo.background_min_g = BG_MIN_G;
|
||||
ubo.background_min_b = BG_MIN_B;
|
||||
@@ -373,8 +373,8 @@ void GpuFrameRenderer::compositePass() {
|
||||
ubo.background_max_a = 1.0F;
|
||||
ubo.texel_size_x = 1.0F / logical_w_;
|
||||
ubo.texel_size_y = 1.0F / logical_h_;
|
||||
ubo.pad_b_ = 0.0F;
|
||||
ubo.pad_c_ = 0.0F;
|
||||
ubo.pad_b = 0.0F;
|
||||
ubo.pad_c = 0.0F;
|
||||
|
||||
SDL_PushGPUFragmentUniformData(cmd_buffer_, 0, &ubo, sizeof(ubo));
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#include <SDL3/SDL_gpu.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Rendering::GPU {
|
||||
|
||||
class GpuDevice;
|
||||
|
||||
@@ -29,7 +29,7 @@ struct PostFxUniforms {
|
||||
float flicker_amplitude; // Profundidad del flicker (0..1)
|
||||
float flicker_frequency_hz; // Hz
|
||||
float background_pulse_freq_hz; // Hz
|
||||
float pad_a_;
|
||||
float pad_a;
|
||||
|
||||
float background_min_r; // Color min RGB en [0..1], A=1
|
||||
float background_min_g;
|
||||
@@ -43,8 +43,8 @@ struct PostFxUniforms {
|
||||
|
||||
float texel_size_x; // 1.0 / texture_width
|
||||
float texel_size_y;
|
||||
float pad_b_;
|
||||
float pad_c_;
|
||||
float pad_b;
|
||||
float pad_c;
|
||||
};
|
||||
|
||||
class GpuPostFxPipeline {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/input/mouse.hpp"
|
||||
#include "core/rendering/coordinate_transform.hpp"
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
#include "game/options.hpp"
|
||||
#include "project.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "core/defaults.hpp"
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
|
||||
namespace Rendering {
|
||||
@@ -48,7 +47,7 @@ static auto transformPoint(const Vec2& point, const Vec2& shape_centre, const Ve
|
||||
float centered_y = point.y - shape_centre.y;
|
||||
|
||||
// 2. Aplicar rotación 3D (si es proporciona)
|
||||
if ((rotation_3d != nullptr) && rotation_3d->has_rotation()) {
|
||||
if ((rotation_3d != nullptr) && rotation_3d->hasRotation()) {
|
||||
Vec2 rotated_3d = apply3dRotation(centered_x, centered_y, *rotation_3d);
|
||||
centered_x = rotated_3d.x;
|
||||
centered_y = rotated_3d.y;
|
||||
@@ -72,7 +71,7 @@ static auto transformPoint(const Vec2& point, const Vec2& shape_centre, const Ve
|
||||
return {.x = rotated_x + position.x, .y = rotated_y + position.y};
|
||||
}
|
||||
|
||||
void render_shape(Rendering::Renderer* renderer,
|
||||
void renderShape(Rendering::Renderer* renderer,
|
||||
const std::shared_ptr<Graphics::Shape>& shape,
|
||||
const Vec2& position,
|
||||
float angle,
|
||||
@@ -90,7 +89,7 @@ void render_shape(Rendering::Renderer* renderer,
|
||||
|
||||
const Vec2& shape_centre = shape->getCenter();
|
||||
|
||||
for (const auto& primitive : shape->get_primitives()) {
|
||||
for (const auto& primitive : shape->getPrimitives()) {
|
||||
if (primitive.type == Graphics::PrimitiveType::POLYLINE) {
|
||||
// POLYLINE: conectar puntos consecutivos.
|
||||
for (size_t i = 0; i < primitive.points.size() - 1; i++) {
|
||||
|
||||
@@ -29,7 +29,7 @@ struct Rotation3D {
|
||||
yaw(y),
|
||||
roll(r) {}
|
||||
|
||||
[[nodiscard]] auto has_rotation() const -> bool {
|
||||
[[nodiscard]] auto hasRotation() const -> bool {
|
||||
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
|
||||
}
|
||||
};
|
||||
@@ -42,7 +42,7 @@ struct Rotation3D {
|
||||
// - scale: factor de scale (1.0 = mida original)
|
||||
// - progress: progrés de l'animación (0.0-1.0, default 1.0 = tot visible)
|
||||
// - brightness: factor de brightness (0.0-1.0, default 1.0 = màxima brightness)
|
||||
void render_shape(Rendering::Renderer* renderer,
|
||||
void renderShape(Rendering::Renderer* renderer,
|
||||
const std::shared_ptr<Graphics::Shape>& shape,
|
||||
const Vec2& position,
|
||||
float angle,
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "resource_helper.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include "resource_loader.hpp"
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace Resource {
|
||||
|
||||
// Singleton
|
||||
auto Loader::get() -> Loader& {
|
||||
static Loader instance;
|
||||
return instance;
|
||||
static Loader instance_;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
// Inicialitzar el sistema de recursos
|
||||
|
||||
@@ -62,7 +62,7 @@ class Pack {
|
||||
static auto readFile(const std::string& filepath) -> std::vector<uint8_t>;
|
||||
[[nodiscard]] static auto calculateChecksum(const std::vector<uint8_t>& data) -> uint32_t;
|
||||
static void encryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
void decryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
static void decryptData(std::vector<uint8_t>& data, const std::string& key);
|
||||
};
|
||||
|
||||
} // namespace Resource
|
||||
|
||||
@@ -19,29 +19,29 @@ struct MatchConfig {
|
||||
// Métodos auxiliars
|
||||
|
||||
// Retorna true si solo hay un player active
|
||||
[[nodiscard]] auto es_un_jugador() const -> bool {
|
||||
[[nodiscard]] auto isSinglePlayer() const -> bool {
|
||||
return (jugador1_actiu && !jugador2_actiu) ||
|
||||
(!jugador1_actiu && jugador2_actiu);
|
||||
}
|
||||
|
||||
// Retorna true si hay dos jugadors active
|
||||
[[nodiscard]] auto son_dos_jugadors() const -> bool {
|
||||
[[nodiscard]] auto isCoop() const -> bool {
|
||||
return jugador1_actiu && jugador2_actiu;
|
||||
}
|
||||
|
||||
// Retorna true si no hay sin player active
|
||||
[[nodiscard]] auto cap_jugador() const -> bool {
|
||||
[[nodiscard]] auto hasNoPlayers() const -> bool {
|
||||
return !jugador1_actiu && !jugador2_actiu;
|
||||
}
|
||||
|
||||
// Compte de jugadors active (0, 1 o 2)
|
||||
[[nodiscard]] auto compte_jugadors() const -> uint8_t {
|
||||
[[nodiscard]] auto getPlayerCount() const -> uint8_t {
|
||||
return (jugador1_actiu ? 1 : 0) + (jugador2_actiu ? 1 : 0);
|
||||
}
|
||||
|
||||
// Retorna l'ID de l'únic player active (0 o 1)
|
||||
// Solo vàlid si es_un_jugador() retorna true
|
||||
[[nodiscard]] auto id_unic_jugador() const -> uint8_t {
|
||||
[[nodiscard]] auto getSinglePlayerId() const -> uint8_t {
|
||||
if (jugador1_actiu && !jugador2_actiu) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,39 +10,39 @@
|
||||
namespace Utils {
|
||||
|
||||
// Variables globals per guardar argv[0]
|
||||
static std::string executable_path_;
|
||||
static std::string executable_directory_;
|
||||
static std::string executable_path;
|
||||
static std::string executable_directory;
|
||||
|
||||
// Inicialitzar el sistema de rutes con argv[0]
|
||||
void initializePathSystem(const char* argv0) {
|
||||
if (argv0 == nullptr) {
|
||||
std::cerr << "[PathUtils] ADVERTÈNCIA: argv[0] es nullptr\n";
|
||||
executable_path_ = "";
|
||||
executable_directory_ = ".";
|
||||
executable_path = "";
|
||||
executable_directory = ".";
|
||||
return;
|
||||
}
|
||||
|
||||
executable_path_ = argv0;
|
||||
executable_path = argv0;
|
||||
|
||||
// Extreure el directori
|
||||
std::filesystem::path path(argv0);
|
||||
executable_directory_ = path.parent_path().string();
|
||||
executable_directory = path.parent_path().string();
|
||||
|
||||
if (executable_directory_.empty()) {
|
||||
executable_directory_ = ".";
|
||||
if (executable_directory.empty()) {
|
||||
executable_directory = ".";
|
||||
}
|
||||
|
||||
std::cout << "[PathUtils] Executable: " << executable_path_ << "\n";
|
||||
std::cout << "[PathUtils] Directori: " << executable_directory_ << "\n";
|
||||
std::cout << "[PathUtils] Executable: " << executable_path << "\n";
|
||||
std::cout << "[PathUtils] Directori: " << executable_directory << "\n";
|
||||
}
|
||||
|
||||
// Obtenir el directori de l'executable
|
||||
auto getExecutableDirectory() -> std::string {
|
||||
if (executable_directory_.empty()) {
|
||||
if (executable_directory.empty()) {
|
||||
std::cerr << "[PathUtils] ADVERTÈNCIA: Sistema de rutes no inicialitzat\n";
|
||||
return ".";
|
||||
}
|
||||
return executable_directory_;
|
||||
return executable_directory;
|
||||
}
|
||||
|
||||
// Detectar si estem dins un bundle de macOS
|
||||
|
||||
Reference in New Issue
Block a user