migrat Input a la ultima versió
cohesionats tots els metodes update de les escenes
This commit is contained in:
@@ -55,8 +55,7 @@ inline auto findFirstByte(const std::vector<DictionaryEntry>& dictionary, int co
|
||||
}
|
||||
|
||||
// Agrega una nueva entrada al diccionario
|
||||
inline void addDictionaryEntry(std::vector<DictionaryEntry>& dictionary, int& dictionary_ind,
|
||||
int& code_length, int prev, int code) {
|
||||
inline void addDictionaryEntry(std::vector<DictionaryEntry>& dictionary, int& dictionary_ind, int& code_length, int prev, int code) {
|
||||
uint8_t first_byte;
|
||||
if (code == dictionary_ind) {
|
||||
first_byte = findFirstByte(dictionary, prev);
|
||||
|
||||
@@ -209,13 +209,6 @@ void Screen::toggleShaders() {
|
||||
initShaders();
|
||||
}
|
||||
|
||||
// Actualiza la lógica de la clase (versión antigua para escenas no migradas)
|
||||
void Screen::update() {
|
||||
fps_.calculate(SDL_GetTicks());
|
||||
Notifier::get()->update(0.016f); // Asume ~60 FPS (16ms por frame)
|
||||
Mouse::updateCursorVisibility();
|
||||
}
|
||||
|
||||
// Actualiza la lógica de la clase (versión nueva con delta_time para escenas migradas)
|
||||
void Screen::update(float delta_time) {
|
||||
fps_.calculate(SDL_GetTicks());
|
||||
|
||||
@@ -153,7 +153,6 @@ class Screen {
|
||||
void render();
|
||||
|
||||
// Actualiza la lógica de la clase
|
||||
void update(); // Para escenas no migradas (sin delta_time)
|
||||
void update(float delta_time); // Para escenas migradas (con delta_time)
|
||||
|
||||
// Establece el modo de video
|
||||
@@ -196,7 +195,7 @@ class Screen {
|
||||
void hide();
|
||||
|
||||
// Establece el renderizador para las surfaces
|
||||
void setRendererSurface(const std::shared_ptr<Surface> &surface = nullptr);
|
||||
void setRendererSurface(const std::shared_ptr<Surface>& surface = nullptr);
|
||||
|
||||
// Cambia la paleta
|
||||
void nextPalette();
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/rendering/gif.hpp" // Para Gif
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/gif.hpp" // Para Gif
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
|
||||
// Carga una paleta desde un archivo .gif
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/resources/resource.hpp" // Para Resource
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "utils/utils.hpp" // Para printWithDots
|
||||
#include "utils/utils.hpp" // Para printWithDots
|
||||
|
||||
// Carga las animaciones en un vector(Animations) desde un fichero
|
||||
auto loadAnimationsFromFile(const std::string& file_path) -> Animations {
|
||||
@@ -30,14 +30,14 @@ auto loadAnimationsFromFile(const std::string& file_path) -> Animations {
|
||||
std::vector<std::string> buffer;
|
||||
std::string line;
|
||||
while (std::getline(stream, line)) {
|
||||
// Eliminar \r de Windows line endings
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
if (!line.empty()) {
|
||||
buffer.push_back(line);
|
||||
}
|
||||
}
|
||||
// Eliminar \r de Windows line endings
|
||||
if (!line.empty() && line.back() == '\r') {
|
||||
line.pop_back();
|
||||
}
|
||||
if (!line.empty()) {
|
||||
buffer.push_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -60,7 +60,6 @@ SurfaceAnimatedSprite::SurfaceAnimatedSprite(const Animations& animations)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Constructor
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, const std::string& file_path)
|
||||
: SurfaceMovingSprite(std::move(surface)) {
|
||||
@@ -105,8 +104,7 @@ void SurfaceAnimatedSprite::animate(float delta_time) {
|
||||
// Calcula el frame actual a partir del tiempo acumulado
|
||||
const int TARGET_FRAME = static_cast<int>(
|
||||
animations_[current_animation_].accumulated_time /
|
||||
animations_[current_animation_].speed
|
||||
);
|
||||
animations_[current_animation_].speed);
|
||||
|
||||
// Si alcanza el final de la animación, maneja el loop
|
||||
if (TARGET_FRAME >= static_cast<int>(animations_[current_animation_].frames.size())) {
|
||||
@@ -137,7 +135,7 @@ void SurfaceAnimatedSprite::animate(float delta_time) {
|
||||
// Establece el clip del frame actual
|
||||
if (animations_[current_animation_].current_frame >= 0 &&
|
||||
animations_[current_animation_].current_frame <
|
||||
static_cast<int>(animations_[current_animation_].frames.size())) {
|
||||
static_cast<int>(animations_[current_animation_].frames.size())) {
|
||||
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||
}
|
||||
}
|
||||
@@ -215,9 +213,7 @@ auto parseGlobalParameter(const std::string& line, std::shared_ptr<Surface>& sur
|
||||
}
|
||||
|
||||
// Helper: Parsea los frames de una animación desde una cadena separada por comas
|
||||
void parseAnimationFrames(const std::string& value, AnimationData& animation,
|
||||
float frame_width, float frame_height,
|
||||
int frames_per_row, int max_tiles) {
|
||||
void parseAnimationFrames(const std::string& value, AnimationData& animation, float frame_width, float frame_height, int frames_per_row, int max_tiles) {
|
||||
std::stringstream ss(value);
|
||||
std::string tmp;
|
||||
SDL_FRect rect = {0.0F, 0.0F, frame_width, frame_height};
|
||||
@@ -269,8 +265,7 @@ auto parseAnimation(const Animations& animations, size_t& index, float frame_wid
|
||||
if (pos != std::string::npos) {
|
||||
std::string key = line.substr(0, pos);
|
||||
std::string value = line.substr(pos + 1);
|
||||
parseAnimationParameter(key, value, animation, frame_width, frame_height,
|
||||
frames_per_row, max_tiles);
|
||||
parseAnimationParameter(key, value, animation, frame_width, frame_height, frames_per_row, max_tiles);
|
||||
}
|
||||
} while (line != "[/animation]");
|
||||
|
||||
@@ -302,8 +297,7 @@ void SurfaceAnimatedSprite::setAnimations(const Animations& animations) {
|
||||
|
||||
// Si la linea contiene el texto [animation] se realiza el proceso de carga de una animación
|
||||
if (line == "[animation]") {
|
||||
AnimationData animation = parseAnimation(animations, index, frame_width, frame_height,
|
||||
frames_per_row, max_tiles);
|
||||
AnimationData animation = parseAnimation(animations, index, frame_width, frame_height, frames_per_row, max_tiles);
|
||||
animations_.emplace_back(animation);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,5 +54,5 @@ void SurfaceSprite::clear() {
|
||||
// Actualiza el estado del sprite (time-based)
|
||||
void SurfaceSprite::update(float delta_time) {
|
||||
// Base implementation does nothing (static sprites)
|
||||
(void)delta_time; // Evita warning de parámetro no usado
|
||||
(void)delta_time; // Evita warning de parámetro no usado
|
||||
}
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <sstream> // Para istringstream
|
||||
#include <stdexcept> // Para runtime_error
|
||||
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource_helper.hpp" // Para ResourceHelper
|
||||
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
|
||||
#include "utils/utils.hpp" // Para getFileName, stringToColor, printWithDots
|
||||
|
||||
// Llena una estructuta TextFile desde un fichero
|
||||
auto loadTextFile(const std::string& file_path) -> std::shared_ptr<TextFile> {
|
||||
|
||||
Reference in New Issue
Block a user