eliminats metodes deprecated
migracions finals a time based migracions de jail_audio a Audio
This commit is contained in:
@@ -89,13 +89,20 @@ void Audio::stopMusic() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reproduce un sonido
|
// Reproduce un sonido por nombre
|
||||||
void Audio::playSound(const std::string& name, Group group) const {
|
void Audio::playSound(const std::string& name, Group group) const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
JA_PlaySound(Resource::get()->getSound(name), 0, static_cast<int>(group));
|
JA_PlaySound(Resource::get()->getSound(name), 0, static_cast<int>(group));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reproduce un sonido por puntero directo
|
||||||
|
void Audio::playSound(JA_Sound_t* sound, Group group) const {
|
||||||
|
if (sound_enabled_) {
|
||||||
|
JA_PlaySound(sound, 0, static_cast<int>(group));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Detiene todos los sonidos
|
// Detiene todos los sonidos
|
||||||
void Audio::stopAllSounds() const {
|
void Audio::stopAllSounds() const {
|
||||||
if (sound_enabled_) {
|
if (sound_enabled_) {
|
||||||
|
|||||||
@@ -42,8 +42,9 @@ class Audio {
|
|||||||
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
|
void fadeOutMusic(int milliseconds) const; // Fundido de salida de la música
|
||||||
|
|
||||||
// --- Control de Sonidos ---
|
// --- Control de Sonidos ---
|
||||||
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual
|
void playSound(const std::string& name, Group group = Group::GAME) const; // Reproducir sonido puntual por nombre
|
||||||
void stopAllSounds() const; // Detener todos los sonidos
|
void playSound(struct JA_Sound_t* sound, Group group = Group::GAME) const; // Reproducir sonido puntual por puntero
|
||||||
|
void stopAllSounds() const; // Detener todos los sonidos
|
||||||
|
|
||||||
// --- Configuración General ---
|
// --- Configuración General ---
|
||||||
void enable(bool value); // Establecer estado general
|
void enable(bool value); // Establecer estado general
|
||||||
|
|||||||
@@ -133,38 +133,6 @@ void SurfaceAnimatedSprite::animate(float delta_time) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación (frame-based, deprecated)
|
|
||||||
void SurfaceAnimatedSprite::animate() {
|
|
||||||
if (animations_[current_animation_].speed == 0.0F) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Calcula el frame actual a partir del contador (sistema antiguo)
|
|
||||||
animations_[current_animation_].current_frame =
|
|
||||||
static_cast<int>(animations_[current_animation_].counter / animations_[current_animation_].speed);
|
|
||||||
|
|
||||||
// Si alcanza el final de la animación, reinicia el contador de la animación
|
|
||||||
// en función de la variable loop y coloca el nuevo frame
|
|
||||||
if (animations_[current_animation_].current_frame >= static_cast<int>(animations_[current_animation_].frames.size())) {
|
|
||||||
if (animations_[current_animation_].loop == -1) { // Si no hay loop, deja el último frame
|
|
||||||
animations_[current_animation_].current_frame =
|
|
||||||
static_cast<int>(animations_[current_animation_].frames.size()) - 1;
|
|
||||||
animations_[current_animation_].completed = true;
|
|
||||||
} else { // Si hay loop, vuelve al frame indicado
|
|
||||||
animations_[current_animation_].counter = 0;
|
|
||||||
animations_[current_animation_].current_frame = animations_[current_animation_].loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// En caso contrario
|
|
||||||
else {
|
|
||||||
// Escoge el frame correspondiente de la animación
|
|
||||||
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
|
||||||
|
|
||||||
// Incrementa el contador de la animacion
|
|
||||||
animations_[current_animation_].counter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
auto SurfaceAnimatedSprite::animationIsCompleted() -> bool {
|
auto SurfaceAnimatedSprite::animationIsCompleted() -> bool {
|
||||||
return animations_[current_animation_].completed;
|
return animations_[current_animation_].completed;
|
||||||
@@ -176,8 +144,7 @@ void SurfaceAnimatedSprite::setCurrentAnimation(const std::string& name) {
|
|||||||
if (current_animation_ != NEW_ANIMATION) {
|
if (current_animation_ != NEW_ANIMATION) {
|
||||||
current_animation_ = NEW_ANIMATION;
|
current_animation_ = NEW_ANIMATION;
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
|
animations_[current_animation_].accumulated_time = 0.0F;
|
||||||
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
|
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
}
|
}
|
||||||
@@ -189,8 +156,7 @@ void SurfaceAnimatedSprite::setCurrentAnimation(int index) {
|
|||||||
if (current_animation_ != NEW_ANIMATION) {
|
if (current_animation_ != NEW_ANIMATION) {
|
||||||
current_animation_ = NEW_ANIMATION;
|
current_animation_ = NEW_ANIMATION;
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
|
animations_[current_animation_].accumulated_time = 0.0F;
|
||||||
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
|
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
}
|
}
|
||||||
@@ -202,17 +168,10 @@ void SurfaceAnimatedSprite::update(float delta_time) {
|
|||||||
SurfaceMovingSprite::update(delta_time);
|
SurfaceMovingSprite::update(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables del objeto (frame-based, deprecated)
|
|
||||||
void SurfaceAnimatedSprite::update() {
|
|
||||||
animate();
|
|
||||||
SurfaceMovingSprite::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reinicia la animación
|
// Reinicia la animación
|
||||||
void SurfaceAnimatedSprite::resetAnimation() {
|
void SurfaceAnimatedSprite::resetAnimation() {
|
||||||
animations_[current_animation_].current_frame = 0;
|
animations_[current_animation_].current_frame = 0;
|
||||||
animations_[current_animation_].accumulated_time = 0.0F; // Time-based
|
animations_[current_animation_].accumulated_time = 0.0F;
|
||||||
animations_[current_animation_].counter = 0; // Frame-based (deprecated)
|
|
||||||
animations_[current_animation_].completed = false;
|
animations_[current_animation_].completed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +315,6 @@ void SurfaceAnimatedSprite::setCurrentAnimationFrame(int num) {
|
|||||||
|
|
||||||
// Cambia el valor de la variable
|
// Cambia el valor de la variable
|
||||||
animations_[current_animation_].current_frame = num;
|
animations_[current_animation_].current_frame = num;
|
||||||
animations_[current_animation_].counter = 0;
|
|
||||||
|
|
||||||
// Escoge el frame correspondiente de la animación
|
// Escoge el frame correspondiente de la animación
|
||||||
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
setClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ struct AnimationData {
|
|||||||
int current_frame{0}; // Frame actual
|
int current_frame{0}; // Frame actual
|
||||||
float accumulated_time{0.0F}; // Tiempo acumulado para las animaciones (time-based)
|
float accumulated_time{0.0F}; // Tiempo acumulado para las animaciones (time-based)
|
||||||
|
|
||||||
// DEPRECATED: Mantener compatibilidad con sistema antiguo
|
|
||||||
int counter{0}; // Contador para las animaciones (frame-based, deprecated)
|
|
||||||
|
|
||||||
AnimationData()
|
AnimationData()
|
||||||
|
|
||||||
= default;
|
= default;
|
||||||
@@ -41,9 +38,6 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
|||||||
// Calcula el frame correspondiente a la animación actual (time-based)
|
// Calcula el frame correspondiente a la animación actual (time-based)
|
||||||
void animate(float delta_time);
|
void animate(float delta_time);
|
||||||
|
|
||||||
// Calcula el frame correspondiente a la animación actual (frame-based, deprecated)
|
|
||||||
void animate();
|
|
||||||
|
|
||||||
// Carga la animación desde un vector de cadenas
|
// Carga la animación desde un vector de cadenas
|
||||||
void setAnimations(const Animations& animations);
|
void setAnimations(const Animations& animations);
|
||||||
|
|
||||||
@@ -66,10 +60,6 @@ class SurfaceAnimatedSprite : public SurfaceMovingSprite {
|
|||||||
// Actualiza las variables del objeto (time-based)
|
// Actualiza las variables del objeto (time-based)
|
||||||
void update(float delta_time) override;
|
void update(float delta_time) override;
|
||||||
|
|
||||||
// Actualiza las variables del objeto (frame-based, deprecated)
|
|
||||||
[[deprecated("Use update(float delta_time) instead")]]
|
|
||||||
void update() override;
|
|
||||||
|
|
||||||
// Comprueba si ha terminado la animación
|
// Comprueba si ha terminado la animación
|
||||||
auto animationIsCompleted() -> bool;
|
auto animationIsCompleted() -> bool;
|
||||||
|
|
||||||
|
|||||||
@@ -62,29 +62,11 @@ void SurfaceMovingSprite::move(float delta_time) {
|
|||||||
pos_.y = static_cast<int>(y_);
|
pos_.y = static_cast<int>(y_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mueve el sprite (frame-based, deprecated)
|
|
||||||
void SurfaceMovingSprite::move() {
|
|
||||||
// Versión antigua: suma directa sin delta_time
|
|
||||||
x_ += vx_;
|
|
||||||
y_ += vy_;
|
|
||||||
|
|
||||||
vx_ += ax_;
|
|
||||||
vy_ += ay_;
|
|
||||||
|
|
||||||
pos_.x = static_cast<int>(x_);
|
|
||||||
pos_.y = static_cast<int>(y_);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza las variables internas del objeto (time-based)
|
// Actualiza las variables internas del objeto (time-based)
|
||||||
void SurfaceMovingSprite::update(float delta_time) {
|
void SurfaceMovingSprite::update(float delta_time) {
|
||||||
move(delta_time);
|
move(delta_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las variables internas del objeto (frame-based, deprecated)
|
|
||||||
void SurfaceMovingSprite::update() {
|
|
||||||
move();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
void SurfaceMovingSprite::render() {
|
void SurfaceMovingSprite::render() {
|
||||||
surface_->render(pos_.x, pos_.y, &clip_, flip_);
|
surface_->render(pos_.x, pos_.y, &clip_, flip_);
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ class SurfaceMovingSprite : public SurfaceSprite {
|
|||||||
// Mueve el sprite (time-based)
|
// Mueve el sprite (time-based)
|
||||||
void move(float delta_time);
|
void move(float delta_time);
|
||||||
|
|
||||||
// Mueve el sprite (frame-based, deprecated)
|
|
||||||
void move();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
|
SurfaceMovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
|
||||||
@@ -41,10 +38,6 @@ class SurfaceMovingSprite : public SurfaceSprite {
|
|||||||
// Actualiza las variables internas del objeto (time-based)
|
// Actualiza las variables internas del objeto (time-based)
|
||||||
void update(float delta_time) override;
|
void update(float delta_time) override;
|
||||||
|
|
||||||
// Actualiza las variables internas del objeto (frame-based, deprecated)
|
|
||||||
[[deprecated("Use update(float delta_time) instead")]]
|
|
||||||
void update() override;
|
|
||||||
|
|
||||||
// Reinicia todas las variables a cero
|
// Reinicia todas las variables a cero
|
||||||
void clear() override;
|
void clear() override;
|
||||||
|
|
||||||
|
|||||||
@@ -55,10 +55,4 @@ void SurfaceSprite::clear() {
|
|||||||
void SurfaceSprite::update(float delta_time) {
|
void SurfaceSprite::update(float delta_time) {
|
||||||
// Base implementation does nothing (static sprites)
|
// 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
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el estado del sprite (frame-based, deprecated)
|
|
||||||
void SurfaceSprite::update() {
|
|
||||||
// Llama a la versión time-based con 0.0f para compatibilidad
|
|
||||||
update(0.0F);
|
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,6 @@ class SurfaceSprite {
|
|||||||
// Actualiza el estado del sprite (time-based)
|
// Actualiza el estado del sprite (time-based)
|
||||||
virtual void update(float delta_time);
|
virtual void update(float delta_time);
|
||||||
|
|
||||||
// Actualiza el estado del sprite (frame-based, deprecated)
|
|
||||||
[[deprecated("Use update(float delta_time) instead")]]
|
|
||||||
virtual void update();
|
|
||||||
|
|
||||||
// Muestra el sprite por pantalla
|
// Muestra el sprite por pantalla
|
||||||
virtual void render();
|
virtual void render();
|
||||||
virtual void render(Uint8 source_color, Uint8 target_color);
|
virtual void render(Uint8 source_color, Uint8 target_color);
|
||||||
|
|||||||
@@ -6,10 +6,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ranges> // Para std::ranges::any_of
|
#include <ranges> // Para std::ranges::any_of
|
||||||
|
|
||||||
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "core/input/input.hpp" // Para Input, InputAction
|
#include "core/input/input.hpp" // Para Input, InputAction
|
||||||
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
#include "core/rendering/surface_animated_sprite.hpp" // Para SAnimatedSprite
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
#include "external/jail_audio.h" // Para JA_PlaySound
|
|
||||||
#include "game/gameplay/room.hpp" // Para Room, TileType
|
#include "game/gameplay/room.hpp" // Para Room, TileType
|
||||||
#include "game/options.hpp" // Para Cheat, Options, options
|
#include "game/options.hpp" // Para Cheat, Options, options
|
||||||
#include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
|
#include "utils/defines.hpp" // Para RoomBorder::BOTTOM, RoomBorder::LEFT, RoomBorder::RIGHT
|
||||||
@@ -414,7 +414,7 @@ void Player::playJumpSound() {
|
|||||||
|
|
||||||
// Solo reproduce cuando cambia de índice (nuevo hito alcanzado)
|
// Solo reproduce cuando cambia de índice (nuevo hito alcanzado)
|
||||||
if (SOUND_INDEX != PREVIOUS_INDEX && SOUND_INDEX < static_cast<int>(jumping_sound_.size())) {
|
if (SOUND_INDEX != PREVIOUS_INDEX && SOUND_INDEX < static_cast<int>(jumping_sound_.size())) {
|
||||||
JA_PlaySound(jumping_sound_[SOUND_INDEX]);
|
Audio::get()->playSound(jumping_sound_[SOUND_INDEX], Audio::Group::GAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ void Player::playFallSound() {
|
|||||||
|
|
||||||
// Solo reproduce cuando cambia de índice (nuevo hito alcanzado)
|
// Solo reproduce cuando cambia de índice (nuevo hito alcanzado)
|
||||||
if (SOUND_INDEX != PREVIOUS_INDEX && SOUND_INDEX < static_cast<int>(falling_sound_.size())) {
|
if (SOUND_INDEX != PREVIOUS_INDEX && SOUND_INDEX < static_cast<int>(falling_sound_.size())) {
|
||||||
JA_PlaySound(falling_sound_[SOUND_INDEX]);
|
Audio::get()->playSound(falling_sound_[SOUND_INDEX], Audio::Group::GAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
#include <sstream> // Para basic_stringstream
|
#include <sstream> // Para basic_stringstream
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "core/rendering/screen.hpp" // Para Screen
|
#include "core/rendering/screen.hpp" // Para Screen
|
||||||
#include "core/rendering/surface.hpp" // Para Surface
|
#include "core/rendering/surface.hpp" // Para Surface
|
||||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
#include "core/system/debug.hpp" // Para Debug
|
#include "core/system/debug.hpp" // Para Debug
|
||||||
#include "external/jail_audio.h" // Para JA_PlaySound
|
|
||||||
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
||||||
#include "game/gameplay/scoreboard.hpp" // Para ScoreboardData
|
#include "game/gameplay/scoreboard.hpp" // Para ScoreboardData
|
||||||
#include "game/options.hpp" // Para Options, OptionsStats, options
|
#include "game/options.hpp" // Para Options, OptionsStats, options
|
||||||
@@ -63,7 +63,7 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
surface_ = Resource::get()->getSurface(room.tile_set_file);
|
surface_ = Resource::get()->getSurface(room.tile_set_file);
|
||||||
tile_set_width_ = surface_->getWidth() / TILE_SIZE;
|
tile_set_width_ = surface_->getWidth() / TILE_SIZE;
|
||||||
is_paused_ = false;
|
is_paused_ = false;
|
||||||
counter_ = 0;
|
time_accumulator_ = 0.0F;
|
||||||
|
|
||||||
// Crear los enemigos
|
// Crear los enemigos
|
||||||
for (const auto& enemy_data : room.enemies) {
|
for (const auto& enemy_data : room.enemies) {
|
||||||
@@ -208,8 +208,8 @@ void Room::update(float delta_time) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el contador (mantenido para compatibilidad temporalmente)
|
// Actualiza el acumulador de tiempo
|
||||||
counter_++;
|
time_accumulator_ += delta_time;
|
||||||
|
|
||||||
// Actualiza los tiles animados
|
// Actualiza los tiles animados
|
||||||
updateAnimatedTiles();
|
updateAnimatedTiles();
|
||||||
@@ -309,7 +309,7 @@ auto Room::itemCollision(SDL_FRect& rect) -> bool {
|
|||||||
if (checkCollision(rect, items_.at(i)->getCollider())) {
|
if (checkCollision(rect, items_.at(i)->getCollider())) {
|
||||||
ItemTracker::get()->addItem(name_, items_.at(i)->getPos());
|
ItemTracker::get()->addItem(name_, items_.at(i)->getPos());
|
||||||
items_.erase(items_.begin() + i);
|
items_.erase(items_.begin() + i);
|
||||||
JA_PlaySound(Resource::get()->getSound("item.wav"));
|
Audio::get()->playSound("item.wav", Audio::Group::GAME);
|
||||||
data_->items++;
|
data_->items++;
|
||||||
Options::stats.items = data_->items;
|
Options::stats.items = data_->items;
|
||||||
return true;
|
return true;
|
||||||
@@ -653,11 +653,16 @@ void Room::setAnimatedTiles() {
|
|||||||
// Actualiza los tiles animados
|
// Actualiza los tiles animados
|
||||||
void Room::updateAnimatedTiles() {
|
void Room::updateAnimatedTiles() {
|
||||||
const int NUM_FRAMES = 4;
|
const int NUM_FRAMES = 4;
|
||||||
|
|
||||||
|
// Calcular frame actual basado en tiempo
|
||||||
|
const int current_frame = static_cast<int>(time_accumulator_ / CONVEYOR_FRAME_DURATION) % NUM_FRAMES;
|
||||||
|
|
||||||
|
// Calcular offset basado en dirección
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (conveyor_belt_direction_ == -1) {
|
if (conveyor_belt_direction_ == -1) {
|
||||||
offset = ((counter_ / 3) % NUM_FRAMES * TILE_SIZE);
|
offset = current_frame * TILE_SIZE;
|
||||||
} else {
|
} else {
|
||||||
offset = ((NUM_FRAMES - 1 - ((counter_ / 3) % NUM_FRAMES)) * TILE_SIZE);
|
offset = (NUM_FRAMES - 1 - current_frame) * TILE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& a : animated_tiles_) {
|
for (auto& a : animated_tiles_) {
|
||||||
|
|||||||
@@ -128,8 +128,11 @@ class Room {
|
|||||||
std::vector<LineVertical> right_walls_; // Lista con las superficies laterales de la parte derecha de la habitación
|
std::vector<LineVertical> right_walls_; // Lista con las superficies laterales de la parte derecha de la habitación
|
||||||
std::vector<LineDiagonal> left_slopes_; // Lista con todas las rampas que suben hacia la izquierda
|
std::vector<LineDiagonal> left_slopes_; // Lista con todas las rampas que suben hacia la izquierda
|
||||||
std::vector<LineDiagonal> right_slopes_; // Lista con todas las rampas que suben hacia la derecha
|
std::vector<LineDiagonal> right_slopes_; // Lista con todas las rampas que suben hacia la derecha
|
||||||
int counter_ = 0; // Contador para lo que haga falta
|
float time_accumulator_ = 0.0F; // Acumulador de tiempo para animaciones (time-based)
|
||||||
bool is_paused_ = false; // Indica si el mapa esta en modo pausa
|
bool is_paused_ = false; // Indica si el mapa esta en modo pausa
|
||||||
|
|
||||||
|
// Constantes de tiempo
|
||||||
|
static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame de conveyor belt (3 frames @ 60fps)
|
||||||
std::vector<AnimatedTile> animated_tiles_; // Vector con los indices de tiles animados
|
std::vector<AnimatedTile> animated_tiles_; // Vector con los indices de tiles animados
|
||||||
std::vector<LineHorizontal> conveyor_belt_floors_; // Lista con las superficies automaticas de la habitación
|
std::vector<LineHorizontal> conveyor_belt_floors_; // Lista con las superficies automaticas de la habitación
|
||||||
int tile_set_width_ = 0; // Ancho del tileset en tiles
|
int tile_set_width_ = 0; // Ancho del tileset en tiles
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "core/rendering/text.hpp" // Para Text, TEXT_STROKE
|
#include "core/rendering/text.hpp" // Para Text, TEXT_STROKE
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
#include "core/system/global_events.hpp" // Para check
|
#include "core/system/global_events.hpp" // Para check
|
||||||
#include "external/jail_audio.h" // Para JA_SetVolume, JA_PlayMusic, JA_StopMusic
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "game/options.hpp" // Para Options, options, OptionsGame, SectionS...
|
#include "game/options.hpp" // Para Options, options, OptionsGame, SectionS...
|
||||||
#include "game/scene_manager.hpp" // Para SceneManager
|
#include "game/scene_manager.hpp" // Para SceneManager
|
||||||
#include "utils/defines.hpp" // Para GAME_SPEED
|
#include "utils/defines.hpp" // Para GAME_SPEED
|
||||||
@@ -60,9 +60,6 @@ void Ending::update() {
|
|||||||
// Actualiza las cortinillas de los elementos
|
// Actualiza las cortinillas de los elementos
|
||||||
updateSpriteCovers();
|
updateSpriteCovers();
|
||||||
|
|
||||||
// Actualiza el volumen de la musica
|
|
||||||
updateMusicVolume();
|
|
||||||
|
|
||||||
// Actualiza el objeto Screen
|
// Actualiza el objeto Screen
|
||||||
Screen::get()->update(current_delta_);
|
Screen::get()->update(current_delta_);
|
||||||
}
|
}
|
||||||
@@ -423,7 +420,7 @@ void Ending::iniScenes() {
|
|||||||
|
|
||||||
// Bucle principal
|
// Bucle principal
|
||||||
void Ending::run() {
|
void Ending::run() {
|
||||||
JA_PlayMusic(Resource::get()->getMusic("ending1.ogg"));
|
Audio::get()->playMusic("ending1.ogg");
|
||||||
|
|
||||||
while (SceneManager::current == SceneManager::Scene::ENDING) {
|
while (SceneManager::current == SceneManager::Scene::ENDING) {
|
||||||
update();
|
update();
|
||||||
@@ -431,8 +428,7 @@ void Ending::run() {
|
|||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
|
|
||||||
JA_StopMusic();
|
Audio::get()->stopMusic();
|
||||||
JA_SetVolume(128);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza las cortinillas de los elementos
|
// Actualiza las cortinillas de los elementos
|
||||||
@@ -589,15 +585,4 @@ void Ending::renderCoverTexture() {
|
|||||||
SDL_FRect dst_rect = {0.0F, 0.0F, 256.0F, FADEOUT_COUNTER * 2.0F};
|
SDL_FRect dst_rect = {0.0F, 0.0F, 256.0F, FADEOUT_COUNTER * 2.0F};
|
||||||
cover_surface_->render(&src_rect, &dst_rect);
|
cover_surface_->render(&src_rect, &dst_rect);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Actualiza el volumen de la musica
|
|
||||||
void Ending::updateMusicVolume() const {
|
|
||||||
if (state_ == State::SCENE_4 && fadeout_time_ > 0.0F) {
|
|
||||||
// Convertir fadeout_time_ a equivalente de cover_counter_ @ 60fps
|
|
||||||
const float FADEOUT_COUNTER = std::min(fadeout_time_ * 60.0F, 100.0F);
|
|
||||||
const float STEP = (100.0F - FADEOUT_COUNTER) / 100.0F;
|
|
||||||
const int VOLUME = static_cast<int>(128.0F * STEP);
|
|
||||||
JA_SetVolume(VOLUME);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
#include "core/resources/resource.hpp" // Para ResourceRoom, Resource
|
#include "core/resources/resource.hpp" // Para ResourceRoom, Resource
|
||||||
#include "core/system/debug.hpp" // Para Debug
|
#include "core/system/debug.hpp" // Para Debug
|
||||||
#include "core/system/global_events.hpp" // Para check
|
#include "core/system/global_events.hpp" // Para check
|
||||||
#include "external/jail_audio.h" // Para JA_PauseMusic, JA_GetMusicState, JA_P...
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
#include "game/gameplay/cheevos.hpp" // Para Cheevos
|
||||||
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
#include "game/gameplay/item_tracker.hpp" // Para ItemTracker
|
||||||
#include "game/gameplay/room.hpp" // Para Room, RoomData
|
#include "game/gameplay/room.hpp" // Para Room, RoomData
|
||||||
@@ -83,7 +83,7 @@ void Game::checkEvents() {
|
|||||||
void Game::checkInput() {
|
void Game::checkInput() {
|
||||||
if (Input::get()->checkInput(InputAction::TOGGLE_MUSIC, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
if (Input::get()->checkInput(InputAction::TOGGLE_MUSIC, INPUT_DO_NOT_ALLOW_REPEAT)) {
|
||||||
board_->music = !board_->music;
|
board_->music = !board_->music;
|
||||||
board_->music ? JA_ResumeMusic() : JA_PauseMusic();
|
board_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||||
Notifier::get()->show({"MUSIC " + std::string(board_->music ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
Notifier::get()->show({"MUSIC " + std::string(board_->music ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ void Game::checkInput() {
|
|||||||
void Game::run() {
|
void Game::run() {
|
||||||
keepMusicPlaying();
|
keepMusicPlaying();
|
||||||
if (!board_->music && mode_ == Mode::GAME) {
|
if (!board_->music && mode_ == Mode::GAME) {
|
||||||
JA_PauseMusic();
|
Audio::get()->pauseMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (SceneManager::current == SceneManager::Scene::GAME || SceneManager::current == SceneManager::Scene::DEMO) {
|
while (SceneManager::current == SceneManager::Scene::GAME || SceneManager::current == SceneManager::Scene::DEMO) {
|
||||||
@@ -109,7 +109,7 @@ void Game::run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mode_ == Mode::GAME) {
|
if (mode_ == Mode::GAME) {
|
||||||
JA_StopMusic();
|
Audio::get()->stopMusic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ void Game::checkDebugEvents(const SDL_Event& event) {
|
|||||||
Debug::get()->toggleEnabled();
|
Debug::get()->toggleEnabled();
|
||||||
Options::cheats.invincible = static_cast<Options::Cheat::State>(Debug::get()->getEnabled());
|
Options::cheats.invincible = static_cast<Options::Cheat::State>(Debug::get()->getEnabled());
|
||||||
board_->music = !Debug::get()->getEnabled();
|
board_->music = !Debug::get()->getEnabled();
|
||||||
board_->music ? JA_ResumeMusic() : JA_PauseMusic();
|
board_->music ? Audio::get()->resumeMusic() : Audio::get()->pauseMusic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_SCANCODE_R:
|
case SDL_SCANCODE_R:
|
||||||
@@ -356,7 +356,7 @@ void Game::killPlayer() {
|
|||||||
Cheevos::get()->setUnobtainable(11);
|
Cheevos::get()->setUnobtainable(11);
|
||||||
|
|
||||||
// Sonido
|
// Sonido
|
||||||
JA_PlaySound(Resource::get()->getSound("death.wav"));
|
Audio::get()->playSound("death.wav", Audio::Group::GAME);
|
||||||
|
|
||||||
// Pone la pantalla en negro un tiempo
|
// Pone la pantalla en negro un tiempo
|
||||||
setBlackScreen();
|
setBlackScreen();
|
||||||
@@ -469,7 +469,7 @@ void Game::checkRestoringJail(float delta_time) {
|
|||||||
if (jail_restore_time_ >= JAIL_RESTORE_INTERVAL) {
|
if (jail_restore_time_ >= JAIL_RESTORE_INTERVAL) {
|
||||||
jail_restore_time_ -= JAIL_RESTORE_INTERVAL; // Mantiene el excedente para precisión
|
jail_restore_time_ -= JAIL_RESTORE_INTERVAL; // Mantiene el excedente para precisión
|
||||||
board_->lives++;
|
board_->lives++;
|
||||||
JA_PlaySound(Resource::get()->getSound("death.wav"));
|
Audio::get()->playSound("death.wav", Audio::Group::GAME);
|
||||||
|
|
||||||
// Invalida el logro de completar el juego sin entrar a la jail
|
// Invalida el logro de completar el juego sin entrar a la jail
|
||||||
const bool HAVE_THE_ITEMS = board_->items >= int(total_items_ * 0.9F);
|
const bool HAVE_THE_ITEMS = board_->items >= int(total_items_ * 0.9F);
|
||||||
@@ -587,9 +587,9 @@ void Game::keepMusicPlaying() {
|
|||||||
const std::string MUSIC_PATH = mode_ == Mode::GAME ? "game.ogg" : "title.ogg";
|
const std::string MUSIC_PATH = mode_ == Mode::GAME ? "game.ogg" : "title.ogg";
|
||||||
|
|
||||||
// Si la música no está sonando
|
// Si la música no está sonando
|
||||||
if (JA_GetMusicState() == JA_MUSIC_INVALID || JA_GetMusicState() == JA_MUSIC_STOPPED) {
|
if (Audio::get()->getMusicState() == Audio::MusicState::STOPPED) {
|
||||||
JA_PlayMusic(Resource::get()->getMusic(MUSIC_PATH));
|
Audio::get()->playMusic(MUSIC_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEMO MODE: Inicializa las variables para el modo demo
|
// DEMO MODE: Inicializa las variables para el modo demo
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "core/rendering/text.hpp" // Para TEXT_CENTER, TEXT_COLOR, Text
|
#include "core/rendering/text.hpp" // Para TEXT_CENTER, TEXT_COLOR, Text
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
#include "core/system/global_events.hpp" // Para check
|
#include "core/system/global_events.hpp" // Para check
|
||||||
#include "external/jail_audio.h" // Para JA_PlayMusic
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "game/options.hpp" // Para Options, options, OptionsStats, Secti...
|
#include "game/options.hpp" // Para Options, options, OptionsStats, Secti...
|
||||||
#include "game/scene_manager.hpp" // Para SceneManager
|
#include "game/scene_manager.hpp" // Para SceneManager
|
||||||
#include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X
|
#include "utils/defines.hpp" // Para GAMECANVAS_CENTER_X
|
||||||
@@ -172,7 +172,7 @@ void GameOver::updateState() {
|
|||||||
state_ = State::FADE_IN;
|
state_ = State::FADE_IN;
|
||||||
elapsed_time_ = 0.0f;
|
elapsed_time_ = 0.0f;
|
||||||
// Hace sonar la música cuando termina la espera
|
// Hace sonar la música cuando termina la espera
|
||||||
JA_PlayMusic(Resource::get()->getMusic("game_over.ogg"), 0);
|
Audio::get()->playMusic("game_over.ogg", 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
#include "core/rendering/surface_sprite.hpp" // Para SSprite
|
||||||
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
#include "core/rendering/text.hpp" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||||
#include "core/resources/resource.hpp" // Para Resource
|
#include "core/resources/resource.hpp" // Para Resource
|
||||||
#include "external/jail_audio.h" // Para JA_PlaySound
|
#include "core/audio/audio.hpp" // Para Audio
|
||||||
#include "game/options.hpp" // Para Options, options, NotificationPosition
|
#include "game/options.hpp" // Para Options, options, NotificationPosition
|
||||||
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
#include "utils/delta_timer.hpp" // Para DeltaTimer
|
||||||
#include "utils/utils.hpp" // Para PaletteColor
|
#include "utils/utils.hpp" // Para PaletteColor
|
||||||
@@ -240,7 +240,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
|||||||
notifications_.emplace_back(n);
|
notifications_.emplace_back(n);
|
||||||
|
|
||||||
// Reproduce el sonido de la notificación
|
// Reproduce el sonido de la notificación
|
||||||
JA_PlaySound(Resource::get()->getSound("notify.wav"));
|
Audio::get()->playSound("notify.wav", Audio::Group::INTERFACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indica si hay notificaciones activas
|
// Indica si hay notificaciones activas
|
||||||
|
|||||||
Reference in New Issue
Block a user