reordenades i renombrades les classes sprite
This commit is contained in:
@@ -43,10 +43,10 @@ set(APP_SOURCES
|
||||
source/core/rendering/pixel_reveal.cpp
|
||||
source/core/rendering/screen.cpp
|
||||
source/core/rendering/surface.cpp
|
||||
source/core/rendering/surface_animated_sprite.cpp
|
||||
source/core/rendering/surface_dissolve_sprite.cpp
|
||||
source/core/rendering/surface_moving_sprite.cpp
|
||||
source/core/rendering/surface_sprite.cpp
|
||||
source/core/rendering/sprite/animated_sprite.cpp
|
||||
source/core/rendering/sprite/dissolve_sprite.cpp
|
||||
source/core/rendering/sprite/moving_sprite.cpp
|
||||
source/core/rendering/sprite/sprite.cpp
|
||||
source/core/rendering/text.cpp
|
||||
|
||||
# Core - Locale
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "core/rendering/surface_animated_sprite.hpp"
|
||||
#include "core/rendering/sprite/animated_sprite.hpp"
|
||||
|
||||
#include <cstddef> // Para size_t
|
||||
#include <fstream> // Para basic_ostream, basic_istream, operator<<, basic...
|
||||
@@ -31,7 +31,7 @@ auto convertYAMLFramesToRects(const fkyaml::node& frames_node, float frame_width
|
||||
}
|
||||
|
||||
// Carga las animaciones desde un fichero YAML
|
||||
auto SurfaceAnimatedSprite::loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData> { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto AnimatedSprite::loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData> { // NOLINT(readability-convert-member-functions-to-static)
|
||||
std::vector<AnimationData> animations;
|
||||
|
||||
// Extract filename for logging
|
||||
@@ -124,7 +124,7 @@ auto SurfaceAnimatedSprite::loadAnimationsFromYAML(const std::string& file_path,
|
||||
}
|
||||
|
||||
// Constructor con bytes YAML del cache (parsing lazy)
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(const AnimationResource& cached_data) {
|
||||
AnimatedSprite::AnimatedSprite(const AnimationResource& cached_data) {
|
||||
// Parsear YAML desde los bytes cargados en cache
|
||||
std::string yaml_content(cached_data.yaml_data.begin(), cached_data.yaml_data.end());
|
||||
|
||||
@@ -215,8 +215,8 @@ SurfaceAnimatedSprite::SurfaceAnimatedSprite(const AnimationResource& cached_dat
|
||||
}
|
||||
|
||||
// Constructor per a subclasses amb surface directa (sense YAML)
|
||||
SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: SurfaceMovingSprite(std::move(surface), pos) {
|
||||
AnimatedSprite::AnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: MovingSprite(std::move(surface), pos) {
|
||||
// animations_ queda buit (protegit per el guard de animate())
|
||||
if (surface_) {
|
||||
clip_ = {.x = 0, .y = 0, .w = surface_->getWidth(), .h = surface_->getHeight()};
|
||||
@@ -224,7 +224,7 @@ SurfaceAnimatedSprite::SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, S
|
||||
}
|
||||
|
||||
// Obtiene el indice de la animación a partir del nombre
|
||||
auto SurfaceAnimatedSprite::getIndex(const std::string& name) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto AnimatedSprite::getIndex(const std::string& name) -> int { // NOLINT(readability-convert-member-functions-to-static)
|
||||
auto index = -1;
|
||||
|
||||
for (const auto& a : animations_) {
|
||||
@@ -238,7 +238,7 @@ auto SurfaceAnimatedSprite::getIndex(const std::string& name) -> int { // NOLINT
|
||||
}
|
||||
|
||||
// Calcula el frame correspondiente a la animación (time-based)
|
||||
void SurfaceAnimatedSprite::animate(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
void AnimatedSprite::animate(float delta_time) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
if (animations_.empty()) { return; }
|
||||
if (animations_[current_animation_].speed <= 0.0F) {
|
||||
return;
|
||||
@@ -288,12 +288,12 @@ void SurfaceAnimatedSprite::animate(float delta_time) { // NOLINT(readability-co
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado la animación
|
||||
auto SurfaceAnimatedSprite::animationIsCompleted() -> bool {
|
||||
auto AnimatedSprite::animationIsCompleted() -> bool {
|
||||
return animations_[current_animation_].completed;
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) {
|
||||
void AnimatedSprite::setCurrentAnimation(const std::string& name) {
|
||||
const auto NEW_ANIMATION = getIndex(name);
|
||||
if (current_animation_ != NEW_ANIMATION) {
|
||||
current_animation_ = NEW_ANIMATION;
|
||||
@@ -305,7 +305,7 @@ void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) {
|
||||
}
|
||||
|
||||
// Establece la animacion actual
|
||||
void SurfaceAnimatedSprite::setCurrentAnimation(int index) {
|
||||
void AnimatedSprite::setCurrentAnimation(int index) {
|
||||
const auto NEW_ANIMATION = index;
|
||||
if (current_animation_ != NEW_ANIMATION) {
|
||||
current_animation_ = NEW_ANIMATION;
|
||||
@@ -317,20 +317,20 @@ void SurfaceAnimatedSprite::setCurrentAnimation(int index) {
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto (time-based)
|
||||
void SurfaceAnimatedSprite::update(float delta_time) {
|
||||
void AnimatedSprite::update(float delta_time) {
|
||||
animate(delta_time);
|
||||
SurfaceMovingSprite::update(delta_time);
|
||||
MovingSprite::update(delta_time);
|
||||
}
|
||||
|
||||
// Reinicia la animación
|
||||
void SurfaceAnimatedSprite::resetAnimation() {
|
||||
void AnimatedSprite::resetAnimation() {
|
||||
animations_[current_animation_].current_frame = 0;
|
||||
animations_[current_animation_].accumulated_time = 0.0F;
|
||||
animations_[current_animation_].completed = false;
|
||||
}
|
||||
|
||||
// Establece el frame actual de la animación
|
||||
void SurfaceAnimatedSprite::setCurrentAnimationFrame(int num) {
|
||||
void AnimatedSprite::setCurrentAnimationFrame(int num) {
|
||||
// Descarta valores fuera de rango
|
||||
if (num < 0 || num >= static_cast<int>(animations_[current_animation_].frames.size())) {
|
||||
num = 0;
|
||||
@@ -7,12 +7,12 @@
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/rendering/surface_moving_sprite.hpp" // Para SMovingSprite
|
||||
#include "core/resources/resource_types.hpp" // Para AnimationResource
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // Para SMovingSprite
|
||||
#include "core/resources/resource_types.hpp" // Para AnimationResource
|
||||
|
||||
class Surface;
|
||||
|
||||
class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
||||
class AnimatedSprite : public MovingSprite {
|
||||
public:
|
||||
using Animations = std::vector<std::string>; // Tipo para lista de animaciones
|
||||
|
||||
@@ -31,9 +31,9 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
||||
static auto loadAnimationsFromYAML(const std::string& file_path, std::shared_ptr<Surface>& surface, float& frame_width, float& frame_height) -> std::vector<AnimationData>; // Carga las animaciones desde fichero YAML
|
||||
|
||||
// Constructores
|
||||
explicit SurfaceAnimatedSprite(const AnimationResource& cached_data); // Constructor con datos pre-cargados del cache
|
||||
explicit AnimatedSprite(const AnimationResource& cached_data); // Constructor con datos pre-cargados del cache
|
||||
|
||||
~SurfaceAnimatedSprite() override = default; // Destructor
|
||||
~AnimatedSprite() override = default; // Destructor
|
||||
|
||||
void update(float delta_time) override; // Actualiza las variables del objeto (time-based)
|
||||
|
||||
@@ -50,7 +50,7 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
||||
|
||||
protected:
|
||||
// Constructor per a ús de subclasses que gestionen la surface directament (sense YAML)
|
||||
SurfaceAnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
AnimatedSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
|
||||
// Métodos protegidos
|
||||
void animate(float delta_time); // Calcula el frame correspondiente a la animación actual (time-based)
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "core/rendering/surface_dissolve_sprite.hpp"
|
||||
#include "core/rendering/sprite/dissolve_sprite.hpp"
|
||||
|
||||
#include <algorithm> // Para min
|
||||
#include <cstdint> // Para uint32_t
|
||||
@@ -15,7 +15,7 @@ static auto pixelRank(int col, int row) -> float {
|
||||
}
|
||||
|
||||
// Rang per a un píxel tenint en compte direcció (70% direccional + 30% aleatori)
|
||||
auto SurfaceDissolveSprite::computePixelRank(int col, int row, int frame_h, DissolveDirection dir) -> float {
|
||||
auto DissolveSprite::computePixelRank(int col, int row, int frame_h, DissolveDirection dir) -> float {
|
||||
const float RANDOM = pixelRank(col, row);
|
||||
if (dir == DissolveDirection::NONE || frame_h <= 0) {
|
||||
return RANDOM;
|
||||
@@ -32,8 +32,8 @@ auto SurfaceDissolveSprite::computePixelRank(int col, int row, int frame_h, Diss
|
||||
}
|
||||
|
||||
// Constructor per a surface directa (sense AnimationResource)
|
||||
SurfaceDissolveSprite::SurfaceDissolveSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: SurfaceAnimatedSprite(std::move(surface), pos) {
|
||||
DissolveSprite::DissolveSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: AnimatedSprite(std::move(surface), pos) {
|
||||
if (surface_) {
|
||||
const int W = static_cast<int>(surface_->getWidth());
|
||||
const int H = static_cast<int>(surface_->getHeight());
|
||||
@@ -44,8 +44,8 @@ SurfaceDissolveSprite::SurfaceDissolveSprite(std::shared_ptr<Surface> surface, S
|
||||
}
|
||||
|
||||
// Constructor
|
||||
SurfaceDissolveSprite::SurfaceDissolveSprite(const AnimationResource& data)
|
||||
: SurfaceAnimatedSprite(data) {
|
||||
DissolveSprite::DissolveSprite(const AnimationResource& data)
|
||||
: AnimatedSprite(data) {
|
||||
if (surface_) {
|
||||
const int W = static_cast<int>(surface_->getWidth());
|
||||
const int H = static_cast<int>(surface_->getHeight());
|
||||
@@ -57,7 +57,7 @@ SurfaceDissolveSprite::SurfaceDissolveSprite(const AnimationResource& data)
|
||||
}
|
||||
|
||||
// Reconstrueix la surface_display_ filtrant píxels per progress_
|
||||
void SurfaceDissolveSprite::rebuildDisplaySurface() {
|
||||
void DissolveSprite::rebuildDisplaySurface() {
|
||||
if (!surface_ || !surface_display_) {
|
||||
return;
|
||||
}
|
||||
@@ -109,9 +109,9 @@ void SurfaceDissolveSprite::rebuildDisplaySurface() {
|
||||
}
|
||||
|
||||
// Actualitza animació, moviment i transició temporal
|
||||
void SurfaceDissolveSprite::update(float delta_time) {
|
||||
void DissolveSprite::update(float delta_time) {
|
||||
const SDL_FRect OLD_CLIP = clip_;
|
||||
SurfaceAnimatedSprite::update(delta_time);
|
||||
AnimatedSprite::update(delta_time);
|
||||
|
||||
// Detecta canvi de frame d'animació
|
||||
if (clip_.x != OLD_CLIP.x || clip_.y != OLD_CLIP.y ||
|
||||
@@ -136,22 +136,22 @@ void SurfaceDissolveSprite::update(float delta_time) {
|
||||
}
|
||||
|
||||
// Renderitza: usa surface_display_ (amb color replace) si disponible
|
||||
void SurfaceDissolveSprite::render() {
|
||||
void DissolveSprite::render() {
|
||||
if (!surface_display_) {
|
||||
SurfaceAnimatedSprite::render();
|
||||
AnimatedSprite::render();
|
||||
return;
|
||||
}
|
||||
surface_display_->render(static_cast<int>(pos_.x), static_cast<int>(pos_.y), &clip_, flip_);
|
||||
}
|
||||
|
||||
// Estableix el progrés manualment
|
||||
void SurfaceDissolveSprite::setProgress(float progress) {
|
||||
void DissolveSprite::setProgress(float progress) {
|
||||
progress_ = std::min(std::max(progress, 0.0F), 1.0F);
|
||||
needs_rebuild_ = true;
|
||||
}
|
||||
|
||||
// Inicia dissolució temporal (visible → invisible)
|
||||
void SurfaceDissolveSprite::startDissolve(float duration_ms, DissolveDirection dir) {
|
||||
void DissolveSprite::startDissolve(float duration_ms, DissolveDirection dir) {
|
||||
direction_ = dir;
|
||||
transition_mode_ = TransitionMode::DISSOLVING;
|
||||
transition_duration_ = duration_ms;
|
||||
@@ -161,7 +161,7 @@ void SurfaceDissolveSprite::startDissolve(float duration_ms, DissolveDirection d
|
||||
}
|
||||
|
||||
// Inicia generació temporal (invisible → visible)
|
||||
void SurfaceDissolveSprite::startGenerate(float duration_ms, DissolveDirection dir) {
|
||||
void DissolveSprite::startGenerate(float duration_ms, DissolveDirection dir) {
|
||||
direction_ = dir;
|
||||
transition_mode_ = TransitionMode::GENERATING;
|
||||
transition_duration_ = duration_ms;
|
||||
@@ -171,17 +171,17 @@ void SurfaceDissolveSprite::startGenerate(float duration_ms, DissolveDirection d
|
||||
}
|
||||
|
||||
// Atura la transició temporal
|
||||
void SurfaceDissolveSprite::stopTransition() {
|
||||
void DissolveSprite::stopTransition() {
|
||||
transition_mode_ = TransitionMode::NONE;
|
||||
}
|
||||
|
||||
// Retorna si la transició ha acabat
|
||||
auto SurfaceDissolveSprite::isTransitionDone() const -> bool {
|
||||
auto DissolveSprite::isTransitionDone() const -> bool {
|
||||
return transition_mode_ == TransitionMode::NONE;
|
||||
}
|
||||
|
||||
// Configura substitució de color per a la reconstrucció
|
||||
void SurfaceDissolveSprite::setColorReplace(Uint8 source, Uint8 target) {
|
||||
void DissolveSprite::setColorReplace(Uint8 source, Uint8 target) {
|
||||
source_color_ = source;
|
||||
target_color_ = target;
|
||||
needs_rebuild_ = true;
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SurfaceAnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SurfaceAnimatedSprite
|
||||
|
||||
class Surface;
|
||||
|
||||
@@ -15,11 +15,11 @@ enum class DissolveDirection { NONE,
|
||||
|
||||
// Sprite que pot dissoldre's o generar-se de forma aleatòria en X mil·lisegons.
|
||||
// progress_ va de 0.0 (totalment visible) a 1.0 (totalment invisible).
|
||||
class SurfaceDissolveSprite : public SurfaceAnimatedSprite {
|
||||
class DissolveSprite : public AnimatedSprite {
|
||||
public:
|
||||
explicit SurfaceDissolveSprite(const AnimationResource& data);
|
||||
SurfaceDissolveSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
~SurfaceDissolveSprite() override = default;
|
||||
explicit DissolveSprite(const AnimationResource& data);
|
||||
DissolveSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
~DissolveSprite() override = default;
|
||||
|
||||
void update(float delta_time) override;
|
||||
void render() override;
|
||||
@@ -1,28 +1,28 @@
|
||||
#include "core/rendering/surface_moving_sprite.hpp"
|
||||
#include "core/rendering/sprite/moving_sprite.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
|
||||
// Constructor
|
||||
SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
|
||||
: SurfaceSprite(std::move(surface), pos),
|
||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip)
|
||||
: Sprite(std::move(surface), pos),
|
||||
x_(pos.x),
|
||||
y_(pos.y),
|
||||
flip_(flip) { SurfaceSprite::pos_ = pos; }
|
||||
flip_(flip) { Sprite::pos_ = pos; }
|
||||
|
||||
SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: SurfaceSprite(std::move(surface), pos),
|
||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos)
|
||||
: Sprite(std::move(surface), pos),
|
||||
x_(pos.x),
|
||||
y_(pos.y) { SurfaceSprite::pos_ = pos; }
|
||||
y_(pos.y) { Sprite::pos_ = pos; }
|
||||
|
||||
SurfaceMovingSprite::SurfaceMovingSprite() { SurfaceSprite::clear(); }
|
||||
MovingSprite::MovingSprite() { Sprite::clear(); }
|
||||
|
||||
SurfaceMovingSprite::SurfaceMovingSprite(std::shared_ptr<Surface> surface)
|
||||
: SurfaceSprite(std::move(surface)) { SurfaceSprite::clear(); }
|
||||
MovingSprite::MovingSprite(std::shared_ptr<Surface> surface)
|
||||
: Sprite(std::move(surface)) { Sprite::clear(); }
|
||||
|
||||
// Reinicia todas las variables
|
||||
void SurfaceMovingSprite::clear() {
|
||||
void MovingSprite::clear() {
|
||||
// Resetea posición
|
||||
x_ = 0.0F;
|
||||
y_ = 0.0F;
|
||||
@@ -38,13 +38,13 @@ void SurfaceMovingSprite::clear() {
|
||||
// Resetea flip
|
||||
flip_ = SDL_FLIP_NONE;
|
||||
|
||||
SurfaceSprite::clear();
|
||||
Sprite::clear();
|
||||
}
|
||||
|
||||
// Mueve el sprite (time-based)
|
||||
// Nota: vx_, vy_ ahora se interpretan como pixels/segundo
|
||||
// Nota: ax_, ay_ ahora se interpretan como pixels/segundo²
|
||||
void SurfaceMovingSprite::move(float delta_time) {
|
||||
void MovingSprite::move(float delta_time) {
|
||||
// Aplica aceleración a velocidad (time-based)
|
||||
vx_ += ax_ * delta_time;
|
||||
vy_ += ay_ * delta_time;
|
||||
@@ -59,22 +59,22 @@ void SurfaceMovingSprite::move(float delta_time) {
|
||||
}
|
||||
|
||||
// Actualiza las variables internas del objeto (time-based)
|
||||
void SurfaceMovingSprite::update(float delta_time) {
|
||||
void MovingSprite::update(float delta_time) {
|
||||
move(delta_time);
|
||||
}
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void SurfaceMovingSprite::render() {
|
||||
void MovingSprite::render() {
|
||||
surface_->render(pos_.x, pos_.y, &clip_, flip_);
|
||||
}
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void SurfaceMovingSprite::render(Uint8 source_color, Uint8 target_color) {
|
||||
void MovingSprite::render(Uint8 source_color, Uint8 target_color) {
|
||||
surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_, flip_);
|
||||
}
|
||||
|
||||
// Establece la posición y_ el tamaño del objeto
|
||||
void SurfaceMovingSprite::setPos(SDL_FRect rect) {
|
||||
void MovingSprite::setPos(SDL_FRect rect) {
|
||||
x_ = rect.x;
|
||||
y_ = rect.y;
|
||||
|
||||
@@ -82,7 +82,7 @@ void SurfaceMovingSprite::setPos(SDL_FRect rect) {
|
||||
}
|
||||
|
||||
// Establece el valor de las variables
|
||||
void SurfaceMovingSprite::setPos(float x, float y) {
|
||||
void MovingSprite::setPos(float x, float y) {
|
||||
x_ = x;
|
||||
y_ = y;
|
||||
|
||||
@@ -91,13 +91,13 @@ void SurfaceMovingSprite::setPos(float x, float y) {
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void SurfaceMovingSprite::setPosX(float value) {
|
||||
void MovingSprite::setPosX(float value) {
|
||||
x_ = value;
|
||||
pos_.x = static_cast<int>(x_);
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void SurfaceMovingSprite::setPosY(float value) {
|
||||
void MovingSprite::setPosY(float value) {
|
||||
y_ = value;
|
||||
pos_.y = static_cast<int>(y_);
|
||||
}
|
||||
@@ -4,18 +4,18 @@
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
class Surface; // lines 8-8
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
class Surface; // lines 8-8
|
||||
|
||||
// Clase SMovingSprite. Añade movimiento y flip al sprite
|
||||
class SurfaceMovingSprite : public SurfaceSprite {
|
||||
class MovingSprite : public Sprite {
|
||||
public:
|
||||
// Constructores
|
||||
SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
|
||||
SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
explicit SurfaceMovingSprite();
|
||||
explicit SurfaceMovingSprite(std::shared_ptr<Surface> surface);
|
||||
~SurfaceMovingSprite() override = default;
|
||||
MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
|
||||
MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
explicit MovingSprite();
|
||||
explicit MovingSprite(std::shared_ptr<Surface> surface);
|
||||
~MovingSprite() override = default;
|
||||
|
||||
// Actualización y renderizado
|
||||
void update(float delta_time) override; // Actualiza variables internas (time-based)
|
||||
@@ -1,37 +1,37 @@
|
||||
#include "core/rendering/surface_sprite.hpp"
|
||||
#include "core/rendering/sprite/sprite.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
|
||||
// Constructor
|
||||
SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface, float x, float y, float w, float h)
|
||||
Sprite::Sprite(std::shared_ptr<Surface> surface, float x, float y, float w, float h)
|
||||
: surface_(std::move(surface)),
|
||||
pos_{.x = x, .y = y, .w = w, .h = h},
|
||||
clip_{.x = 0.0F, .y = 0.0F, .w = pos_.w, .h = pos_.h} {}
|
||||
|
||||
SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface, SDL_FRect rect)
|
||||
Sprite::Sprite(std::shared_ptr<Surface> surface, SDL_FRect rect)
|
||||
: surface_(std::move(surface)),
|
||||
pos_(rect),
|
||||
clip_{.x = 0.0F, .y = 0.0F, .w = pos_.w, .h = pos_.h} {}
|
||||
|
||||
SurfaceSprite::SurfaceSprite() = default;
|
||||
Sprite::Sprite() = default;
|
||||
|
||||
SurfaceSprite::SurfaceSprite(std::shared_ptr<Surface> surface)
|
||||
Sprite::Sprite(std::shared_ptr<Surface> surface)
|
||||
: surface_(std::move(surface)),
|
||||
pos_{0.0F, 0.0F, surface_->getWidth(), surface_->getHeight()},
|
||||
clip_(pos_) {}
|
||||
|
||||
// Muestra el sprite por pantalla
|
||||
void SurfaceSprite::render() {
|
||||
void Sprite::render() {
|
||||
surface_->render(pos_.x, pos_.y, &clip_);
|
||||
}
|
||||
|
||||
void SurfaceSprite::render(Uint8 source_color, Uint8 target_color) {
|
||||
void Sprite::render(Uint8 source_color, Uint8 target_color) {
|
||||
surface_->renderWithColorReplace(pos_.x, pos_.y, source_color, target_color, &clip_);
|
||||
}
|
||||
|
||||
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height) {
|
||||
void Sprite::renderWithVerticalFade(int fade_h, int canvas_height) {
|
||||
surface_->renderWithVerticalFade(
|
||||
static_cast<int>(pos_.x),
|
||||
static_cast<int>(pos_.y),
|
||||
@@ -40,7 +40,7 @@ void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height) {
|
||||
&clip_);
|
||||
}
|
||||
|
||||
void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color) {
|
||||
void Sprite::renderWithVerticalFade(int fade_h, int canvas_height, Uint8 source_color, Uint8 target_color) {
|
||||
surface_->renderWithVerticalFade(
|
||||
static_cast<int>(pos_.x),
|
||||
static_cast<int>(pos_.y),
|
||||
@@ -52,25 +52,25 @@ void SurfaceSprite::renderWithVerticalFade(int fade_h, int canvas_height, Uint8
|
||||
}
|
||||
|
||||
// Establece la posición del objeto
|
||||
void SurfaceSprite::setPosition(float x, float y) {
|
||||
void Sprite::setPosition(float x, float y) {
|
||||
pos_.x = x;
|
||||
pos_.y = y;
|
||||
}
|
||||
|
||||
// Establece la posición del objeto
|
||||
void SurfaceSprite::setPosition(SDL_FPoint p) {
|
||||
void Sprite::setPosition(SDL_FPoint p) {
|
||||
pos_.x = p.x;
|
||||
pos_.y = p.y;
|
||||
}
|
||||
|
||||
// Reinicia las variables a cero
|
||||
void SurfaceSprite::clear() {
|
||||
void Sprite::clear() {
|
||||
pos_ = {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
|
||||
clip_ = {.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F};
|
||||
}
|
||||
|
||||
// Actualiza el estado del sprite (time-based)
|
||||
void SurfaceSprite::update(float delta_time) {
|
||||
void Sprite::update(float delta_time) {
|
||||
// Base implementation does nothing (static sprites)
|
||||
(void)delta_time; // Evita warning de parámetro no usado
|
||||
}
|
||||
@@ -7,16 +7,16 @@
|
||||
class Surface; // lines 5-5
|
||||
|
||||
// Clase SurfaceSprite
|
||||
class SurfaceSprite {
|
||||
class Sprite {
|
||||
public:
|
||||
// Constructores
|
||||
SurfaceSprite(std::shared_ptr<Surface>, float x, float y, float w, float h);
|
||||
SurfaceSprite(std::shared_ptr<Surface>, SDL_FRect rect);
|
||||
SurfaceSprite();
|
||||
explicit SurfaceSprite(std::shared_ptr<Surface>);
|
||||
Sprite(std::shared_ptr<Surface>, float x, float y, float w, float h);
|
||||
Sprite(std::shared_ptr<Surface>, SDL_FRect rect);
|
||||
Sprite();
|
||||
explicit Sprite(std::shared_ptr<Surface>);
|
||||
|
||||
// Destructor
|
||||
virtual ~SurfaceSprite() = default;
|
||||
virtual ~Sprite() = default;
|
||||
|
||||
// Actualización y renderizado
|
||||
virtual void update(float delta_time); // Actualiza el estado del sprite (time-based)
|
||||
@@ -56,7 +56,7 @@ class SurfaceSprite {
|
||||
|
||||
protected:
|
||||
// Variables miembro
|
||||
std::shared_ptr<Surface> surface_{nullptr}; // Surface donde estan todos los dibujos del sprite
|
||||
SDL_FRect pos_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // Posición y tamaño donde dibujar el sprite
|
||||
SDL_FRect clip_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // Rectangulo de origen de la surface que se dibujará en pantalla
|
||||
std::shared_ptr<Surface> surface_{nullptr}; // Surface donde estan todos los dibujos del sprite
|
||||
SDL_FRect pos_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // Posición y tamaño donde dibujar el sprite
|
||||
SDL_FRect clip_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 0.0F}; // Rectangulo de origen de la surface que se dibujará en pantalla
|
||||
};
|
||||
@@ -8,8 +8,8 @@
|
||||
#include <stdexcept> // Para runtime_error
|
||||
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#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
|
||||
|
||||
@@ -136,12 +136,12 @@ Text::Text(const std::shared_ptr<Surface>& surface, const std::string& text_file
|
||||
box_width_ = tf->box_width;
|
||||
offset_ = tf->offset;
|
||||
|
||||
sprite_ = std::make_unique<SurfaceSprite>(surface, SDL_FRect{.x = 0.0F, .y = 0.0F, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
sprite_ = std::make_unique<Sprite>(surface, SDL_FRect{.x = 0.0F, .y = 0.0F, .w = static_cast<float>(box_width_), .h = static_cast<float>(box_height_)});
|
||||
}
|
||||
|
||||
// Constructor desde estructura precargada
|
||||
Text::Text(const std::shared_ptr<Surface>& surface, const std::shared_ptr<File>& text_file)
|
||||
: sprite_(std::make_unique<SurfaceSprite>(surface, SDL_FRect{.x = 0.0F, .y = 0.0F, .w = static_cast<float>(text_file->box_width), .h = static_cast<float>(text_file->box_height)})),
|
||||
: sprite_(std::make_unique<Sprite>(surface, SDL_FRect{.x = 0.0F, .y = 0.0F, .w = static_cast<float>(text_file->box_width), .h = static_cast<float>(text_file->box_height)})),
|
||||
box_width_(text_file->box_width),
|
||||
box_height_(text_file->box_height),
|
||||
offset_(text_file->offset) {
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#include <string> // Para string
|
||||
#include <unordered_map> // Para unordered_map
|
||||
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
class Surface; // Forward declaration
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
class Surface; // Forward declaration
|
||||
|
||||
// Clase texto. Pinta texto en pantalla a partir de un bitmap con soporte UTF-8
|
||||
class Text {
|
||||
@@ -52,7 +52,7 @@ class Text {
|
||||
[[nodiscard]] auto getCharacterSize() const -> int; // Devuelve el tamaño del caracter
|
||||
[[nodiscard]] auto glyphWidth(uint32_t codepoint, int kerning = 0) const -> int; // Devuelve el ancho en pixels de un glifo
|
||||
[[nodiscard]] auto getGlyphClip(uint32_t codepoint) const -> SDL_FRect; // Devuelve el clip rect del glifo
|
||||
[[nodiscard]] auto getSprite() const -> SurfaceSprite* { return sprite_.get(); } // Acceso al sprite interno
|
||||
[[nodiscard]] auto getSprite() const -> Sprite* { return sprite_.get(); } // Acceso al sprite interno
|
||||
|
||||
void setFixedWidth(bool value); // Establece si se usa un tamaño fijo de letra
|
||||
|
||||
@@ -62,7 +62,7 @@ class Text {
|
||||
|
||||
private:
|
||||
// Objetos y punteros
|
||||
std::unique_ptr<SurfaceSprite> sprite_ = nullptr; // Objeto con los graficos para el texto
|
||||
std::unique_ptr<Sprite> sprite_ = nullptr; // Objeto con los graficos para el texto
|
||||
|
||||
// Variables
|
||||
int box_width_ = 0; // Anchura de la caja de cada caracter en el png
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
#include <cstdlib> // Para rand
|
||||
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
|
||||
// Constructor
|
||||
Enemy::Enemy(const Data& enemy)
|
||||
: sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::Cache::get()->getAnimationData(enemy.animation_path))),
|
||||
: sprite_(std::make_shared<AnimatedSprite>(Resource::Cache::get()->getAnimationData(enemy.animation_path))),
|
||||
color_string_(enemy.color),
|
||||
x1_(enemy.x1),
|
||||
x2_(enemy.x2),
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
class SurfaceAnimatedSprite; // lines 7-7
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
class AnimatedSprite; // lines 7-7
|
||||
|
||||
class Enemy {
|
||||
public:
|
||||
@@ -36,7 +36,7 @@ class Enemy {
|
||||
private:
|
||||
void checkPath(); // Comprueba si ha llegado al limite del recorrido para darse media vuelta
|
||||
|
||||
std::shared_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del enemigo
|
||||
std::shared_ptr<AnimatedSprite> sprite_; // Sprite del enemigo
|
||||
|
||||
// Variables
|
||||
Uint8 color_{0}; // Color del enemigo
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "game/entities/item.hpp"
|
||||
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
|
||||
// Constructor
|
||||
Item::Item(const Data& item)
|
||||
: sprite_(std::make_shared<SurfaceSprite>(Resource::Cache::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE, ITEM_SIZE)),
|
||||
: sprite_(std::make_shared<Sprite>(Resource::Cache::get()->getSurface(item.tile_set_file), item.x, item.y, ITEM_SIZE, ITEM_SIZE)),
|
||||
time_accumulator_(static_cast<float>(item.counter) * COLOR_CHANGE_INTERVAL) {
|
||||
// Inicia variables
|
||||
sprite_->setClip((item.tile % 10) * ITEM_SIZE, (item.tile / 10) * ITEM_SIZE, ITEM_SIZE, ITEM_SIZE);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
class SurfaceSprite;
|
||||
class Sprite;
|
||||
|
||||
class Item {
|
||||
public:
|
||||
@@ -34,7 +34,7 @@ class Item {
|
||||
static constexpr float ITEM_SIZE = 8.0F; // Tamaño del item en pixels
|
||||
static constexpr float COLOR_CHANGE_INTERVAL = 0.06F; // Intervalo de cambio de color en segundos (4 frames a 66.67fps)
|
||||
|
||||
std::shared_ptr<SurfaceSprite> sprite_; // SSprite del objeto
|
||||
std::shared_ptr<Sprite> sprite_; // SSprite del objeto
|
||||
|
||||
// Variables
|
||||
std::vector<Uint8> color_; // Vector con los colores del objeto
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
#include <iostream>
|
||||
#include <ranges> // Para std::ranges::any_of
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input, InputAction
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/gameplay/room.hpp" // Para Room, TileType
|
||||
#include "game/options.hpp" // Para Cheat, Options, options
|
||||
#include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/input.hpp" // Para Input, InputAction
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/gameplay/room.hpp" // Para Room, TileType
|
||||
#include "game/options.hpp" // Para Cheat, Options, options
|
||||
#include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "core/system/debug.hpp" // Para Debug
|
||||
@@ -751,7 +751,7 @@ void Player::applySpawnValues(const SpawnData& spawn) {
|
||||
// Inicializa el sprite del jugador
|
||||
void Player::initSprite(const std::string& animations_path) { // NOLINT(readability-convert-member-functions-to-static)
|
||||
const auto& animation_data = Resource::Cache::get()->getAnimationData(animations_path);
|
||||
sprite_ = std::make_unique<SurfaceAnimatedSprite>(animation_data);
|
||||
sprite_ = std::make_unique<AnimatedSprite>(animation_data);
|
||||
sprite_->setWidth(WIDTH);
|
||||
sprite_->setHeight(HEIGHT);
|
||||
sprite_->setCurrentAnimation("walk");
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <string> // Para string
|
||||
#include <utility>
|
||||
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "game/gameplay/room.hpp"
|
||||
#include "game/options.hpp" // Para Cheat, Options, options
|
||||
#include "utils/defines.hpp" // Para BORDER_TOP, BLOCK
|
||||
@@ -118,8 +118,8 @@ class Player {
|
||||
static constexpr int MAX_FALLING_HEIGHT = Tile::SIZE * 4; // Altura maxima permitida de caída en pixels
|
||||
|
||||
// --- Objetos y punteros ---
|
||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||
std::unique_ptr<SurfaceAnimatedSprite> sprite_; // Sprite del jugador
|
||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||
std::unique_ptr<AnimatedSprite> sprite_; // Sprite del jugador
|
||||
|
||||
// --- Variables de posición y física ---
|
||||
float x_ = 0.0F; // Posición del jugador en el eje X
|
||||
@@ -136,11 +136,11 @@ class Player {
|
||||
State previous_state_ = State::ON_GROUND; // Estado previo en el que se encontraba el jugador
|
||||
|
||||
// --- Variables de colisión ---
|
||||
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
||||
std::array<SDL_FPoint, 8> collider_points_{}; // Puntos de colisión con el mapa
|
||||
SDL_FPoint under_left_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
||||
SDL_FPoint under_right_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
||||
const LineDiagonal* current_slope_{nullptr}; // Rampa actual sobe la que está el jugador
|
||||
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
||||
std::array<SDL_FPoint, 8> collider_points_{}; // Puntos de colisión con el mapa
|
||||
SDL_FPoint under_left_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
||||
SDL_FPoint under_right_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
||||
const LineDiagonal* current_slope_{nullptr}; // Rampa actual sobe la que está el jugador
|
||||
|
||||
// --- Variables de juego ---
|
||||
bool is_alive_ = true; // Indica si el jugador esta vivo o no
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "game/entities/item.hpp" // Para ItemData
|
||||
#include "game/gameplay/scoreboard.hpp" // Para Scoreboard::Data
|
||||
#include "utils/utils.hpp" // Para LineHorizontal, LineDiagonal, LineVertical
|
||||
class SurfaceSprite; // lines 12-12
|
||||
class Sprite; // lines 12-12
|
||||
class Surface; // lines 13-13
|
||||
class EnemyManager;
|
||||
class ItemManager;
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame
|
||||
#include "utils/defines.hpp" // Para BLOCK
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Options, options, Cheat, OptionsGame
|
||||
#include "utils/defines.hpp" // Para BLOCK
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
|
||||
// Constructor
|
||||
Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
||||
@@ -23,7 +23,7 @@ Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
const auto& player_animation_data = Resource::Cache::get()->getAnimationData(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.yaml" : "player.yaml");
|
||||
player_sprite_ = std::make_shared<SurfaceAnimatedSprite>(player_animation_data);
|
||||
player_sprite_ = std::make_shared<AnimatedSprite>(player_animation_data);
|
||||
player_sprite_->setCurrentAnimation("walk_menu");
|
||||
|
||||
surface_ = std::make_shared<Surface>(SURFACE_WIDTH, SURFACE_HEIGHT);
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string, basic_string
|
||||
#include <utility>
|
||||
#include <vector> // Para vector
|
||||
class SurfaceAnimatedSprite; // lines 10-10
|
||||
class Surface; // lines 11-11
|
||||
#include <vector> // Para vector
|
||||
class AnimatedSprite; // lines 10-10
|
||||
class Surface; // lines 11-11
|
||||
|
||||
class Scoreboard {
|
||||
public:
|
||||
@@ -50,10 +50,10 @@ class Scoreboard {
|
||||
void fillTexture(); // Dibuja los elementos del marcador en la surface
|
||||
|
||||
// Objetos y punteros
|
||||
std::shared_ptr<SurfaceAnimatedSprite> player_sprite_; // Sprite para mostrar las vidas en el marcador
|
||||
std::shared_ptr<Surface> item_surface_; // Surface con los graficos para los elementos del marcador
|
||||
std::shared_ptr<Data> data_; // Contiene las variables a mostrar en el marcador
|
||||
std::shared_ptr<Surface> surface_; // Surface donde dibujar el marcador
|
||||
std::shared_ptr<AnimatedSprite> player_sprite_; // Sprite para mostrar las vidas en el marcador
|
||||
std::shared_ptr<Surface> item_surface_; // Surface con los graficos para los elementos del marcador
|
||||
std::shared_ptr<Data> data_; // Contiene las variables a mostrar en el marcador
|
||||
std::shared_ptr<Surface> surface_; // Surface donde dibujar el marcador
|
||||
|
||||
// Variables de estado
|
||||
std::vector<Uint8> color_; // Vector con los colores del objeto
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "tilemap_renderer.hpp"
|
||||
|
||||
#include "core/rendering/screen.hpp"
|
||||
#include "core/rendering/sprite/sprite.hpp"
|
||||
#include "core/rendering/surface.hpp"
|
||||
#include "core/rendering/surface_sprite.hpp"
|
||||
#ifdef _DEBUG
|
||||
#include "core/system/debug.hpp"
|
||||
#endif
|
||||
@@ -159,7 +159,7 @@ void TilemapRenderer::setAnimatedTiles(const CollisionMap* collision_map) { //
|
||||
const int YC = (tile_map_[i] / tile_set_width_) * TILE_SIZE;
|
||||
|
||||
AnimatedTile at;
|
||||
at.sprite = std::make_shared<SurfaceSprite>(tileset_surface_, X, Y, 8, 8);
|
||||
at.sprite = std::make_shared<Sprite>(tileset_surface_, X, Y, 8, 8);
|
||||
at.sprite->setClip(XC, YC, 8, 8);
|
||||
at.x_orig = XC;
|
||||
animated_tiles_.push_back(at);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "utils/defines.hpp"
|
||||
|
||||
class Surface;
|
||||
class SurfaceSprite;
|
||||
class Sprite;
|
||||
class CollisionMap;
|
||||
|
||||
/**
|
||||
@@ -85,8 +85,8 @@ class TilemapRenderer {
|
||||
private:
|
||||
// Estructura para tiles animados (conveyor belts)
|
||||
struct AnimatedTile {
|
||||
std::shared_ptr<SurfaceSprite> sprite{nullptr}; // SurfaceSprite para dibujar el tile
|
||||
int x_orig{0}; // Posición X del primer tile de la animación en tilesheet
|
||||
std::shared_ptr<Sprite> sprite{nullptr}; // SurfaceSprite para dibujar el tile
|
||||
int x_orig{0}; // Posición X del primer tile de la animación en tilesheet
|
||||
};
|
||||
|
||||
// === Constantes ===
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/pixel_reveal.hpp" // Para PixelReveal
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GAME_SPEED, PlayArea::CENTER_X, PLAY_...
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/pixel_reveal.hpp" // Para PixelReveal
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GAME_SPEED, PlayArea::CENTER_X, PLAY_...
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
|
||||
// Destructor
|
||||
Credits::~Credits() = default;
|
||||
@@ -25,7 +25,7 @@ Credits::~Credits() = default;
|
||||
// Constructor
|
||||
Credits::Credits()
|
||||
: text_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||
shining_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::Cache::get()->getAnimationData("shine.yaml"))),
|
||||
shining_sprite_(std::make_shared<AnimatedSprite>(Resource::Cache::get()->getAnimationData("shine.yaml"))),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()) {
|
||||
// Configura la escena
|
||||
SceneManager::current = SceneManager::Scene::CREDITS;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
class SurfaceAnimatedSprite; // lines 11-11
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
class AnimatedSprite; // lines 11-11
|
||||
class Surface;
|
||||
class PixelReveal;
|
||||
class DeltaTimer;
|
||||
@@ -64,9 +64,9 @@ class Credits {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Recursos gráficos
|
||||
std::shared_ptr<Surface> text_surface_; // Textura para dibujar el texto
|
||||
std::unique_ptr<PixelReveal> pixel_reveal_; // Efecto de revelado pixel a pixel
|
||||
std::shared_ptr<SurfaceAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
|
||||
std::shared_ptr<Surface> text_surface_; // Textura para dibujar el texto
|
||||
std::unique_ptr<PixelReveal> pixel_reveal_; // Efecto de revelado pixel a pixel
|
||||
std::shared_ptr<AnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
|
||||
|
||||
// Temporizadores y estado
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Temporizador delta para time-based update
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/pixel_reveal.hpp" // Para PixelReveal
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/text.hpp" // Para Text, TEXT_STROKE
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
@@ -224,7 +224,7 @@ void Ending::iniTexts() { // NOLINT(readability-convert-member-functions-to-sta
|
||||
text->writeDX(Text::STROKE_FLAG, 2, 2, txt.caption, 1, text_color, 2, shadow_color);
|
||||
|
||||
// Crea el sprite
|
||||
st.image_sprite = std::make_shared<SurfaceSprite>(st.image_surface, 0, 0, st.image_surface->getWidth(), st.image_surface->getHeight());
|
||||
st.image_sprite = std::make_shared<Sprite>(st.image_surface, 0, 0, st.image_surface->getWidth(), st.image_surface->getHeight());
|
||||
st.pos_x = static_cast<int>((Options::game.width - st.image_surface->getWidth()) / 2);
|
||||
st.pos_y = txt.pos;
|
||||
st.image_sprite->setPosition(st.pos_x, st.pos_y);
|
||||
@@ -263,7 +263,7 @@ void Ending::iniPics() {
|
||||
// Crea el sprite
|
||||
sp.pos_x = static_cast<int>((Options::game.width - WIDTH) / 2);
|
||||
sp.pos_y = pic.pos;
|
||||
sp.image_sprite = std::make_shared<SurfaceSprite>(sp.image_surface, 0, 0, WIDTH, HEIGHT);
|
||||
sp.image_sprite = std::make_shared<Sprite>(sp.image_surface, 0, 0, WIDTH, HEIGHT);
|
||||
sp.image_sprite->setPosition(sp.pos_x, sp.pos_y);
|
||||
|
||||
// Crea el efecto de revelado pixel a pixel
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
class SurfaceSprite; // lines 8-8
|
||||
class Surface; // lines 9-9
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
class Sprite; // lines 8-8
|
||||
class Surface; // lines 9-9
|
||||
class PixelReveal;
|
||||
class DeltaTimer;
|
||||
|
||||
@@ -33,11 +33,11 @@ class Ending {
|
||||
|
||||
// --- Estructuras ---
|
||||
struct EndingSurface {
|
||||
std::shared_ptr<Surface> image_surface; // Surface a mostrar
|
||||
std::shared_ptr<SurfaceSprite> image_sprite; // SSprite para mostrar la textura
|
||||
std::unique_ptr<PixelReveal> pixel_reveal; // Efecto de revelado pixel a pixel
|
||||
int pos_x{0}; // Posición X de renderizado
|
||||
int pos_y{0}; // Posición Y de renderizado
|
||||
std::shared_ptr<Surface> image_surface; // Surface a mostrar
|
||||
std::shared_ptr<Sprite> image_sprite; // SSprite para mostrar la textura
|
||||
std::unique_ptr<PixelReveal> pixel_reveal; // Efecto de revelado pixel a pixel
|
||||
int pos_x{0}; // Posición X de renderizado
|
||||
int pos_y{0}; // Posición Y de renderizado
|
||||
};
|
||||
|
||||
struct TextAndPosition {
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
#include <algorithm> // Para max, replace
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
||||
#include "core/rendering/surface_moving_sprite.hpp" // Para SMovingSprite
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GameCanvas::CENTER_X, GameCanvas::CENTER_Y
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor, stringToColor
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
||||
#include "core/rendering/sprite/moving_sprite.hpp" // Para SMovingSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/text.hpp" // Para Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsGame, Sectio...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GameCanvas::CENTER_X, GameCanvas::CENTER_Y
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor, stringToColor
|
||||
|
||||
// Constructor
|
||||
Ending2::Ending2()
|
||||
@@ -268,7 +268,7 @@ void Ending2::loadSprites() {
|
||||
// Carga los sprites
|
||||
for (const auto& file : sprite_list_) {
|
||||
const auto& animation_data = Resource::Cache::get()->getAnimationData(file + ".yaml");
|
||||
sprites_.emplace_back(std::make_shared<SurfaceDissolveSprite>(animation_data));
|
||||
sprites_.emplace_back(std::make_shared<DissolveSprite>(animation_data));
|
||||
sprites_.back()->setColorReplace(1, static_cast<Uint8>(PaletteColor::RED));
|
||||
sprites_.back()->setProgress(1.0F); // comença invisible
|
||||
sprite_max_width_ = std::max(sprites_.back()->getWidth(), sprite_max_width_);
|
||||
@@ -427,7 +427,7 @@ void Ending2::createSpriteTexts() { // NOLINT(readability-convert-member-functi
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {.x = X, .y = Y, .w = W, .h = H};
|
||||
sprite_texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
sprite_texts_.emplace_back(std::make_shared<DissolveSprite>(surface, pos));
|
||||
sprite_texts_.back()->setColorReplace(1, static_cast<Uint8>(PaletteColor::WHITE));
|
||||
sprite_texts_.back()->setProgress(1.0F); // comença invisible
|
||||
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED);
|
||||
@@ -460,7 +460,7 @@ void Ending2::createTexts() { // NOLINT(readability-convert-member-functions-to
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {.x = X + DX, .y = Y, .w = W, .h = H};
|
||||
texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
texts_.emplace_back(std::make_shared<DissolveSprite>(surface, pos));
|
||||
texts_.back()->setProgress(1.0F); // comença invisible
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED);
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
@@ -490,7 +490,7 @@ void Ending2::createTexts() { // NOLINT(readability-convert-member-functions-to
|
||||
|
||||
// Crea el sprite
|
||||
SDL_FRect pos = {.x = X + DX, .y = Y, .w = W, .h = H};
|
||||
texts_.emplace_back(std::make_shared<SurfaceDissolveSprite>(surface, pos));
|
||||
texts_.emplace_back(std::make_shared<DissolveSprite>(surface, pos));
|
||||
texts_.back()->setProgress(1.0F); // comença invisible
|
||||
texts_.back()->setVelY(SPRITE_DESP_SPEED);
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "core/rendering/surface_dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
||||
#include "utils/defines.hpp" // Para GameCanvas::WIDTH, GameCanvas::FIRST_QUAR...
|
||||
#include "core/rendering/sprite/dissolve_sprite.hpp" // Para SurfaceDissolveSprite
|
||||
#include "utils/defines.hpp" // Para GameCanvas::WIDTH, GameCanvas::FIRST_QUAR...
|
||||
|
||||
class SurfaceMovingSprite;
|
||||
class MovingSprite;
|
||||
class DeltaTimer;
|
||||
|
||||
class Ending2 {
|
||||
@@ -77,10 +77,10 @@ class Ending2 {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Objetos y punteros a recursos
|
||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprites_; // Vector con todos los sprites a dibujar
|
||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
|
||||
std::vector<std::shared_ptr<SurfaceDissolveSprite>> texts_; // Vector con los sprites de texto
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para time-based update
|
||||
std::vector<std::shared_ptr<DissolveSprite>> sprites_; // Vector con todos los sprites a dibujar
|
||||
std::vector<std::shared_ptr<DissolveSprite>> sprite_texts_; // Vector con los sprites de texto de los sprites
|
||||
std::vector<std::shared_ptr<DissolveSprite>> texts_; // Vector con los sprites de texto
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para time-based update
|
||||
|
||||
// Variables de estado
|
||||
State state_; // Controla el estado de la clase
|
||||
|
||||
@@ -5,25 +5,25 @@
|
||||
#include <algorithm> // Para min, max
|
||||
#include <string> // Para basic_string, operator+, to_string
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/text.hpp" // Para Text::CENTER_FLAG, Text::COLOR_FLAG, Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsStats, Secti...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GameCanvas::CENTER_X
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor, stringToColor
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para SAnimatedSprite
|
||||
#include "core/rendering/text.hpp" // Para Text::CENTER_FLAG, Text::COLOR_FLAG, Text
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, OptionsStats, Secti...
|
||||
#include "game/scene_manager.hpp" // Para SceneManager
|
||||
#include "utils/defines.hpp" // Para GameCanvas::CENTER_X
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor, stringToColor
|
||||
|
||||
// Constructor
|
||||
GameOver::GameOver()
|
||||
: player_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::Cache::get()->getAnimationData("player_game_over.yaml"))),
|
||||
tv_sprite_(std::make_shared<SurfaceAnimatedSprite>(Resource::Cache::get()->getAnimationData("tv.yaml"))),
|
||||
: player_sprite_(std::make_shared<AnimatedSprite>(Resource::Cache::get()->getAnimationData("player_game_over.yaml"))),
|
||||
tv_sprite_(std::make_shared<AnimatedSprite>(Resource::Cache::get()->getAnimationData("tv.yaml"))),
|
||||
delta_timer_(std::make_shared<DeltaTimer>()) {
|
||||
SceneManager::current = SceneManager::Scene::GAME_OVER;
|
||||
SceneManager::options = SceneManager::Options::NONE;
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <vector> // Para vector
|
||||
class SurfaceAnimatedSprite; // lines 7-7
|
||||
class DeltaTimer; // Forward declaration
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <vector> // Para vector
|
||||
class AnimatedSprite; // lines 7-7
|
||||
class DeltaTimer; // Forward declaration
|
||||
|
||||
class GameOver {
|
||||
public:
|
||||
@@ -55,9 +55,9 @@ class GameOver {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Objetos y punteros a recursos
|
||||
std::shared_ptr<SurfaceAnimatedSprite> player_sprite_; // Sprite con el jugador
|
||||
std::shared_ptr<SurfaceAnimatedSprite> tv_sprite_; // Sprite con el televisor
|
||||
std::shared_ptr<DeltaTimer> delta_timer_; // Timer para time-based logic
|
||||
std::shared_ptr<AnimatedSprite> player_sprite_; // Sprite con el jugador
|
||||
std::shared_ptr<AnimatedSprite> tv_sprite_; // Sprite con el televisor
|
||||
std::shared_ptr<DeltaTimer> delta_timer_; // Timer para time-based logic
|
||||
|
||||
// Variables de estado de la escena
|
||||
State state_{State::WAITING}; // Estado actual de la escena
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, options, SectionState, Options...
|
||||
@@ -22,9 +22,9 @@
|
||||
LoadingScreen::LoadingScreen()
|
||||
: mono_loading_screen_surface_(Resource::Cache::get()->getSurface("loading_screen_bn.gif")),
|
||||
color_loading_screen_surface_(Resource::Cache::get()->getSurface("loading_screen_color.gif")),
|
||||
mono_loading_screen_sprite_(std::make_unique<SurfaceSprite>(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())),
|
||||
color_loading_screen_sprite_(std::make_unique<SurfaceSprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
||||
program_sprite_(std::make_unique<SurfaceSprite>(Resource::Cache::get()->getSurface("program_jaildoc.gif"))),
|
||||
mono_loading_screen_sprite_(std::make_unique<Sprite>(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())),
|
||||
color_loading_screen_sprite_(std::make_unique<Sprite>(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())),
|
||||
program_sprite_(std::make_unique<Sprite>(Resource::Cache::get()->getSurface("program_jaildoc.gif"))),
|
||||
screen_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()) {
|
||||
// Configura la superficie donde se van a pintar los sprites
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
#include "utils/utils.hpp" // Para PaletteColor
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Sprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
|
||||
class LoadingScreen {
|
||||
@@ -98,13 +98,13 @@ class LoadingScreen {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Objetos y punteros a recursos
|
||||
std::shared_ptr<Surface> mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro
|
||||
std::shared_ptr<Surface> color_loading_screen_surface_; // Surface con la pantalla de carga en color
|
||||
std::unique_ptr<SurfaceSprite> mono_loading_screen_sprite_; // SurfaceSprite para manejar la textura mono_loading_screen_surface_
|
||||
std::unique_ptr<SurfaceSprite> color_loading_screen_sprite_; // SurfaceSprite para manejar la textura color_loading_screen_surface_
|
||||
std::unique_ptr<SurfaceSprite> program_sprite_; // SurfaceSprite para manejar la textura con el nombre del programa
|
||||
std::shared_ptr<Surface> screen_surface_; // Surface para dibujar la pantalla de carga
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Surface> mono_loading_screen_surface_; // Surface con la pantalla de carga en blanco y negro
|
||||
std::shared_ptr<Surface> color_loading_screen_surface_; // Surface con la pantalla de carga en color
|
||||
std::unique_ptr<Sprite> mono_loading_screen_sprite_; // SurfaceSprite para manejar la textura mono_loading_screen_surface_
|
||||
std::unique_ptr<Sprite> color_loading_screen_sprite_; // SurfaceSprite para manejar la textura color_loading_screen_surface_
|
||||
std::unique_ptr<Sprite> program_sprite_; // SurfaceSprite para manejar la textura con el nombre del programa
|
||||
std::shared_ptr<Surface> screen_surface_; // Surface para dibujar la pantalla de carga
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
|
||||
// Variables de estado de la secuencia
|
||||
State state_{State::SILENT1}; // Estado actual de la secuencia
|
||||
@@ -112,10 +112,10 @@ class LoadingScreen {
|
||||
Border current_border_type_{Border::NONE}; // Tipo de borde actual
|
||||
|
||||
// Arrays y estructuras auxiliares
|
||||
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
||||
SDL_FRect load_rect_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 1.0F}; // Rectángulo para dibujar la pantalla de carga
|
||||
Carrier carrier_; // Estructura para los efectos de la carga de cabeceras
|
||||
Noise noise_; // Variaciones de ruido durante los silencios
|
||||
std::array<int, MONO_TOTAL_LINES> line_index_; // El orden en el que se procesan las 192 líneas de la pantalla de carga
|
||||
SDL_FRect load_rect_{.x = 0.0F, .y = 0.0F, .w = 0.0F, .h = 1.0F}; // Rectángulo para dibujar la pantalla de carga
|
||||
Carrier carrier_; // Estructura para los efectos de la carga de cabeceras
|
||||
Noise noise_; // Variaciones de ruido durante los silencios
|
||||
|
||||
// Variables de seguimiento para evitar saltos de pasos/bloques
|
||||
int last_mono_step_{-1}; // Último paso mono dibujado
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "core/input/global_inputs.hpp" // Para check
|
||||
#include "core/input/input.hpp" // Para Input
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/system/global_events.hpp" // Para check
|
||||
#include "game/options.hpp" // Para Options, SectionState, options, Section
|
||||
@@ -24,7 +24,7 @@
|
||||
Logo::Logo()
|
||||
: jailgames_surface_(Resource::Cache::get()->getSurface("jailgames.gif")),
|
||||
since_1998_surface_(Resource::Cache::get()->getSurface("since_1998.gif")),
|
||||
since_1998_sprite_(std::make_shared<SurfaceSprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())),
|
||||
since_1998_sprite_(std::make_shared<Sprite>(since_1998_surface_, (256 - since_1998_surface_->getWidth()) / 2, 83 + jailgames_surface_->getHeight() + 5, since_1998_surface_->getWidth(), since_1998_surface_->getHeight())),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()) {
|
||||
// Configura variables
|
||||
since_1998_sprite_->setClip(0, 0, since_1998_surface_->getWidth(), since_1998_surface_->getHeight());
|
||||
@@ -42,8 +42,8 @@ Logo::Logo()
|
||||
static const std::array<EasingFunction, 4> EASING_OPTIONS = {
|
||||
[](float t) -> float { return Easing::backOut(t); }, // Overshoot retro
|
||||
[](float t) -> float { return Easing::elasticOut(t); }, // Rebote múltiple con oscilación
|
||||
Easing::bounceOut, // Rebote físico decreciente
|
||||
Easing::cubicOut // Suavizado sin overshoot (para variedad)
|
||||
Easing::bounceOut, // Rebote físico decreciente
|
||||
Easing::cubicOut // Suavizado sin overshoot (para variedad)
|
||||
};
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
@@ -270,7 +270,7 @@ void Logo::initSprites() { // NOLINT(readability-convert-member-functions-to-st
|
||||
jailgames_initial_x_.reserve(jailgames_surface_->getHeight());
|
||||
|
||||
for (int i = 0; i < jailgames_surface_->getHeight(); ++i) {
|
||||
jailgames_sprite_.push_back(std::make_shared<SurfaceSprite>(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1));
|
||||
jailgames_sprite_.push_back(std::make_shared<Sprite>(jailgames_surface_, 0, i, jailgames_surface_->getWidth(), 1));
|
||||
jailgames_sprite_.back()->setClip(0, i, jailgames_surface_->getWidth(), 1);
|
||||
|
||||
// Calcular posición inicial (alternando entre derecha e izquierda)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Sprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
|
||||
class Logo {
|
||||
@@ -59,12 +59,12 @@ class Logo {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Objetos y punteros a recursos
|
||||
std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
|
||||
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
|
||||
std::vector<std::shared_ptr<SurfaceSprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||
std::vector<int> jailgames_initial_x_; // Posiciones X iniciales de cada línea (para interpolación con easing)
|
||||
std::shared_ptr<SurfaceSprite> since_1998_sprite_; // SSprite para manejar la textura2
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Surface> jailgames_surface_; // Textura con los graficos "JAILGAMES"
|
||||
std::shared_ptr<Surface> since_1998_surface_; // Textura con los graficos "Since 1998"
|
||||
std::vector<std::shared_ptr<Sprite>> jailgames_sprite_; // Vector con los sprites de cada linea que forman el bitmap JAILGAMES
|
||||
std::vector<int> jailgames_initial_x_; // Posiciones X iniciales de cada línea (para interpolación con easing)
|
||||
std::shared_ptr<Sprite> since_1998_sprite_; // SSprite para manejar la textura2
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
|
||||
// Variables de estado de colores
|
||||
std::vector<Uint8> color_; // Vector con los colores para el fade
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include "core/input/input.hpp" // Para Input, InputAction, Input::DO_NOT_ALLOW_REPEAT, REP...
|
||||
#include "core/locale/locale.hpp" // Para Locale
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "core/resources/resource_list.hpp" // Para Asset
|
||||
@@ -24,9 +24,9 @@
|
||||
// Constructor
|
||||
Title::Title()
|
||||
: game_logo_surface_(Resource::Cache::get()->getSurface("title_logo.gif")),
|
||||
game_logo_sprite_(std::make_unique<SurfaceSprite>(game_logo_surface_, 29, 9, game_logo_surface_->getWidth(), game_logo_surface_->getHeight())),
|
||||
game_logo_sprite_(std::make_unique<Sprite>(game_logo_surface_, 29, 9, game_logo_surface_->getWidth(), game_logo_surface_->getHeight())),
|
||||
loading_screen_surface_(Resource::Cache::get()->getSurface("loading_screen_color.gif")),
|
||||
loading_screen_sprite_(std::make_unique<SurfaceSprite>(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())),
|
||||
loading_screen_sprite_(std::make_unique<Sprite>(loading_screen_surface_, 0, 0, loading_screen_surface_->getWidth(), loading_screen_surface_->getHeight())),
|
||||
title_surface_(std::make_shared<Surface>(Options::game.width, Options::game.height)),
|
||||
delta_timer_(std::make_unique<DeltaTimer>()),
|
||||
marquee_text_(Resource::Cache::get()->getText("gauntlet")),
|
||||
@@ -491,7 +491,7 @@ void Title::createCheevosTexture() { // NOLINT(readability-convert-member-funct
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
|
||||
// Crea el sprite para el listado de logros (usa la zona del menu)
|
||||
cheevos_sprite_ = std::make_unique<SurfaceSprite>(cheevos_surface_, (GameCanvas::WIDTH - cheevos_surface_->getWidth()) / 2, MENU_ZONE_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
||||
cheevos_sprite_ = std::make_unique<Sprite>(cheevos_surface_, (GameCanvas::WIDTH - cheevos_surface_->getWidth()) / 2, MENU_ZONE_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
||||
cheevos_surface_view_ = {.x = 0, .y = 0, .w = cheevos_surface_->getWidth(), .h = CHEEVOS_TEXTURE_VIEW_HEIGHT};
|
||||
cheevos_sprite_->setClip(cheevos_surface_view_);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "game/scene_manager.hpp" // Para SceneManager::Scene
|
||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||
class SurfaceSprite; // Forward declaration
|
||||
class Sprite; // Forward declaration
|
||||
class Surface; // Forward declaration
|
||||
class Text; // Forward declaration
|
||||
|
||||
@@ -95,16 +95,16 @@ class Title {
|
||||
|
||||
// --- Variables miembro ---
|
||||
// Objetos y punteros
|
||||
std::shared_ptr<Surface> game_logo_surface_; // Textura con los graficos
|
||||
std::unique_ptr<SurfaceSprite> game_logo_sprite_; // SSprite para manejar la surface
|
||||
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
|
||||
std::unique_ptr<SurfaceSprite> loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga
|
||||
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
|
||||
std::unique_ptr<SurfaceSprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
|
||||
std::shared_ptr<Surface> title_surface_; // Surface donde se dibuja toda la clase
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Text> marquee_text_; // Texto para marquesina
|
||||
std::shared_ptr<Text> menu_text_; // Texto para los menus
|
||||
std::shared_ptr<Surface> game_logo_surface_; // Textura con los graficos
|
||||
std::unique_ptr<Sprite> game_logo_sprite_; // SSprite para manejar la surface
|
||||
std::shared_ptr<Surface> loading_screen_surface_; // Surface con los gráficos de la pantalla de carga
|
||||
std::unique_ptr<Sprite> loading_screen_sprite_; // SSprite con los gráficos de la pantalla de carga
|
||||
std::shared_ptr<Surface> cheevos_surface_; // Textura con la lista de logros
|
||||
std::unique_ptr<Sprite> cheevos_sprite_; // SSprite para manejar la surface con la lista de logros
|
||||
std::shared_ptr<Surface> title_surface_; // Surface donde se dibuja toda la clase
|
||||
std::unique_ptr<DeltaTimer> delta_timer_; // Timer para delta time
|
||||
std::shared_ptr<Text> marquee_text_; // Texto para marquesina
|
||||
std::shared_ptr<Text> menu_text_; // Texto para los menus
|
||||
|
||||
// Variables de estado de marquesina
|
||||
std::string long_text_; // Texto que aparece en la parte inferior del titulo
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#include "core/audio/audio.hpp" // Para Audio
|
||||
#include "core/rendering/screen.hpp" // Para Screen
|
||||
#include "core/rendering/sprite/sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/surface.hpp" // Para Surface
|
||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||
#include "core/rendering/text.hpp" // Para Text, Text::CENTER_FLAG, Text::COLOR_FLAG
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/options.hpp" // Para Options, options, NotificationPosition
|
||||
@@ -225,7 +225,7 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
|
||||
// Dibuja el icono de la notificación
|
||||
if (has_icons_ && icon >= 0 && texts.size() >= 2) {
|
||||
auto sp = std::make_unique<SurfaceSprite>(icon_surface_, SDL_FRect{.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
auto sp = std::make_unique<Sprite>(icon_surface_, SDL_FRect{.x = 0, .y = 0, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setPosition({.x = PADDING_IN_H, .y = PADDING_IN_V, .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->setClip(SDL_FRect{.x = ICON_SIZE * (icon % 10), .y = ICON_SIZE * (icon / 10), .w = ICON_SIZE, .h = ICON_SIZE});
|
||||
sp->render();
|
||||
@@ -253,7 +253,7 @@ void Notifier::show(std::vector<std::string> texts, const Style& style, int icon
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
|
||||
// Crea el sprite de la notificación
|
||||
n.sprite = std::make_shared<SurfaceSprite>(n.surface, n.rect);
|
||||
n.sprite = std::make_shared<Sprite>(n.surface, n.rect);
|
||||
|
||||
// Añade la notificación a la lista
|
||||
notifications_.emplace_back(n);
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string, basic_string
|
||||
#include <vector> // Para vector
|
||||
class SurfaceSprite; // lines 8-8
|
||||
class Surface; // lines 10-10
|
||||
class Text; // lines 9-9
|
||||
class DeltaTimer; // lines 11-11
|
||||
#include <memory> // Para shared_ptr
|
||||
#include <string> // Para string, basic_string
|
||||
#include <vector> // Para vector
|
||||
class Sprite; // lines 8-8
|
||||
class Surface; // lines 10-10
|
||||
class Text; // lines 9-9
|
||||
class DeltaTimer; // lines 11-11
|
||||
|
||||
class Notifier {
|
||||
public:
|
||||
@@ -70,7 +70,7 @@ class Notifier {
|
||||
|
||||
struct Notification {
|
||||
std::shared_ptr<Surface> surface{nullptr};
|
||||
std::shared_ptr<SurfaceSprite> sprite{nullptr};
|
||||
std::shared_ptr<Sprite> sprite{nullptr};
|
||||
std::vector<std::string> texts;
|
||||
Status state{Status::RISING};
|
||||
Shape shape{Shape::SQUARED};
|
||||
|
||||
Reference in New Issue
Block a user