linter
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// IWYU pragma: no_include <bits/std_abs.h>
|
||||
#include "path_sprite.hpp"
|
||||
|
||||
#include <cmath> // Para abs
|
||||
#include <functional> // Para function
|
||||
#include <utility> // Para move
|
||||
|
||||
@@ -75,32 +76,32 @@ void PathSprite::addPath(Path path, bool centered) {
|
||||
switch (path_centered) {
|
||||
case PathCentered::ON_X: {
|
||||
// Centrar en el eje X (para paths Verticales)
|
||||
const float X_offset = pos_.w / 2.0f; // Asume que pos_.w está inicializado por el constructor de Sprite
|
||||
const float X_OFFSET = pos_.w / 2.0F; // Asume que pos_.w está inicializado por el constructor de Sprite
|
||||
if (path.is_point_path) {
|
||||
const float X_base = !path.spots.empty() ? path.spots.front().x : 0.0f;
|
||||
const float X = X_base - X_offset;
|
||||
const float X_BASE = !path.spots.empty() ? path.spots.front().x : 0.0F;
|
||||
const float X = X_BASE - X_OFFSET;
|
||||
for (auto& spot : path.spots) {
|
||||
spot.x = X;
|
||||
}
|
||||
} else {
|
||||
// Es un path generado, ajustamos la posición fija (que es X)
|
||||
path.fixed_pos -= X_offset;
|
||||
path.fixed_pos -= X_OFFSET;
|
||||
}
|
||||
paths_.emplace_back(std::move(path)); // Usamos std::move
|
||||
break;
|
||||
}
|
||||
case PathCentered::ON_Y: {
|
||||
// Centrar en el eje Y (para paths Horizontales)
|
||||
const float Y_offset = pos_.h / 2.0f; // Asume que pos_.h está inicializado
|
||||
const float Y_OFFSET = pos_.h / 2.0F; // Asume que pos_.h está inicializado
|
||||
if (path.is_point_path) {
|
||||
const float Y_base = !path.spots.empty() ? path.spots.front().y : 0.0f;
|
||||
const float Y = Y_base - Y_offset;
|
||||
const float Y_BASE = !path.spots.empty() ? path.spots.front().y : 0.0F;
|
||||
const float Y = Y_BASE - Y_OFFSET;
|
||||
for (auto& spot : path.spots) {
|
||||
spot.y = Y;
|
||||
}
|
||||
} else {
|
||||
// Es un path generado, ajustamos la posición fija (que es Y)
|
||||
path.fixed_pos -= Y_offset;
|
||||
path.fixed_pos -= Y_OFFSET;
|
||||
}
|
||||
paths_.emplace_back(std::move(path)); // Usamos std::move
|
||||
break;
|
||||
@@ -139,9 +140,9 @@ void PathSprite::enable() {
|
||||
// Para paths generados, establecer posición inicial
|
||||
SDL_FPoint initial_pos;
|
||||
if (path.type == PathType::HORIZONTAL) {
|
||||
initial_pos = {path.start_pos, path.fixed_pos};
|
||||
initial_pos = {.x = path.start_pos, .y = path.fixed_pos};
|
||||
} else {
|
||||
initial_pos = {path.fixed_pos, path.start_pos};
|
||||
initial_pos = {.x = path.fixed_pos, .y = path.start_pos};
|
||||
}
|
||||
setPosition(initial_pos);
|
||||
}
|
||||
@@ -177,8 +178,8 @@ void PathSprite::moveThroughCurrentPath(float delta_time) {
|
||||
|
||||
// Calcular progreso (0.0 a 1.0)
|
||||
float progress = path.elapsed_time / path.duration_s;
|
||||
if (progress >= 1.0f) {
|
||||
progress = 1.0f;
|
||||
if (progress >= 1.0F) {
|
||||
progress = 1.0F;
|
||||
path.on_destination = true;
|
||||
}
|
||||
|
||||
@@ -186,14 +187,14 @@ void PathSprite::moveThroughCurrentPath(float delta_time) {
|
||||
double eased_progress = path.easing_function(progress);
|
||||
|
||||
// Calcular posición actual
|
||||
float current_pos = path.start_pos + (path.end_pos - path.start_pos) * static_cast<float>(eased_progress);
|
||||
float current_pos = path.start_pos + ((path.end_pos - path.start_pos) * static_cast<float>(eased_progress));
|
||||
|
||||
// Establecer posición según el tipo
|
||||
SDL_FPoint position;
|
||||
if (path.type == PathType::HORIZONTAL) {
|
||||
position = {current_pos, path.fixed_pos};
|
||||
position = {.x = current_pos, .y = path.fixed_pos};
|
||||
} else {
|
||||
position = {path.fixed_pos, current_pos};
|
||||
position = {.x = path.fixed_pos, .y = current_pos};
|
||||
}
|
||||
setPosition(position);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user