Continue arreglant cosetes amb cppcheck

This commit is contained in:
2024-10-24 20:36:30 +02:00
parent a5c72a0f65
commit 43e7b83403
80 changed files with 4830 additions and 3461 deletions

View File

@@ -1,10 +1,10 @@
#include "animated_sprite.h" #include "animated_sprite.h"
#include <algorithm> // for copy #include <algorithm> // para copy
#include <fstream> // for basic_ostream, operator<<, basic_istream, basic... #include <fstream> // para basic_ostream, operator<<, basic_istream, basic...
#include <iostream> // for cout #include <iostream> // para cout
#include <iterator> // for back_insert_iterator, back_inserter #include <iterator> // para back_insert_iterator, back_inserter
#include <sstream> // for basic_stringstream #include <sstream> // para basic_stringstream
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" #include "utils.h"
// Carga las animaciones en un vector(Animations) desde un fichero // Carga las animaciones en un vector(Animations) desde un fichero
@@ -106,65 +106,18 @@ void AnimatedSprite::animate()
} }
} }
// Obtiene el número de frames de la animación actual
int AnimatedSprite::getNumFrames()
{
return (int)animations_[current_animation_].frames.size();
}
// Establece el frame actual de la animación
void AnimatedSprite::setCurrentFrame(int num)
{
// Descarta valores fuera de rango
if (num >= (int)animations_[current_animation_].frames.size())
{
num = 0;
}
// Cambia el valor de la variable
animations_[current_animation_].current_frame = num;
animations_[current_animation_].counter = 0;
// Escoge el frame correspondiente de la animación
setSpriteClip(animations_[current_animation_].frames[animations_[current_animation_].current_frame]);
}
// Establece el valor del contador
void AnimatedSprite::setAnimationCounter(const std::string &name, int num)
{
animations_[getIndex(name)].counter = num;
}
// Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(const std::string &name, int speed)
{
animations_[getIndex(name)].counter = speed;
}
// Establece la velocidad de una animación // Establece la velocidad de una animación
void AnimatedSprite::setAnimationSpeed(int index, int speed) void AnimatedSprite::setAnimationSpeed(int index, int speed)
{ {
animations_[index].counter = speed; animations_[index].counter = speed;
} }
// Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(const std::string &name, int loop)
{
animations_[getIndex(name)].loop = loop;
}
// Establece si la animación se reproduce en bucle // Establece si la animación se reproduce en bucle
void AnimatedSprite::setAnimationLoop(int index, int loop) void AnimatedSprite::setAnimationLoop(int index, int loop)
{ {
animations_[index].loop = loop; animations_[index].loop = loop;
} }
// Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(const std::string &name, bool value)
{
animations_[getIndex(name)].completed = value;
}
// OLD - Establece el valor de la variable // OLD - Establece el valor de la variable
void AnimatedSprite::setAnimationCompleted(int index, bool value) void AnimatedSprite::setAnimationCompleted(int index, bool value)
{ {
@@ -222,21 +175,6 @@ void AnimatedSprite::update()
MovingSprite::update(); MovingSprite::update();
} }
// Establece el rectangulo para un frame de una animación
void AnimatedSprite::setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h)
{
animations_[index_animation].frames.push_back({x, y, w, h});
}
// OLD - Establece el contador para todas las animaciones
void AnimatedSprite::setAnimationCounter(int value)
{
for (auto &a : animations_)
{
a.counter = value;
}
}
// Reinicia la animación // Reinicia la animación
void AnimatedSprite::resetAnimation() void AnimatedSprite::resetAnimation()
{ {

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
#include <memory> // for shared_ptr #include <memory> // para shared_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // para MovingSprite
class Texture; class Texture;
struct Animation struct Animation
@@ -52,25 +52,15 @@ public:
// Actualiza las variables del objeto // Actualiza las variables del objeto
void update() override; void update() override;
// Obtiene el número de frames de la animación actual
int getNumFrames();
// Establece el frame actual de la animación
void setCurrentFrame(int num);
// Establece el valor del contador
void setAnimationCounter(const std::string &name, int num);
// Establece la velocidad de una animación // Establece la velocidad de una animación
void setAnimationSpeed(const std::string &name, int speed);
void setAnimationSpeed(int index, int speed); void setAnimationSpeed(int index, int speed);
// Establece el frame al que vuelve la animación al finalizar // Establece el frame al que vuelve la animación al finalizar
void setAnimationLoop(const std::string &name, int loop); //void setAnimationLoop(const std::string &name, int loop);
void setAnimationLoop(int index, int loop); void setAnimationLoop(int index, int loop);
// Establece el valor de la variable // Establece el valor de la variable
void setAnimationCompleted(const std::string &name, bool value); //void setAnimationCompleted(const std::string &name, bool value);
void setAnimationCompleted(int index, bool value); void setAnimationCompleted(int index, bool value);
// Comprueba si ha terminado la animación // Comprueba si ha terminado la animación
@@ -87,12 +77,6 @@ public:
void setCurrentAnimation(const std::string &name = "default"); void setCurrentAnimation(const std::string &name = "default");
void setCurrentAnimation(int index = 0); void setCurrentAnimation(int index = 0);
// OLD - Establece el rectangulo para un frame de una animación
void setAnimationFrames(Uint8 index_animation, Uint8 index_frame, int x, int y, int w, int h);
// OLD - Establece el contador para todas las animaciones
void setAnimationCounter(int value);
// Reinicia la animación // Reinicia la animación
void resetAnimation(); void resetAnimation();
}; };

View File

@@ -1,11 +1,12 @@
#include "asset.h" #include "asset.h"
#include "utils.h" #include "utils.h"
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_RWops #include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_RWops
#include <SDL2/SDL_stdinc.h> // for SDL_max #include <SDL2/SDL_stdinc.h> // para SDL_max
#include <stddef.h> // for size_t #include <stddef.h> // para size_t
#include <iostream> // for basic_ostream, operator<<, cout, endl #include <iostream> // para basic_ostream, operator<<, cout, endl
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <algorithm> // Para std::find_if
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Asset *Asset::asset_ = nullptr; Asset *Asset::asset_ = nullptr;
@@ -38,16 +39,21 @@ void Asset::add(const std::string &file, AssetType type, bool required, bool abs
// Devuelve la ruta completa a un fichero a partir de una cadena // Devuelve la ruta completa a un fichero a partir de una cadena
std::string Asset::get(const std::string &text) const std::string Asset::get(const std::string &text) const
{ {
for (const auto &f : file_list_) auto it = std::find_if(file_list_.begin(), file_list_.end(),
{ [&text, this](const auto &f)
if (getFileName(f.file) == text) {
{ return getFileName(f.file) == text;
return f.file; });
}
}
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl; if (it != file_list_.end())
return ""; {
return it->file;
}
else
{
std::cout << "Warning: file " << text << " not found" << std::endl;
return "";
}
} }
// Comprueba que existen todos los elementos // Comprueba que existen todos los elementos

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> // for string, basic_string #include <string> // para string, basic_string
#include <vector> // for vector #include <vector> // para vector
#include "utils.h" #include "utils.h"
enum class AssetType : int enum class AssetType : int

View File

@@ -1,14 +1,14 @@
#include "background.h" #include "background.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <algorithm> // for clamp, max #include <algorithm> // para clamp, max
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // para MovingSprite
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" #include "screen.h"
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
// Constructor // Constructor
Background::Background() Background::Background()

View File

@@ -1,9 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include "utils.h" // for Color #include "utils.h" // para Color
class MovingSprite; class MovingSprite;
class Sprite; class Sprite;
class Texture; class Texture;

View File

@@ -1,10 +1,10 @@
#include "balloon.h" #include "balloon.h"
#include <cmath> // for abs #include <cmath> // para abs
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // para MovingSprite
#include "param.h" // for param #include "param.h" // para param
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
// Constructor // Constructor
Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation) Balloon::Balloon(float x, float y, Uint8 kind, float vel_x, float speed, Uint16 creation_timer, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32 #include <SDL2/SDL_stdinc.h> // para Uint8, Uint16, Uint32
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "utils.h" // for Circle #include "utils.h" // para Circle
class Texture; class Texture;
// Cantidad de elementos del vector con los valores de la deformación del globo al rebotar // Cantidad de elementos del vector con los valores de la deformación del globo al rebotar

View File

@@ -1,7 +1,7 @@
#include "balloon_formations.h" #include "balloon_formations.h"
#include "balloon.h" // for BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE #include "balloon.h" // para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include "param.h" // for param #include "param.h" // para param
#include "utils.h" // for ParamGame, Param, Zone, BLOCK #include "utils.h" // para ParamGame, Param, Zone, BLOCK
// Constructor // Constructor
BalloonFormations::BalloonFormations() BalloonFormations::BalloonFormations()

View File

@@ -1,7 +1,7 @@
#include "bullet.h" #include "bullet.h"
#include <memory> // for unique_ptr, make_unique, shared_ptr #include <memory> // para unique_ptr, make_unique, shared_ptr
#include "param.h" // for param #include "param.h" // para param
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
class Texture; class Texture;
constexpr int BULLET_WIDTH = 12; constexpr int BULLET_WIDTH = 12;

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "utils.h" // for Circle #include "utils.h" // para Circle
class Texture; class Texture;
// Enumeración para los diferentes tipos de balas // Enumeración para los diferentes tipos de balas

View File

@@ -1,7 +1,7 @@
#include "dbgtxt.h" #include "dbgtxt.h"
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_rwops.h> // for SDL_RWFromMem #include <SDL2/SDL_rwops.h> // para SDL_RWFromMem
#include <SDL2/SDL_surface.h> // for SDL_LoadBMP_RW #include <SDL2/SDL_surface.h> // para SDL_LoadBMP_RW
namespace namespace
{ {

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
void dbg_init(SDL_Renderer *renderer); void dbg_init(SDL_Renderer *renderer);
void dbg_print(int x, int y, const char *text, Uint8 r, Uint8 g, Uint8 b); void dbg_print(int x, int y, const char *text, Uint8 r, Uint8 g, Uint8 b);

View File

@@ -1,12 +1,12 @@
#include "define_buttons.h" #include "define_buttons.h"
#include <utility> // for move #include <utility> // para move
#include "input.h" // for Input, InputType #include "input.h" // para Input, InputType
#include "lang.h" // for getText #include "lang.h" // para getText
#include "options.h" // for options #include "options.h" // para options
#include "param.h" // for param #include "param.h" // para param
#include "section.h" // for Name, Options, name, options #include "section.h" // para Name, Options, name, options
#include "text.h" // for Text #include "text.h" // para Text
#include "utils.h" // for OptionsController, Options, Param, ParamGame #include "utils.h" // para OptionsController, Options, Param, ParamGame
// Constructor // Constructor
DefineButtons::DefineButtons(std::unique_ptr<Text> text_) DefineButtons::DefineButtons(std::unique_ptr<Text> text_)

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_ControllerButtonEvent #include <SDL2/SDL_events.h> // para SDL_ControllerButtonEvent
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton #include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
class Input; class Input;
class Text; class Text;
enum class InputType : int; enum class InputType : int;

View File

@@ -1,47 +1,47 @@
#include "director.h" #include "director.h"
#include <SDL2/SDL.h> // for SDL_Init, SDL_Quit, SDL_INIT_EV... #include <SDL2/SDL.h> // para SDL_Init, SDL_Quit, SDL_INIT_EV...
#include <SDL2/SDL_audio.h> // for AUDIO_S16 #include <SDL2/SDL_audio.h> // para AUDIO_S16
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // for SDL_GetError #include <SDL2/SDL_error.h> // para SDL_GetError
#include <SDL2/SDL_gamecontroller.h> // for SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // for SDL_SetHint, SDL_HINT_RENDER_DR... #include <SDL2/SDL_hints.h> // para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_0, SDL_SCANCODE_DOWN #include <SDL2/SDL_scancode.h> // para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // for SDL_bool, Uint32 #include <SDL2/SDL_stdinc.h> // para SDL_bool, Uint32
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <cstdlib> // for system #include <cstdlib> // para system
#include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO... #include <errno.h> // para errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // for printf, perror #include <stdio.h> // para printf, perror
#include <string.h> // for strcmp #include <string.h> // para strcmp
#include <sys/stat.h> // for mkdir, stat, S_IRWXU #include <sys/stat.h> // para mkdir, stat, S_IRWXU
#include <unistd.h> // for getuid #include <unistd.h> // para getuid
#include <cstdlib> // for exit, EXIT_FAILURE, rand, srand #include <cstdlib> // para exit, EXIT_FAILURE, rand, srand
#include <iostream> // for basic_ostream, operator<<, cout #include <iostream> // para basic_ostream, operator<<, cout
#include <memory> // for make_unique, unique_ptr #include <memory> // para make_unique, unique_ptr
#include <string> // for operator+, allocator, char_traits #include <string> // para operator+, allocator, char_traits
#include "asset.h" // for Asset, AssetType #include "asset.h" // para Asset, AssetType
#include "dbgtxt.h" // for dbg_init #include "dbgtxt.h" // para dbg_init
#include "game.h" // for Game, GAME_MODE_DEMO_OFF, GAME_... #include "game.h" // para Game, GAME_MODE_DEMO_OFF, GAME_...
#include "global_inputs.h" // for init #include "global_inputs.h" // para init
#include "hiscore_table.h" // for HiScoreTable #include "hiscore_table.h" // para HiScoreTable
#include "input.h" // for Input, InputType #include "input.h" // para Input, InputType
#include "instructions.h" // for Instructions #include "instructions.h" // para Instructions
#include "intro.h" // for Intro #include "intro.h" // para Intro
#include "jail_audio.h" // for JA_LoadMusic, JA_LoadSound, JA_... #include "jail_audio.h" // para JA_LoadMusic, JA_LoadSound, JA_...
#include "lang.h" // for Code, loadFromFile #include "lang.h" // para Code, loadFromFile
#include "logo.h" // for Logo #include "logo.h" // para Logo
#include "manage_hiscore_table.h" // for ManageHiScoreTable #include "manage_hiscore_table.h" // para ManageHiScoreTable
#include "notifier.h" // for Notifier #include "notifier.h" // para Notifier
#include "on_screen_help.h" // for OnScreenHelp #include "on_screen_help.h" // para OnScreenHelp
#include "options.h" // for options, loadOptionsFile, saveO... #include "options.h" // para options, loadOptionsFile, saveO...
#include "param.h" // for param, loadParamsFromFile #include "param.h" // para param, loadParamsFromFile
#include "resource.h" //for Resource #include "resource.h" //for Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "title.h" // for Title #include "title.h" // para Title
#include "utils.h" // for MusicFile, SoundFile, Options #include "utils.h" // para MusicFile, SoundFile, Options
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> // for getpwuid, passwd #include <pwd.h> // para getpwuid, passwd
#endif #endif
// Constructor // Constructor
@@ -770,4 +770,4 @@ void Director::shutdownSystem()
#error "Sistema operativo no soportado" #error "Sistema operativo no soportado"
#endif #endif
} }
#endif //ARCADE #endif // ARCADE

View File

@@ -1,9 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // para SDL_Window
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
namespace lang namespace lang
{ {
enum class Code : int; enum class Code : int;
@@ -23,8 +23,8 @@ private:
std::streambuf *orig_buf; // Puntero al buffer de flujo original para restaurar std::cout std::streambuf *orig_buf; // Puntero al buffer de flujo original para restaurar std::cout
// Variables // Variables
std::string executable_path_; // Path del ejecutable std::string executable_path_; // Path del ejecutable
std::string system_folder_; // Carpeta del sistema donde guardar datos std::string system_folder_; // Carpeta del sistema donde guardar datos
// Inicializa jail_audio // Inicializa jail_audio
void initJailAudio(); void initJailAudio();

View File

@@ -1,5 +1,5 @@
#include "enter_name.h" #include "enter_name.h"
#include <algorithm> // for max, min #include <algorithm> // para max, min
// Constructor // Constructor
EnterName::EnterName() EnterName::EnterName()

View File

@@ -1,6 +1,6 @@
#include "explosions.h" #include "explosions.h"
#include <utility> // for move #include <utility> // para move
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
class Texture; // lines 3-3 class Texture; // lines 3-3
// Constructor // Constructor

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
class AnimatedSprite; class AnimatedSprite;
class Texture; class Texture;

View File

@@ -1,11 +1,11 @@
#include "fade.h" #include "fade.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_NONE
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // for rand #include <stdlib.h> // para rand
#include <algorithm> // for min, max #include <algorithm> // para min, max
#include "param.h" // for param #include "param.h" // para param
#include "screen.h" #include "screen.h"
#include "utils.h" // for Param, ParamGame, ParamFade #include "utils.h" // para Param, ParamGame, ParamFade
// Constructor // Constructor
Fade::Fade() Fade::Fade()

View File

@@ -1,9 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16 #include <SDL2/SDL_stdinc.h> // para Uint8, Uint16
#include <vector> // for vector #include <vector> // para vector
// Tipos de fundido // Tipos de fundido
enum class FadeType : Uint8 enum class FadeType : Uint8

View File

@@ -1,41 +1,41 @@
#include "game.h" #include "game.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3, SDLK_4 #include <SDL2/SDL_keycode.h> // para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_R... #include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_R...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_FOCUS_GAINED, SDL_... #include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_FOCUS_GAINED, SDL_...
#include <stdlib.h> // for rand #include <stdlib.h> // para rand
#include <algorithm> // for min, remove_if #include <algorithm> // para min, remove_if
#include <fstream> // for basic_ostream, operator<<, basic_i... #include <fstream> // para basic_ostream, operator<<, basic_i...
#include <iostream> // for cout #include <iostream> // para cout
#include <numeric> // for accumulate #include <numeric> // para accumulate
#include <utility> // for move #include <utility> // para move
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "background.h" // for Background #include "background.h" // para Background
#include "balloon.h" // for Balloon, BALLOON_SCORE_1, BALLOON_... #include "balloon.h" // para Balloon, BALLOON_SCORE_1, BALLOON_...
#include "balloon_formations.h" // for Stage, BalloonFormationParams, Bal... #include "balloon_formations.h" // para Stage, BalloonFormationParams, Bal...
#include "bullet.h" // for Bullet, BulletType, BulletMoveStatus #include "bullet.h" // para Bullet, BulletType, BulletMoveStatus
#include "explosions.h" // for Explosions #include "explosions.h" // para Explosions
#include "fade.h" // for Fade, FadeType #include "fade.h" // para Fade, FadeType
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for InputType, Input, INPUT_DO_NOT_ALL... #include "input.h" // para InputType, Input, INPUT_DO_NOT_ALL...
#include "item.h" // for Item, ItemType::COFFEE_MACHINE, ItemType::CLOCK #include "item.h" // para Item, ItemType::COFFEE_MACHINE, ItemType::CLOCK
#include "jail_audio.h" // for JA_PlaySound #include "jail_audio.h" // para JA_PlaySound
#include "lang.h" // for getText #include "lang.h" // para getText
#include "manage_hiscore_table.h" // for ManageHiScoreTable #include "manage_hiscore_table.h" // para ManageHiScoreTable
#include "notifier.h" // for Notifier #include "notifier.h" // para Notifier
#include "options.h" // for options #include "options.h" // para options
#include "param.h" // for param #include "param.h" // para param
#include "player.h" // for Player, PlayerStatus #include "player.h" // para Player, PlayerStatus
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "scoreboard.h" // for Scoreboard, ScoreboardMode, SCOREB... #include "scoreboard.h" // para Scoreboard, ScoreboardMode, SCOREB...
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "smart_sprite.h" // for SpriteSmart #include "smart_sprite.h" // para SpriteSmart
#include "text.h" // for Text, TEXT_CENTER #include "text.h" // para Text, TEXT_CENTER
#include "texture.h" // for Texture #include "texture.h" // para Texture
struct JA_Music_t; // lines 35-35 struct JA_Music_t; // lines 35-35
struct JA_Sound_t; // lines 36-36 struct JA_Sound_t; // lines 36-36
#include "dbgtxt.h" #include "dbgtxt.h"

View File

@@ -1,13 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "balloon.h" // for Balloon #include "balloon.h" // para Balloon
#include "player.h" // for Player #include "player.h" // para Player
#include "utils.h" // for DemoKeys, Color, HiScoreEntry #include "utils.h" // para DemoKeys, Color, HiScoreEntry
class Asset; class Asset;
class Background; class Background;
class BalloonFormations; class BalloonFormations;

View File

@@ -1,16 +1,16 @@
#include "game_logo.h" #include "game_logo.h"
#include <SDL2/SDL_render.h> // for SDL_FLIP_HORIZONTAL #include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL
#include <algorithm> // for max #include <algorithm> // para max
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "jail_audio.h" // JA_PlaySound #include "jail_audio.h" // JA_PlaySound
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "smart_sprite.h" // for SpriteSmart #include "smart_sprite.h" // para SpriteSmart
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" // for Param, ParamGame, ParamTitle #include "utils.h" // para Param, ParamGame, ParamTitle
// Constructor // Constructor
GameLogo::GameLogo(int x, int y) GameLogo::GameLogo(int x, int y)
@@ -27,7 +27,6 @@ GameLogo::GameLogo(int x, int y)
arcade_edition_sprite_(std::make_unique<Sprite>(arcade_edition_texture_, (param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight())), arcade_edition_sprite_(std::make_unique<Sprite>(arcade_edition_texture_, (param.game.width - arcade_edition_texture_->getWidth()) / 2, param.title.arcade_edition_position, arcade_edition_texture_->getWidth(), arcade_edition_texture_->getHeight())),
x_(x), x_(x),
y_(y) y_(y)
{ {

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include "animated_sprite.h" #include "animated_sprite.h"
#include "smart_sprite.h" #include "smart_sprite.h"
class Sprite; class Sprite;

View File

@@ -1,14 +1,14 @@
#include "global_inputs.h" #include "global_inputs.h"
#include <string> // for basic_string, operator+ #include <string> // para basic_string, operator+
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // para Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT
#include "jail_audio.h" // for JA_EnableMusic, JA_EnableSound #include "jail_audio.h" // para JA_EnableMusic, JA_EnableSound
#include "lang.h" // for getText #include "lang.h" // para getText
#include "notifier.h" // for Notifier #include "notifier.h" // para Notifier
#include "options.h" // for options #include "options.h" // para options
#include "on_screen_help.h" #include "on_screen_help.h"
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for SectionOptions, name, SectionName, options #include "section.h" // para SectionOptions, name, SectionName, options
#include "utils.h" // for OptionsAudio, Options, OptionsMusic, boolToOnOff #include "utils.h" // para OptionsAudio, Options, OptionsMusic, boolToOnOff
namespace globalInputs namespace globalInputs
{ {

View File

@@ -1,25 +1,25 @@
#include "hiscore_table.h" #include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // for max #include <algorithm> // para max
#include <vector> // for vector #include <vector> // para vector
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "background.h" // for Background #include "background.h" // para Background
#include "fade.h" // for Fade, FadeMode, FadeType #include "fade.h" // para Fade, FadeMode, FadeType
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for Input #include "input.h" // para Input
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state #include "jail_audio.h" // para JA_GetMusicState, JA_Music_state
#include "lang.h" // for getText #include "lang.h" // para getText
#include "options.h" // for options #include "options.h" // para options
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "text.h" // for Text, TEXT_CENTER, TEXT_SHADOW, TEXT... #include "text.h" // para Text, TEXT_CENTER, TEXT_SHADOW, TEXT...
#include "utils.h" // for Param, ParamGame, Color, HiScoreEntry #include "utils.h" // para Param, ParamGame, Color, HiScoreEntry
// Constructor // Constructor
HiScoreTable::HiScoreTable() HiScoreTable::HiScoreTable()

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint16, Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // para Uint16, Uint32, Uint8
#include <memory> // for unique_ptr #include <memory> // para unique_ptr
#include <string> // for string #include <string> // para string
class Background; // lines 8-8 class Background; // lines 8-8
class Fade; // lines 9-9 class Fade; // lines 9-9
class Text; // lines 10-10 class Text; // lines 10-10

View File

@@ -1,9 +1,9 @@
#include "input.h" #include "input.h"
#include <SDL2/SDL.h> // for SDL_INIT_GAMECONTROLLER, SDL_InitSubS... #include <SDL2/SDL.h> // para SDL_INIT_GAMECONTROLLER, SDL_InitSubS...
#include <SDL2/SDL_error.h> // for SDL_GetError #include <SDL2/SDL_error.h> // para SDL_GetError
#include <SDL2/SDL_events.h> // for SDL_ENABLE #include <SDL2/SDL_events.h> // para SDL_ENABLE
#include <SDL2/SDL_keyboard.h> // for SDL_GetKeyboardState #include <SDL2/SDL_keyboard.h> // para SDL_GetKeyboardState
#include <iostream> // for basic_ostream, operator<<, cout, basi... #include <iostream> // para basic_ostream, operator<<, cout, basi...
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Input *Input::input_ = nullptr; Input *Input::input_ = nullptr;

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton, SDL_G... #include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton, SDL_G...
#include <SDL2/SDL_joystick.h> // for SDL_Joystick #include <SDL2/SDL_joystick.h> // para SDL_Joystick
#include <SDL2/SDL_scancode.h> // for SDL_Scancode #include <SDL2/SDL_scancode.h> // para SDL_Scancode
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
#include <string> // for string, basic_string #include <string> // para string, basic_string
#include <vector> // for vector #include <vector> // para vector
/* /*
connectedControllers es un vector donde estan todos los mandos encontrados [0 .. n] connectedControllers es un vector donde estan todos los mandos encontrados [0 .. n]

View File

@@ -1,26 +1,26 @@
#include "instructions.h" #include "instructions.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // for max #include <algorithm> // para max
#include <utility> // for move #include <utility> // para move
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "fade.h" // for Fade, FadeMode, FadeType #include "fade.h" // para Fade, FadeMode, FadeType
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for Input #include "input.h" // para Input
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state #include "jail_audio.h" // para JA_GetMusicState, JA_Music_state
#include "lang.h" // for getText #include "lang.h" // para getText
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR, TEXT_... #include "text.h" // para Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "tiled_bg.h" // for TiledBG, TILED_MODE_STATIC #include "tiled_bg.h" // para TiledBG, TILED_MODE_STATIC
#include "utils.h" // for Param, ParamGame, Color, shdw_txt_color #include "utils.h" // para Param, ParamGame, Color, shdw_txt_color
struct JA_Music_t; // lines 22-22 struct JA_Music_t; // lines 22-22
// Constructor // Constructor

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Texture, SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // para vector
class Fade; class Fade;
class Sprite; class Sprite;
class Text; class Text;
@@ -33,7 +33,7 @@ private:
SDL_Renderer *renderer_; // El renderizador de la ventana SDL_Renderer *renderer_; // El renderizador de la ventana
SDL_Texture *texture_; // Textura fija con el texto SDL_Texture *texture_; // Textura fija con el texto
SDL_Texture *backbuffer_; // Textura para usar como backbuffer SDL_Texture *backbuffer_; // Textura para usar como backbuffer
std::vector<std::shared_ptr<Texture>> item_textures_; // Vector con las texturas de los items std::vector<std::shared_ptr<Texture>> item_textures_; // Vector con las texturas de los items
std::vector<std::unique_ptr<Sprite>> sprites_; // Vector con los sprites de los items std::vector<std::unique_ptr<Sprite>> sprites_; // Vector con los sprites de los items
std::unique_ptr<Text> text_; // Objeto para escribir texto std::unique_ptr<Text> text_; // Objeto para escribir texto

View File

@@ -1,22 +1,22 @@
#include "intro.h" #include "intro.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // for move #include <utility> // para move
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for Input #include "input.h" // para Input
#include "jail_audio.h" // for JA_StopMusic, JA_PlayMusic #include "jail_audio.h" // para JA_StopMusic, JA_PlayMusic
#include "lang.h" // for getText #include "lang.h" // para getText
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "smart_sprite.h" // for SpriteSmart #include "smart_sprite.h" // para SpriteSmart
#include "text.h" // for Text #include "text.h" // para Text
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" // for Param, ParamGame, Zone, BLOCK, Color #include "utils.h" // para Param, ParamGame, Zone, BLOCK, Color
#include "writer.h" // for Writer #include "writer.h" // para Writer
struct JA_Music_t; // lines 19-19 struct JA_Music_t; // lines 19-19
// Constructor // Constructor
@@ -369,7 +369,7 @@ void Intro::updateScenes()
void Intro::update() void Intro::update()
{ {
constexpr int TICKS_SPEED = 15; constexpr int TICKS_SPEED = 15;
if (SDL_GetTicks() - ticks_ > TICKS_SPEED) if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
{ {
// Actualiza el contador de ticks // Actualiza el contador de ticks

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // para Uint32, Uint8
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // para vector
#include "smart_sprite.h" // for SpriteSmart #include "smart_sprite.h" // para SpriteSmart
#include "writer.h" // for Writer #include "writer.h" // para Writer
class Text; class Text;
class Texture; class Texture;
struct JA_Music_t; // lines 11-11 struct JA_Music_t; // lines 11-11

View File

@@ -1,7 +1,7 @@
#include "item.h" #include "item.h"
#include <stdlib.h> // for rand #include <stdlib.h> // para rand
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "param.h" // for param #include "param.h" // para param
class Texture; class Texture;
// Constructor // Constructor

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint16 #include <SDL2/SDL_stdinc.h> // para Uint16
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "utils.h" // for Circle #include "utils.h" // para Circle
class Texture; class Texture;
// Tipos de objetos // Tipos de objetos

View File

@@ -1,74 +1,91 @@
#ifndef JA_USESDLMIXER #ifndef JA_USESDLMIXER
#include "jail_audio.h" #include "jail_audio.h"
#include <stdint.h> // for uint8_t #include <stdint.h> // para uint8_t
#include <stdio.h> // for NULL, fseek, fclose, fopen, fread, ftell, FILE #include <stdio.h> // para NULL, fseek, fclose, fopen, fread, ftell, FILE
#include <stdlib.h> // for free, malloc #include <stdlib.h> // para free, malloc
#include "stb_vorbis.c" // for stb_vorbis_decode_memory #include "stb_vorbis.c" // para stb_vorbis_decode_memory
#define JA_MAX_SIMULTANEOUS_CHANNELS 5 #define JA_MAX_SIMULTANEOUS_CHANNELS 5
struct JA_Sound_t { struct JA_Sound_t
Uint32 length {0}; {
Uint8* buffer {NULL}; Uint32 length{0};
Uint8 *buffer{NULL};
}; };
struct JA_Channel_t { struct JA_Channel_t
JA_Sound_t *sound; {
int pos {0}; JA_Sound_t *sound;
int times {0}; int pos{0};
JA_Channel_state state { JA_CHANNEL_FREE }; int times{0};
JA_Channel_state state{JA_CHANNEL_FREE};
}; };
struct JA_Music_t { struct JA_Music_t
int samples {0}; {
int pos {0}; int samples{0};
int times {0}; int pos{0};
short* output {NULL}; int times{0};
JA_Music_state state {JA_MUSIC_INVALID}; short *output{NULL};
JA_Music_state state{JA_MUSIC_INVALID};
}; };
JA_Music_t *current_music{NULL}; JA_Music_t *current_music{NULL};
JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS]; JA_Channel_t channels[JA_MAX_SIMULTANEOUS_CHANNELS];
int JA_freq {48000}; int JA_freq{48000};
SDL_AudioFormat JA_format {AUDIO_S16}; SDL_AudioFormat JA_format{AUDIO_S16};
Uint8 JA_channels {2}; Uint8 JA_channels{2};
int JA_musicVolume = 128; int JA_musicVolume = 128;
int JA_soundVolume = 64; int JA_soundVolume = 64;
bool JA_musicEnabled = true; bool JA_musicEnabled = true;
bool JA_soundEnabled = true; bool JA_soundEnabled = true;
SDL_AudioDeviceID sdlAudioDevice = 0; SDL_AudioDeviceID sdlAudioDevice = 0;
void audioCallback(void * userdata, uint8_t * stream, int len) { void audioCallback(void *userdata, uint8_t *stream, int len)
{
SDL_memset(stream, 0, len); SDL_memset(stream, 0, len);
if (current_music != NULL && current_music->state == JA_MUSIC_PLAYING) { if (current_music != NULL && current_music->state == JA_MUSIC_PLAYING)
const int size = SDL_min(len, current_music->samples*2-current_music->pos); {
SDL_MixAudioFormat(stream, (Uint8*)(current_music->output+current_music->pos), AUDIO_S16, size, JA_musicVolume); const int size = SDL_min(len, current_music->samples * 2 - current_music->pos);
current_music->pos += size/2; SDL_MixAudioFormat(stream, (Uint8 *)(current_music->output + current_music->pos), AUDIO_S16, size, JA_musicVolume);
if (size < len) { current_music->pos += size / 2;
if (current_music->times != 0) { if (size < len)
SDL_MixAudioFormat(stream+size, (Uint8*)current_music->output, AUDIO_S16, len-size, JA_musicVolume); {
current_music->pos = (len-size)/2; if (current_music->times != 0)
if (current_music->times > 0) current_music->times--; {
} else { SDL_MixAudioFormat(stream + size, (Uint8 *)current_music->output, AUDIO_S16, len - size, JA_musicVolume);
current_music->pos = (len - size) / 2;
if (current_music->times > 0)
current_music->times--;
}
else
{
current_music->pos = 0; current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED; current_music->state = JA_MUSIC_STOPPED;
} }
} }
} }
// Mixar els channels mi amol // Mixar els channels mi amol
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
if (channels[i].state == JA_CHANNEL_PLAYING) { {
if (channels[i].state == JA_CHANNEL_PLAYING)
{
const int size = SDL_min(len, channels[i].sound->length - channels[i].pos); const int size = SDL_min(len, channels[i].sound->length - channels[i].pos);
SDL_MixAudioFormat(stream, channels[i].sound->buffer + channels[i].pos, AUDIO_S16, size, JA_soundVolume); SDL_MixAudioFormat(stream, channels[i].sound->buffer + channels[i].pos, AUDIO_S16, size, JA_soundVolume);
channels[i].pos += size; channels[i].pos += size;
if (size < len) { if (size < len)
if (channels[i].times != 0) { {
SDL_MixAudioFormat(stream + size, channels[i].sound->buffer, AUDIO_S16, len-size, JA_soundVolume); if (channels[i].times != 0)
channels[i].pos = len-size; {
if (channels[i].times > 0) channels[i].times--; SDL_MixAudioFormat(stream + size, channels[i].sound->buffer, AUDIO_S16, len - size, JA_soundVolume);
} else { channels[i].pos = len - size;
if (channels[i].times > 0)
channels[i].times--;
}
else
{
JA_StopChannel(i); JA_StopChannel(i);
} }
} }
@@ -76,23 +93,28 @@ void audioCallback(void * userdata, uint8_t * stream, int len) {
} }
} }
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels) { void JA_Init(const int freq, const SDL_AudioFormat format, const int channels)
{
JA_freq = freq; JA_freq = freq;
JA_format = format; JA_format = format;
JA_channels = channels; JA_channels = channels;
SDL_AudioSpec audioSpec{JA_freq, JA_format, JA_channels, 0, 1024, 0, 0, audioCallback, NULL}; SDL_AudioSpec audioSpec{JA_freq, JA_format, JA_channels, 0, 1024, 0, 0, audioCallback, NULL};
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice); if (sdlAudioDevice != 0)
SDL_CloseAudioDevice(sdlAudioDevice);
sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0); sdlAudioDevice = SDL_OpenAudioDevice(NULL, 0, &audioSpec, NULL, 0);
SDL_PauseAudioDevice(sdlAudioDevice, 0); SDL_PauseAudioDevice(sdlAudioDevice, 0);
} }
void JA_Quit() { void JA_Quit()
{
SDL_PauseAudioDevice(sdlAudioDevice, 1); SDL_PauseAudioDevice(sdlAudioDevice, 1);
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice); if (sdlAudioDevice != 0)
SDL_CloseAudioDevice(sdlAudioDevice);
sdlAudioDevice = 0; sdlAudioDevice = 0;
} }
JA_Music_t *JA_LoadMusic(const char* filename) { JA_Music_t *JA_LoadMusic(const char *filename)
{
int chan, samplerate; int chan, samplerate;
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid. // [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
@@ -100,8 +122,9 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
fseek(f, 0, SEEK_END); fseek(f, 0, SEEK_END);
long fsize = ftell(f); long fsize = ftell(f);
fseek(f, 0, SEEK_SET); fseek(f, 0, SEEK_SET);
Uint8 *buffer = (Uint8*)malloc(fsize + 1); Uint8 *buffer = (Uint8 *)malloc(fsize + 1);
if (fread(buffer, fsize, 1, f)!=1) return NULL; if (fread(buffer, fsize, 1, f) != 1)
return NULL;
fclose(f); fclose(f);
JA_Music_t *music = new JA_Music_t(); JA_Music_t *music = new JA_Music_t();
@@ -109,17 +132,18 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output); music->samples = stb_vorbis_decode_memory(buffer, fsize, &chan, &samplerate, &music->output);
free(buffer); free(buffer);
// [RZC 28/08/22] Abans el descomprimiem mentre el teniem obert // [RZC 28/08/22] Abans el descomprimiem mentre el teniem obert
// music->samples = stb_vorbis_decode_filename(filename, &chan, &samplerate, &music->output); // music->samples = stb_vorbis_decode_filename(filename, &chan, &samplerate, &music->output);
SDL_AudioCVT cvt; SDL_AudioCVT cvt;
SDL_BuildAudioCVT(&cvt, AUDIO_S16, chan, samplerate, JA_format, JA_channels, JA_freq); SDL_BuildAudioCVT(&cvt, AUDIO_S16, chan, samplerate, JA_format, JA_channels, JA_freq);
if (cvt.needed) { if (cvt.needed)
{
cvt.len = music->samples * chan * 2; cvt.len = music->samples * chan * 2;
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult); cvt.buf = (Uint8 *)SDL_malloc(cvt.len * cvt.len_mult);
SDL_memcpy(cvt.buf, music->output, cvt.len); SDL_memcpy(cvt.buf, music->output, cvt.len);
SDL_ConvertAudio(&cvt); SDL_ConvertAudio(&cvt);
free(music->output); free(music->output);
music->output = (short*)cvt.buf; music->output = (short *)cvt.buf;
} }
music->pos = 0; music->pos = 0;
music->state = JA_MUSIC_STOPPED; music->state = JA_MUSIC_STOPPED;
@@ -129,9 +153,11 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
void JA_PlayMusic(JA_Music_t *music, const int loop) void JA_PlayMusic(JA_Music_t *music, const int loop)
{ {
if (!JA_musicEnabled || !music) return; if (!JA_musicEnabled || !music)
return;
if (current_music != NULL) { if (current_music != NULL)
{
current_music->pos = 0; current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED; current_music->state = JA_MUSIC_STOPPED;
} }
@@ -143,67 +169,78 @@ void JA_PlayMusic(JA_Music_t *music, const int loop)
void JA_PauseMusic() void JA_PauseMusic()
{ {
if (!JA_musicEnabled) return; if (!JA_musicEnabled)
return;
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return; if (current_music == NULL || current_music->state == JA_MUSIC_INVALID)
return;
current_music->state = JA_MUSIC_PAUSED; current_music->state = JA_MUSIC_PAUSED;
} }
void JA_ResumeMusic() void JA_ResumeMusic()
{ {
if (!JA_musicEnabled) return; if (!JA_musicEnabled)
return;
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return; if (current_music == NULL || current_music->state == JA_MUSIC_INVALID)
return;
current_music->state = JA_MUSIC_PLAYING; current_music->state = JA_MUSIC_PLAYING;
} }
void JA_StopMusic() void JA_StopMusic()
{ {
if (!JA_musicEnabled) return; if (!JA_musicEnabled)
return;
if (current_music == NULL || current_music->state == JA_MUSIC_INVALID) return; if (current_music == NULL || current_music->state == JA_MUSIC_INVALID)
return;
current_music->pos = 0; current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED; current_music->state = JA_MUSIC_STOPPED;
} }
JA_Music_state JA_GetMusicState() { JA_Music_state JA_GetMusicState()
if (!JA_musicEnabled) return JA_MUSIC_DISABLED; {
if (!JA_musicEnabled)
return JA_MUSIC_DISABLED;
if (current_music == NULL) return JA_MUSIC_INVALID; if (current_music == NULL)
return JA_MUSIC_INVALID;
return current_music->state; return current_music->state;
} }
void JA_DeleteMusic(JA_Music_t *music) { void JA_DeleteMusic(JA_Music_t *music)
if (current_music == music) current_music = NULL; {
if (current_music == music)
current_music = NULL;
free(music->output); free(music->output);
delete music; delete music;
} }
int JA_SetMusicVolume(int volume) int JA_SetMusicVolume(int volume)
{ {
JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0 : volume; JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0
: volume;
return JA_musicVolume; return JA_musicVolume;
} }
void JA_EnableMusic(const bool value) void JA_EnableMusic(const bool value)
{ {
if (!value && current_music != NULL && current_music->state==JA_MUSIC_PLAYING) JA_StopMusic(); if (!value && current_music != NULL && current_music->state == JA_MUSIC_PLAYING)
JA_StopMusic();
JA_musicEnabled = value; JA_musicEnabled = value;
} }
JA_Sound_t *JA_NewSound(Uint8 *buffer, Uint32 length)
{
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length) {
JA_Sound_t *sound = new JA_Sound_t(); JA_Sound_t *sound = new JA_Sound_t();
sound->buffer = buffer; sound->buffer = buffer;
sound->length = length; sound->length = length;
return sound; return sound;
} }
JA_Sound_t *JA_LoadSound(const char* filename) { JA_Sound_t *JA_LoadSound(const char *filename)
{
JA_Sound_t *sound = new JA_Sound_t(); JA_Sound_t *sound = new JA_Sound_t();
SDL_AudioSpec wavSpec; SDL_AudioSpec wavSpec;
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length); SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
@@ -211,7 +248,7 @@ JA_Sound_t *JA_LoadSound(const char* filename) {
SDL_AudioCVT cvt; SDL_AudioCVT cvt;
SDL_BuildAudioCVT(&cvt, wavSpec.format, wavSpec.channels, wavSpec.freq, JA_format, JA_channels, JA_freq); SDL_BuildAudioCVT(&cvt, wavSpec.format, wavSpec.channels, wavSpec.freq, JA_format, JA_channels, JA_freq);
cvt.len = sound->length; cvt.len = sound->length;
cvt.buf = (Uint8 *) SDL_malloc(cvt.len * cvt.len_mult); cvt.buf = (Uint8 *)SDL_malloc(cvt.len * cvt.len_mult);
SDL_memcpy(cvt.buf, sound->buffer, sound->length); SDL_memcpy(cvt.buf, sound->buffer, sound->length);
SDL_ConvertAudio(&cvt); SDL_ConvertAudio(&cvt);
SDL_FreeWAV(sound->buffer); SDL_FreeWAV(sound->buffer);
@@ -223,11 +260,16 @@ JA_Sound_t *JA_LoadSound(const char* filename) {
int JA_PlaySound(JA_Sound_t *sound, const int loop) int JA_PlaySound(JA_Sound_t *sound, const int loop)
{ {
if (!JA_soundEnabled || !sound) return 0; if (!JA_soundEnabled || !sound)
return 0;
int channel = 0; int channel = 0;
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; } while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE)
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0; {
channel++;
}
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS)
channel = 0;
channels[channel].sound = sound; channels[channel].sound = sound;
channels[channel].times = loop; channels[channel].times = loop;
@@ -238,8 +280,10 @@ int JA_PlaySound(JA_Sound_t *sound, const int loop)
void JA_DeleteSound(JA_Sound_t *sound) void JA_DeleteSound(JA_Sound_t *sound)
{ {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
if (channels[i].sound == sound) JA_StopChannel(i); {
if (channels[i].sound == sound)
JA_StopChannel(i);
} }
SDL_free(sound->buffer); SDL_free(sound->buffer);
delete sound; delete sound;
@@ -247,41 +291,60 @@ void JA_DeleteSound(JA_Sound_t *sound)
void JA_PauseChannel(const int channel) void JA_PauseChannel(const int channel)
{ {
if (!JA_soundEnabled) return; if (!JA_soundEnabled)
return;
if (channel == -1) { if (channel == -1)
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { {
if (channels[i].state == JA_CHANNEL_PLAYING) channels[i].state = JA_CHANNEL_PAUSED; for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
if (channels[i].state == JA_CHANNEL_PLAYING)
channels[i].state = JA_CHANNEL_PAUSED;
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { }
if (channels[channel].state == JA_CHANNEL_PLAYING) channels[channel].state = JA_CHANNEL_PAUSED; else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
{
if (channels[channel].state == JA_CHANNEL_PLAYING)
channels[channel].state = JA_CHANNEL_PAUSED;
} }
} }
void JA_ResumeChannel(const int channel) void JA_ResumeChannel(const int channel)
{ {
if (!JA_soundEnabled) return; if (!JA_soundEnabled)
return;
if (channel == -1) { if (channel == -1)
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { {
if (channels[i].state == JA_CHANNEL_PAUSED) channels[i].state = JA_CHANNEL_PLAYING; for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
if (channels[i].state == JA_CHANNEL_PAUSED)
channels[i].state = JA_CHANNEL_PLAYING;
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { }
if (channels[channel].state == JA_CHANNEL_PAUSED) channels[channel].state = JA_CHANNEL_PLAYING; else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
{
if (channels[channel].state == JA_CHANNEL_PAUSED)
channels[channel].state = JA_CHANNEL_PLAYING;
} }
} }
void JA_StopChannel(const int channel) void JA_StopChannel(const int channel)
{ {
if (!JA_soundEnabled) return; if (!JA_soundEnabled)
return;
if (channel == -1) { if (channel == -1)
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) { {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
channels[i].state = JA_CHANNEL_FREE; channels[i].state = JA_CHANNEL_FREE;
channels[i].pos = 0; channels[i].pos = 0;
channels[i].sound = NULL; channels[i].sound = NULL;
} }
} else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS) { }
else if (channel >= 0 && channel < JA_MAX_SIMULTANEOUS_CHANNELS)
{
channels[channel].state = JA_CHANNEL_FREE; channels[channel].state = JA_CHANNEL_FREE;
channels[channel].pos = 0; channels[channel].pos = 0;
channels[channel].sound = NULL; channels[channel].sound = NULL;
@@ -290,15 +353,18 @@ void JA_StopChannel(const int channel)
JA_Channel_state JA_GetChannelState(const int channel) JA_Channel_state JA_GetChannelState(const int channel)
{ {
if (!JA_soundEnabled) return JA_SOUND_DISABLED; if (!JA_soundEnabled)
return JA_SOUND_DISABLED;
if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS) return JA_CHANNEL_INVALID; if (channel < 0 || channel >= JA_MAX_SIMULTANEOUS_CHANNELS)
return JA_CHANNEL_INVALID;
return channels[channel].state; return channels[channel].state;
} }
int JA_SetSoundVolume(int volume) int JA_SetSoundVolume(int volume)
{ {
JA_soundVolume = volume > 128 ? 128 : volume < 0 ? 0 : volume; JA_soundVolume = volume > 128 ? 128 : volume < 0 ? 0
: volume;
return JA_soundVolume; return JA_soundVolume;
} }
@@ -306,15 +372,17 @@ void JA_EnableSound(const bool value)
{ {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{ {
if (channels[i].state == JA_CHANNEL_PLAYING) JA_StopChannel(i); if (channels[i].state == JA_CHANNEL_PLAYING)
JA_StopChannel(i);
} }
JA_soundEnabled = value; JA_soundEnabled = value;
} }
int JA_SetVolume(int volume) int JA_SetVolume(int volume)
{ {
JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0 : volume; JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0
JA_soundVolume = JA_musicVolume/2; : volume;
JA_soundVolume = JA_musicVolume / 2;
return JA_musicVolume; return JA_musicVolume;
} }

View File

@@ -1,17 +1,31 @@
#pragma once #pragma once
#include <SDL2/SDL_audio.h> // for SDL_AudioFormat #include <SDL2/SDL_audio.h> // para SDL_AudioFormat
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // para Uint32, Uint8
struct JA_Music_t; // lines 5-5 struct JA_Music_t; // lines 5-5
struct JA_Sound_t; // lines 6-6 struct JA_Sound_t; // lines 6-6
enum JA_Channel_state { JA_CHANNEL_INVALID, JA_CHANNEL_FREE, JA_CHANNEL_PLAYING, JA_CHANNEL_PAUSED, JA_SOUND_DISABLED }; enum JA_Channel_state
enum JA_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED, JA_MUSIC_DISABLED }; {
JA_CHANNEL_INVALID,
JA_CHANNEL_FREE,
JA_CHANNEL_PLAYING,
JA_CHANNEL_PAUSED,
JA_SOUND_DISABLED
};
enum JA_Music_state
{
JA_MUSIC_INVALID,
JA_MUSIC_PLAYING,
JA_MUSIC_PAUSED,
JA_MUSIC_STOPPED,
JA_MUSIC_DISABLED
};
void JA_Init(const int freq, const SDL_AudioFormat format, const int channels); void JA_Init(const int freq, const SDL_AudioFormat format, const int channels);
void JA_Quit(); void JA_Quit();
JA_Music_t *JA_LoadMusic(const char* filename); JA_Music_t *JA_LoadMusic(const char *filename);
void JA_PlayMusic(JA_Music_t *music, const int loop = -1); void JA_PlayMusic(JA_Music_t *music, const int loop = -1);
void JA_PauseMusic(); void JA_PauseMusic();
void JA_ResumeMusic(); void JA_ResumeMusic();
@@ -21,8 +35,8 @@ void JA_DeleteMusic(JA_Music_t *music);
int JA_SetMusicVolume(int volume); int JA_SetMusicVolume(int volume);
void JA_EnableMusic(const bool value); void JA_EnableMusic(const bool value);
JA_Sound_t *JA_NewSound(Uint8* buffer, Uint32 length); JA_Sound_t *JA_NewSound(Uint8 *buffer, Uint32 length);
JA_Sound_t *JA_LoadSound(const char* filename); JA_Sound_t *JA_LoadSound(const char *filename);
int JA_PlaySound(JA_Sound_t *sound, const int loop = 0); int JA_PlaySound(JA_Sound_t *sound, const int loop = 0);
void JA_PauseChannel(const int channel); void JA_PauseChannel(const int channel);
void JA_ResumeChannel(const int channel); void JA_ResumeChannel(const int channel);

View File

@@ -1,10 +1,10 @@
#ifndef NO_SHADERS #ifndef NO_SHADERS
#include "jail_shader.h" #include "jail_shader.h"
#include <SDL2/SDL_rect.h> // for SDL_Point #include <SDL2/SDL_rect.h> // para SDL_Point
#include <stdlib.h> // for NULL, free, malloc, exit #include <stdlib.h> // para NULL, free, malloc, exit
#include <string.h> // for strncmp #include <string.h> // para strncmp
#include <iostream> // for basic_ostream, char_traits, operator<< #include <iostream> // para basic_ostream, char_traits, operator<<
#ifdef __APPLE__ #ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h" #include "CoreFoundation/CoreFoundation.h"
@@ -14,7 +14,7 @@
#include <OpenGL/gl3.h> #include <OpenGL/gl3.h>
#else #else
#include <OpenGL/gl.h> #include <OpenGL/gl.h>
#endif //!ESSENTIAL_GL_PRACTICES_SUPPORT_GL3 #endif //! ESSENTIAL_GL_PRACTICES_SUPPORT_GL3
#else #else
#include <SDL2/SDL_opengl.h> #include <SDL2/SDL_opengl.h>
#endif #endif
@@ -24,14 +24,14 @@ namespace shader
SDL_Window *win = nullptr; SDL_Window *win = nullptr;
SDL_Renderer *renderer = nullptr; SDL_Renderer *renderer = nullptr;
GLuint programId = 0; GLuint programId = 0;
SDL_Texture* backBuffer = nullptr; SDL_Texture *backBuffer = nullptr;
SDL_Point win_size = {320*4, 256*4}; SDL_Point win_size = {320 * 4, 256 * 4};
SDL_Point tex_size = {320, 256}; SDL_Point tex_size = {320, 256};
bool usingOpenGL; bool usingOpenGL;
#ifndef __APPLE__ #ifndef __APPLE__
// I'm avoiding the use of GLEW or some extensions handler, but that // I'm avoiding the use of GLEW or some extensions handler, but that
// doesn't mean you should... // doesn't mean you should...
PFNGLCREATESHADERPROC glCreateShader; PFNGLCREATESHADERPROC glCreateShader;
PFNGLSHADERSOURCEPROC glShaderSource; PFNGLSHADERSOURCEPROC glShaderSource;
@@ -47,7 +47,8 @@ namespace shader
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLUSEPROGRAMPROC glUseProgram; PFNGLUSEPROGRAMPROC glUseProgram;
bool initGLExtensions() { bool initGLExtensions()
{
glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader"); glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource"); glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource");
glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader"); glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader");
@@ -62,56 +63,60 @@ namespace shader
glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)SDL_GL_GetProcAddress("glGetProgramInfoLog"); glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)SDL_GL_GetProcAddress("glGetProgramInfoLog");
glUseProgram = (PFNGLUSEPROGRAMPROC)SDL_GL_GetProcAddress("glUseProgram"); glUseProgram = (PFNGLUSEPROGRAMPROC)SDL_GL_GetProcAddress("glUseProgram");
return glCreateShader && glShaderSource && glCompileShader && glGetShaderiv && return glCreateShader && glShaderSource && glCompileShader && glGetShaderiv &&
glGetShaderInfoLog && glDeleteShader && glAttachShader && glCreateProgram && glGetShaderInfoLog && glDeleteShader && glAttachShader && glCreateProgram &&
glLinkProgram && glValidateProgram && glGetProgramiv && glGetProgramInfoLog && glLinkProgram && glValidateProgram && glGetProgramiv && glGetProgramInfoLog &&
glUseProgram; glUseProgram;
} }
#endif #endif
GLuint compileShader(const char* source, GLuint shaderType) { GLuint compileShader(const char *source, GLuint shaderType)
{
// Create ID for shader // Create ID for shader
GLuint result = glCreateShader(shaderType); GLuint result = glCreateShader(shaderType);
// Add define depending on shader type // Add define depending on shader type
const char *sources[2] = { shaderType==GL_VERTEX_SHADER?"#define VERTEX\n":"#define FRAGMENT\n", source }; const char *sources[2] = {shaderType == GL_VERTEX_SHADER ? "#define VERTEX\n" : "#define FRAGMENT\n", source};
// Define shader text // Define shader text
glShaderSource(result, 2, sources, NULL); glShaderSource(result, 2, sources, NULL);
// Compile shader // Compile shader
glCompileShader(result); glCompileShader(result);
//Check vertex shader for errors // Check vertex shader for errors
GLint shaderCompiled = GL_FALSE; GLint shaderCompiled = GL_FALSE;
glGetShaderiv( result, GL_COMPILE_STATUS, &shaderCompiled ); glGetShaderiv(result, GL_COMPILE_STATUS, &shaderCompiled);
if( shaderCompiled != GL_TRUE ) { if (shaderCompiled != GL_TRUE)
{
std::cout << "Error en la compilación: " << result << "!" << std::endl; std::cout << "Error en la compilación: " << result << "!" << std::endl;
GLint logLength; GLint logLength;
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength); glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0) if (logLength > 0)
{ {
GLchar *log = (GLchar*)malloc(logLength); GLchar *log = (GLchar *)malloc(logLength);
glGetShaderInfoLog(result, logLength, &logLength, log); glGetShaderInfoLog(result, logLength, &logLength, log);
std::cout << "Shader compile log:" << log << std::endl; std::cout << "Shader compile log:" << log << std::endl;
free(log); free(log);
} }
glDeleteShader(result); glDeleteShader(result);
result = 0; result = 0;
// } else { // } else {
// std::cout << "Shader compilado correctamente. Id = " << result << std::endl; // std::cout << "Shader compilado correctamente. Id = " << result << std::endl;
} }
return result; return result;
} }
GLuint compileProgram(const char* vertexShaderSource, const char* fragmentShaderSource) { GLuint compileProgram(const char *vertexShaderSource, const char *fragmentShaderSource)
{
GLuint programId = 0; GLuint programId = 0;
GLuint vtxShaderId, fragShaderId; GLuint vtxShaderId, fragShaderId;
programId = glCreateProgram(); programId = glCreateProgram();
vtxShaderId = compileShader(vertexShaderSource, GL_VERTEX_SHADER); vtxShaderId = compileShader(vertexShaderSource, GL_VERTEX_SHADER);
fragShaderId = compileShader(fragmentShaderSource?fragmentShaderSource:vertexShaderSource, GL_FRAGMENT_SHADER); fragShaderId = compileShader(fragmentShaderSource ? fragmentShaderSource : vertexShaderSource, GL_FRAGMENT_SHADER);
if(vtxShaderId && fragShaderId) { if (vtxShaderId && fragShaderId)
{
// Associate shader with program // Associate shader with program
glAttachShader(programId, vtxShaderId); glAttachShader(programId, vtxShaderId);
glAttachShader(programId, fragShaderId); glAttachShader(programId, fragShaderId);
@@ -121,24 +126,28 @@ namespace shader
// Check the status of the compile/link // Check the status of the compile/link
GLint logLen; GLint logLen;
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen); glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
if(logLen > 0) { if (logLen > 0)
char* log = (char*) malloc(logLen * sizeof(char)); {
char *log = (char *)malloc(logLen * sizeof(char));
// Show any errors as appropriate // Show any errors as appropriate
glGetProgramInfoLog(programId, logLen, &logLen, log); glGetProgramInfoLog(programId, logLen, &logLen, log);
std::cout << "Prog Info Log: " << std::endl << log << std::endl; std::cout << "Prog Info Log: " << std::endl
<< log << std::endl;
free(log); free(log);
} }
} }
if(vtxShaderId) { if (vtxShaderId)
{
glDeleteShader(vtxShaderId); glDeleteShader(vtxShaderId);
} }
if(fragShaderId) { if (fragShaderId)
{
glDeleteShader(fragShaderId); glDeleteShader(fragShaderId);
} }
return programId; return programId;
} }
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const char* vertexShader, const char* fragmentShader) const bool init(SDL_Window *win, SDL_Texture *backBuffer, const char *vertexShader, const char *fragmentShader)
{ {
shader::win = win; shader::win = win;
shader::renderer = SDL_GetRenderer(win); shader::renderer = SDL_GetRenderer(win);
@@ -155,19 +164,23 @@ namespace shader
SDL_RendererInfo rendererInfo; SDL_RendererInfo rendererInfo;
SDL_GetRendererInfo(renderer, &rendererInfo); SDL_GetRendererInfo(renderer, &rendererInfo);
if(!strncmp(rendererInfo.name, "opengl", 6)) { if (!strncmp(rendererInfo.name, "opengl", 6))
//std::cout << "Es OpenGL!" << std::endl; {
#ifndef __APPLE__ // std::cout << "Es OpenGL!" << std::endl;
if (!initGLExtensions()) { #ifndef __APPLE__
if (!initGLExtensions())
{
std::cout << "WARNING: No s'han pogut inicialitzar les extensions d'OpenGL!" << std::endl; std::cout << "WARNING: No s'han pogut inicialitzar les extensions d'OpenGL!" << std::endl;
usingOpenGL = false; usingOpenGL = false;
return false; return false;
} }
#endif #endif
// Compilar el shader y dejarlo listo para usar. // Compilar el shader y dejarlo listo para usar.
programId = compileProgram(vertexShader, fragmentShader); programId = compileProgram(vertexShader, fragmentShader);
//std::cout << "programId = " << programId << std::endl; // std::cout << "programId = " << programId << std::endl;
} else { }
else
{
std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl; std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl;
usingOpenGL = false; usingOpenGL = false;
return false; return false;
@@ -180,19 +193,21 @@ namespace shader
{ {
GLint oldProgramId; GLint oldProgramId;
// Guarrada para obtener el textureid (en driverdata->texture) // Guarrada para obtener el textureid (en driverdata->texture)
//Detach the texture // Detach the texture
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_SetRenderTarget(renderer, NULL); SDL_SetRenderTarget(renderer, NULL);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
if (usingOpenGL) { if (usingOpenGL)
{
SDL_GL_BindTexture(backBuffer, NULL, NULL); SDL_GL_BindTexture(backBuffer, NULL, NULL);
if(programId != 0) { if (programId != 0)
glGetIntegerv(GL_CURRENT_PROGRAM,&oldProgramId); {
glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgramId);
glUseProgram(programId); glUseProgram(programId);
} }
GLfloat minx, miny, maxx, maxy; GLfloat minx, miny, maxx, maxy;
GLfloat minu, maxu, minv, maxv; GLfloat minu, maxu, minv, maxv;
@@ -210,21 +225,24 @@ namespace shader
glViewport(0, 0, win_size.x, win_size.y); glViewport(0, 0, win_size.x, win_size.y);
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(minu, minv); glTexCoord2f(minu, minv);
glVertex2f(minx, miny); glVertex2f(minx, miny);
glTexCoord2f(maxu, minv); glTexCoord2f(maxu, minv);
glVertex2f(maxx, miny); glVertex2f(maxx, miny);
glTexCoord2f(minu, maxv); glTexCoord2f(minu, maxv);
glVertex2f(minx, maxy); glVertex2f(minx, maxy);
glTexCoord2f(maxu, maxv); glTexCoord2f(maxu, maxv);
glVertex2f(maxx, maxy); glVertex2f(maxx, maxy);
glEnd(); glEnd();
SDL_GL_SwapWindow(win); SDL_GL_SwapWindow(win);
if(programId != 0) { if (programId != 0)
{
glUseProgram(oldProgramId); glUseProgram(oldProgramId);
} }
} else { }
else
{
SDL_RenderCopy(renderer, backBuffer, NULL, NULL); SDL_RenderCopy(renderer, backBuffer, NULL, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }

View File

@@ -2,8 +2,8 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Texture
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // para SDL_Window
// TIPS: // TIPS:
// ======================================================================= // =======================================================================
@@ -27,7 +27,7 @@
// Els shaders li'ls passem com una cadena, som nosaltres els que s'encarreguem // Els shaders li'ls passem com una cadena, som nosaltres els que s'encarreguem
// de carregarlos de disc, amb fopen, ifstream, jfile o el que vullgues. // de carregarlos de disc, amb fopen, ifstream, jfile o el que vullgues.
// Si els tens en un std::string, passa-li-la com "cadena.c_str()". // Si els tens en un std::string, passa-li-la com "cadena.c_str()".
// //
// Poden ser els dos el mateix arxiu, com fa libRetro, jo desde dins ja fique // Poden ser els dos el mateix arxiu, com fa libRetro, jo desde dins ja fique
// els defines necessaris. Si es el mateix arxiu, pots no ficar el quart paràmetre. // els defines necessaris. Si es el mateix arxiu, pots no ficar el quart paràmetre.
// //
@@ -40,8 +40,8 @@
namespace shader namespace shader
{ {
const bool init(SDL_Window* win, SDL_Texture* backBuffer, const bool init(SDL_Window *win, SDL_Texture *backBuffer,
const char* vertexShader, const char* fragmentShader=nullptr); const char *vertexShader, const char *fragmentShader = nullptr);
void render(); void render();
} }

View File

@@ -1,11 +1,11 @@
#include "lang.h" #include "lang.h"
#include <fstream> // for basic_ifstream, basic_istream, ifstream #include <fstream> // para basic_ifstream, basic_istream, ifstream
#include <vector> // for vector #include <vector> // para vector
namespace lang namespace lang
{ {
std::vector<std::string> texts; // Vector con los textos std::vector<std::string> texts; // Vector con los textos
// Inicializa los textos del juego en el idioma seleccionado // Inicializa los textos del juego en el idioma seleccionado
bool loadFromFile(std::string file_path) bool loadFromFile(std::string file_path)
{ {

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string> // for string #include <string> // para string
namespace lang namespace lang
{ {

View File

@@ -1,19 +1,19 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED #include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // for move #include <utility> // para move
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for Input #include "input.h" // para Input
#include "jail_audio.h" // for JA_StopMusic #include "jail_audio.h" // para JA_StopMusic
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Name, name, Options, options #include "section.h" // para Name, name, Options, options
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
// Constructor // Constructor
Logo::Logo() Logo::Logo()

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Point #include <SDL2/SDL_rect.h> // para SDL_Point
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include <vector> // for vector #include <vector> // para vector
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "utils.h" // for Color #include "utils.h" // para Color
class Texture; class Texture;
/* /*
@@ -26,7 +26,7 @@ private:
static constexpr int END_LOGO_COUNTER_MARK = 400; // Tiempo del contador para terminar el logo static constexpr int END_LOGO_COUNTER_MARK = 400; // Tiempo del contador para terminar el logo
static constexpr int POST_LOGO_DURATION = 20; // Tiempo que dura el logo con el fade al maximo static constexpr int POST_LOGO_DURATION = 20; // Tiempo que dura el logo con el fade al maximo
static constexpr int SPEED = 8; // Velocidad de desplazamiento de cada linea static constexpr int SPEED = 8; // Velocidad de desplazamiento de cada linea
// Objetos y punteros // Objetos y punteros
std::shared_ptr<Texture> since_texture_; // Textura con los graficos "Since 1998" std::shared_ptr<Texture> since_texture_; // Textura con los graficos "Since 1998"
std::unique_ptr<Sprite> since_sprite_; // Sprite para manejar la sinceTexture std::unique_ptr<Sprite> since_sprite_; // Sprite para manejar la sinceTexture

View File

@@ -7,9 +7,9 @@ Actualizando a la versión "Arcade Edition" en 08/05/2024
*/ */
#include <iostream> // for char_traits, basic_ostream, operator<<, cout #include <iostream> // para char_traits, basic_ostream, operator<<, cout
#include <memory> // for make_unique, unique_ptr #include <memory> // para make_unique, unique_ptr
#include "director.h" // for Director #include "director.h" // para Director
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {

View File

@@ -1,10 +1,10 @@
#include "manage_hiscore_table.h" #include "manage_hiscore_table.h"
#include <SDL2/SDL_error.h> // for SDL_GetError #include <SDL2/SDL_error.h> // para SDL_GetError
#include <SDL2/SDL_rwops.h> // for SDL_RWread, SDL_RWwrite, SDL_RWFromFile #include <SDL2/SDL_rwops.h> // para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <stdlib.h> // for free, malloc #include <stdlib.h> // para free, malloc
#include <algorithm> // for sort #include <algorithm> // para sort
#include <iostream> // for basic_ostream, char_traits, operator<< #include <iostream> // para basic_ostream, char_traits, operator<<
#include "utils.h" // for HiScoreEntry #include "utils.h" // para HiScoreEntry
// Resetea la tabla a los valores por defecto // Resetea la tabla a los valores por defecto
void ManageHiScoreTable::clear() void ManageHiScoreTable::clear()

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
struct HiScoreEntry; struct HiScoreEntry;
/* /*

View File

@@ -1,5 +1,5 @@
#include "moving_sprite.h" #include "moving_sprite.h"
#include "texture.h" // for Texture #include "texture.h" // para Texture
// Constructor // Constructor
MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotate rotate, float zoom_w, float zoom_h, SDL_RendererFlip flip) MovingSprite::MovingSprite(std::shared_ptr<Texture> texture, SDL_Rect pos, Rotate rotate, float zoom_w, float zoom_h, SDL_RendererFlip flip)

View File

@@ -1,10 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_RendererFlip #include <SDL2/SDL_render.h> // para SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // for Uint16 #include <SDL2/SDL_stdinc.h> // para Uint16
#include <memory> // for shared_ptr #include <memory> // para shared_ptr
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
class Texture; class Texture;
// Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite // Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite

View File

@@ -1,14 +1,14 @@
#include "notifier.h" #include "notifier.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <string> // for string #include <string> // para string
#include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla... #include "jail_audio.h" // para JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "text.h" // for Text #include "text.h" // para Text
#include "texture.h" // for Texture #include "texture.h" // para Texture
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Notifier *Notifier::notifier_ = nullptr; Notifier *Notifier::notifier_ = nullptr;

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string, basic_string #include <string> // para string, basic_string
#include <vector> // for vector #include <vector> // para vector
#include "utils.h" // for Color #include "utils.h" // para Color
class Sprite; class Sprite;
class Text; class Text;
class Texture; class Texture;
@@ -57,6 +57,9 @@ private:
int y; int y;
int travel_dist; int travel_dist;
std::string code; // Permite asignar un código a la notificación std::string code; // Permite asignar un código a la notificación
// Constructor vacío
Notification() = default;
}; };
// Objetos y punteros // Objetos y punteros

View File

@@ -1,16 +1,16 @@
#include "on_screen_help.h" #include "on_screen_help.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <memory> // for make_unique, make_shared, unique_ptr #include <memory> // para make_unique, make_shared, unique_ptr
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "lang.h" // for getText #include "lang.h" // para getText
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "text.h" // for Text #include "text.h" // para Text
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" // for easeInOutSine, Param, ParamGame #include "utils.h" // para easeInOutSine, Param, ParamGame
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
OnScreenHelp *OnScreenHelp::onScreenHelp = nullptr; OnScreenHelp *OnScreenHelp::onScreenHelp = nullptr;

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Texture
#include <vector> // for vector #include <vector> // para vector
class Sprite; class Sprite;
class Text; class Text;

View File

@@ -1,13 +1,13 @@
#include "options.h" #include "options.h"
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton, SDL_C... #include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton, SDL_C...
#include <algorithm> // for max, min #include <algorithm> // para max, min
#include <fstream> // for basic_ostream, operator<<, basi... #include <fstream> // para basic_ostream, operator<<, basi...
#include <iostream> // for cout #include <iostream> // para cout
#include <vector> // for vector #include <vector> // para vector
#include "input.h" // for inputs_e, INPUT_USE_ANY, INPUT_... #include "input.h" // para inputs_e, INPUT_USE_ANY, INPUT_...
#include "lang.h" // for lang_e #include "lang.h" // para lang_e
#include "screen.h" // for ScreenVideoMode, ScreenFilter #include "screen.h" // para ScreenVideoMode, ScreenFilter
#include "utils.h" // for OptionsController, Options, op_... #include "utils.h" // para OptionsController, Options, op_...
// Variables // Variables
Options options; Options options;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string> // for string #include <string> // para string
struct Options; struct Options;
// Variables // Variables

View File

@@ -1,10 +1,10 @@
#include "param.h" #include "param.h"
#include <fstream> // for char_traits, basic_ostream, basic_ifstream, basi... #include <fstream> // para char_traits, basic_ostream, basic_ifstream, basi...
#include <iostream> // for cout #include <iostream> // para cout
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include "utils.h" // for Param, ParamGame, Zone, ParamBalloon #include "utils.h" // para Param, ParamGame, Zone, ParamBalloon
Param param; Param param;

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <string> // for string #include <string> // para string
struct Param; struct Param;
extern Param param; extern Param param;

View File

@@ -1,13 +1,13 @@
#include "player.h" #include "player.h"
#include <SDL2/SDL_render.h> // for SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL... #include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE, SDL...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <stdlib.h> // for rand #include <stdlib.h> // para rand
#include <algorithm> // for max, min #include <algorithm> // para max, min
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "input.h" // for inputs_e #include "input.h" // para inputs_e
#include "param.h" // for param #include "param.h" // para param
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "scoreboard.h" // for Texture #include "scoreboard.h" // para Texture
#include "options.h" #include "options.h"
// Constructor // Constructor

View File

@@ -1,14 +1,14 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
#include "smart_sprite.h" // for SpriteAnimated #include "smart_sprite.h" // para SpriteAnimated
#include "enter_name.h" // for EnterName #include "enter_name.h" // para EnterName
#include "utils.h" // for Circle #include "utils.h" // para Circle
class Texture; class Texture;
enum class InputType : int; enum class InputType : int;
enum class ScoreboardMode; // lines 12-12 enum class ScoreboardMode; // lines 12-12
@@ -41,11 +41,11 @@ class Player
{ {
private: private:
// Constantes // Constantes
static constexpr int POWERUP_COUNTER_ = 1500; // Duración del estado PowerUp static constexpr int POWERUP_COUNTER_ = 1500; // Duración del estado PowerUp
static constexpr int INVULNERABLE_COUNTER_ = 200; // Duración del estado invulnerable static constexpr int INVULNERABLE_COUNTER_ = 200; // Duración del estado invulnerable
static constexpr int WIDTH_ = 30; // Anchura static constexpr int WIDTH_ = 30; // Anchura
static constexpr int HEIGHT_ = 30; // Altura static constexpr int HEIGHT_ = 30; // Altura
static constexpr float BASE_SPEED_ = 1.5f; // Velocidad base del jugador static constexpr float BASE_SPEED_ = 1.5f; // Velocidad base del jugador
// Objetos y punteros // Objetos y punteros
std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador std::unique_ptr<AnimatedSprite> player_sprite_; // Sprite para dibujar el jugador

View File

@@ -113,7 +113,7 @@ std::shared_ptr<TextFile> Resource::getTextFile(const std::string &name)
// Obtiene la animación a partir de un nombre // Obtiene la animación a partir de un nombre
AnimationsFileBuffer &Resource::getAnimation(const std::string &name) AnimationsFileBuffer &Resource::getAnimation(const std::string &name)
{ {
auto it = std::find_if(animations_.begin(), animations_.end(), [&name](auto &a) auto it = std::find_if(animations_.begin(), animations_.end(), [&name](const auto &a)
{ return a.name == name; }); { return a.name == name; });
if (it != animations_.end()) if (it != animations_.end())

View File

@@ -1,17 +1,17 @@
#include "scoreboard.h" #include "scoreboard.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <math.h> // for roundf #include <math.h> // para roundf
#include <iomanip> #include <iomanip>
#include <sstream> #include <sstream>
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "lang.h" // for getText #include "lang.h" // para getText
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" #include "screen.h"
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "text.h" // for Text #include "text.h" // para Text
#include "texture.h" // for Texture #include "texture.h" // para Texture
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard *Scoreboard::scoreboard_ = nullptr; Scoreboard *Scoreboard::scoreboard_ = nullptr;

View File

@@ -1,13 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
#include "utils.h" // for Color #include "utils.h" // para Color
class Sprite; class Sprite;
class Text; class Text;
class Texture; class Texture;

View File

@@ -1,24 +1,23 @@
#include "screen.h" #include "screen.h"
#include <SDL2/SDL_events.h> // for SDL_DISABLE, SDL_ENABLE #include <SDL2/SDL_events.h> // para SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // for SDL_ShowCursor #include <SDL2/SDL_mouse.h> // para SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <algorithm> // for max, min #include <algorithm> // para max, min
#include <fstream> // for basic_ifstream, ifstream #include <fstream> // para basic_ifstream, ifstream
#include <iterator> // for istreambuf_iterator, operator!= #include <iterator> // para istreambuf_iterator, operator!=
#include <string> // for basic_string, operator+, to_string, cha... #include <string> // para basic_string, operator+, to_string, cha...
#include <vector> // for vector #include <vector> // para vector
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "dbgtxt.h" // for dbg_print #include "dbgtxt.h" // para dbg_print
#include "global_inputs.h" // for servicePressedCounter #include "global_inputs.h" // para servicePressedCounter
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT #include "input.h" // para Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT
#include "notifier.h" // for Notify #include "notifier.h" // para Notify
#include "on_screen_help.h" // for OnScreenHelp #include "on_screen_help.h" // para OnScreenHelp
#include "options.h" // for options #include "options.h" // para options
#include "param.h" // for param
#ifndef NO_SHADERS #ifndef NO_SHADERS
#include "jail_shader.h" // for init, render #include "jail_shader.h" // para init, render
#endif #endif
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
@@ -46,26 +45,12 @@ Screen *Screen::get()
Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
: window_(window), : window_(window),
renderer_(renderer), renderer_(renderer),
game_canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)), game_canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
shader_canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)), shader_canvas_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
src_rect_({0, 0, param.game.width, param.game.height}), src_rect_({0, 0, param.game.width, param.game.height}),
dst_rect_({0, 0, param.game.width, param.game.height}) dst_rect_({0, 0, param.game.width, param.game.height})
{ {
// Inicializa variables // Inicializa variables
flash_effect_.enabled = false;
flash_effect_.counter = 0;
flash_effect_.lenght = 0;
flash_effect_.color = Color(0xFF, 0xFF, 0xFF);
shake_effect_.enabled = false;
shake_effect_.desp = 2;
shake_effect_.delay = 3;
shake_effect_.counter = 0;
shake_effect_.lenght = 8;
shake_effect_.remaining = 0;
shake_effect_.originalPos = 0;
shake_effect_.originalWidth = param.game.width;
SDL_DisplayMode DM; SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM); SDL_GetCurrentDisplayMode(0, &DM);
info_resolution_ = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ"; info_resolution_ = std::to_string(DM.w) + " X " + std::to_string(DM.h) + " AT " + std::to_string(DM.refresh_rate) + " HZ";

View File

@@ -1,13 +1,14 @@
#pragma once #pragma once
#include <SDL2/SDL_blendmode.h> // for SDL_BlendMode #include <SDL2/SDL_blendmode.h> // para SDL_BlendMode
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // para SDL_Window
#include <string> // for basic_string, string #include <string> // para basic_string, string
#include "utils.h" // for Color #include "utils.h" // para Color
#include <memory> #include <memory>
#include "param.h" // para param
enum class ScreenFilter : int enum class ScreenFilter : int
{ {
@@ -40,7 +41,7 @@ private:
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
Uint32 fps_ticks_ = 0; // Ticks para contar los frames por segundo Uint32 fps_ticks_ = 0; // Ticks para contar los frames por segundo
int fps_counter_ = 0; // Contador de frames por segundo int fps_counter_ = 0; // Contador de frames por segundo
int fps_; // Frames calculados en el último segundo int fps_ = 0; // Frames calculados en el último segundo
std::string info_resolution_; // Texto con la informacion de la pantalla std::string info_resolution_; // Texto con la informacion de la pantalla
#ifdef DEBUG #ifdef DEBUG
bool show_info_ = true; // Indica si ha de mostrar/ocultar la información de la pantalla bool show_info_ = true; // Indica si ha de mostrar/ocultar la información de la pantalla
@@ -54,6 +55,10 @@ private:
int counter; // Contador para el efecto int counter; // Contador para el efecto
int lenght; // Duración del efecto int lenght; // Duración del efecto
Color color; // Color del efecto Color color; // Color del efecto
// Constructor
FlashEffect(bool en = false, int cnt = 0, int len = 0, Color col = Color(0xFF, 0xFF, 0xFF))
: enabled(en), counter(cnt), lenght(len), color(col) {}
}; };
struct ShakeEffect struct ShakeEffect
@@ -66,6 +71,10 @@ private:
int originalPos; // Posición inicial de la pantalla para dejarla igual tras el desplazamiento int originalPos; // Posición inicial de la pantalla para dejarla igual tras el desplazamiento
int originalWidth; // Anchura inicial de la pantalla para dejarla igual tras el desplazamiento int originalWidth; // Anchura inicial de la pantalla para dejarla igual tras el desplazamiento
bool enabled; // Indica si el efecto está activo bool enabled; // Indica si el efecto está activo
// Constructor
ShakeEffect(bool en = false, int dp = 2, int dl = 3, int cnt = 0, int len = 8, int rem = 0, int origPos = 0, int origWidth = param.game.width)
: desp(dp), delay(dl), counter(cnt), lenght(len), remaining(rem), originalPos(origPos), originalWidth(origWidth), enabled(en) {}
}; };
// Variables - Efectos // Variables - Efectos

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <memory> // for shared_ptr #include <memory> // para shared_ptr
#include "animated_sprite.h" // for SpriteAnimated #include "animated_sprite.h" // para SpriteAnimated
class Texture; class Texture;
// Clase SpriteSmart // Clase SpriteSmart

View File

@@ -1,6 +1,6 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include "texture.h" #include "texture.h"
#include <memory> #include <memory>

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,11 @@
#include "text.h" #include "text.h"
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <fstream> // for basic_ostream, basic_ifstream, basic_istream #include <fstream> // para basic_ostream, basic_ifstream, basic_istream
#include <iostream> // for cout #include <iostream> // para cout
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" // for Color #include "utils.h" // para Color
// Llena una estructuta TextFile desde un fichero // Llena una estructuta TextFile desde un fichero
std::shared_ptr<TextFile> loadTextFile(const std::string &file_path) std::shared_ptr<TextFile> loadTextFile(const std::string &file_path)

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
#include <memory> // for shared_ptr, unique_ptr #include <memory> // para shared_ptr, unique_ptr
#include <string> // for string #include <string> // para string
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "utils.h" // for Color #include "utils.h" // para Color
class Texture; class Texture;
constexpr int TEXT_COLOR = 1; constexpr int TEXT_COLOR = 1;

View File

@@ -1,17 +1,17 @@
#include "texture.h" #include "texture.h"
#include "utils.h" #include "utils.h"
#include <SDL2/SDL_error.h> // for SDL_GetError #include <SDL2/SDL_error.h> // para SDL_GetError
#include <SDL2/SDL_surface.h> // for SDL_CreateRGBSurfaceWithFormatFrom #include <SDL2/SDL_surface.h> // para SDL_CreateRGBSurfaceWithFormatFrom
#include <fcntl.h> // for SEEK_END, SEEK_SET #include <fcntl.h> // para SEEK_END, SEEK_SET
#include <stdio.h> // for fseek, fclose, fopen, fread, ftell, NULL #include <stdio.h> // para fseek, fclose, fopen, fread, ftell, NULL
#include <stdlib.h> // for malloc, free, exit #include <stdlib.h> // para malloc, free, exit
#include <iostream> // for basic_ostream, operator<<, cout, endl #include <iostream> // para basic_ostream, operator<<, cout, endl
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include "gif.c" // for LoadGif, LoadPalette #include "gif.c" // para LoadGif, LoadPalette
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // for stbi_failure_reason, stbi_image_free #include "stb_image.h" // para stbi_failure_reason, stbi_image_free
// Constructor // Constructor
Texture::Texture(SDL_Renderer *renderer, const std::string &path) Texture::Texture(SDL_Renderer *renderer, const std::string &path)

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_blendmode.h> // for SDL_BlendMode #include <SDL2/SDL_blendmode.h> // para SDL_BlendMode
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888, SDL_PixelF... #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888, SDL_PixelF...
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_FLIP_NONE, SDL_TEX... #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_FLIP_NONE, SDL_TEX...
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint32, Uint16 #include <SDL2/SDL_stdinc.h> // para Uint8, Uint32, Uint16
#include <string> // for string, basic_string #include <string> // para string, basic_string
#include <vector> // for vector #include <vector> // para vector
#include <memory> #include <memory>
// Definiciones de tipos // Definiciones de tipos

View File

@@ -1,12 +1,12 @@
#include "tiled_bg.h" #include "tiled_bg.h"
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <stdlib.h> // for rand #include <stdlib.h> // para rand
#include <memory> // for unique_ptr, make_shared, make_unique #include <memory> // para unique_ptr, make_shared, make_unique
#include <cmath> // for sinf #include <cmath> // para sinf
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "texture.h" // for Texture #include "texture.h" // para Texture
// Constructor // Constructor
TiledBG::TiledBG(SDL_Rect pos, TiledBGMode mode) TiledBG::TiledBG(SDL_Rect pos, TiledBGMode mode)

View File

@@ -1,8 +1,8 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <string> // for string, basic_string #include <string> // para string, basic_string
// Modos de funcionamiento para el tileado de fondo // Modos de funcionamiento para el tileado de fondo
enum class TiledBGMode : int enum class TiledBGMode : int

View File

@@ -1,25 +1,25 @@
#include "title.h" #include "title.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // for SDLK_1, SDLK_2, SDLK_3 #include <SDL2/SDL_keycode.h> // para SDLK_1, SDLK_2, SDLK_3
#include <SDL2/SDL_rect.h> // for SDL_Rect #include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <string> // for char_traits, operator+, to_string, bas... #include <string> // para char_traits, operator+, to_string, bas...
#include <utility> // for move #include <utility> // para move
#include <vector> // for vector #include <vector> // para vector
#include "asset.h" // for Asset #include "asset.h" // para Asset
#include "global_inputs.h" // for check #include "global_inputs.h" // para check
#include "input.h" // for Input, InputType, INPUT_DO_NOT_ALLOW_R... #include "input.h" // para Input, InputType, INPUT_DO_NOT_ALLOW_R...
#include "jail_audio.h" // for JA_GetMusicState, JA_Music_state, JA_P... #include "jail_audio.h" // para JA_GetMusicState, JA_Music_state, JA_P...
#include "lang.h" // for getText #include "lang.h" // para getText
#include "notifier.h" // for Notifier #include "notifier.h" // para Notifier
#include "options.h" // for options #include "options.h" // para options
#include "param.h" // for param #include "param.h" // para param
#include "resource.h" // for Resource #include "resource.h" // para Resource
#include "screen.h" // for Screen #include "screen.h" // para Screen
#include "section.h" // for Options, options, Name, name #include "section.h" // para Options, options, Name, name
#include "texture.h" // for Texture #include "texture.h" // para Texture
#include "utils.h" // for Param, OptionsController, Color, Param... #include "utils.h" // para Param, OptionsController, Color, Param...
struct JA_Music_t; // lines 17-17 struct JA_Music_t; // lines 17-17
// Constructor // Constructor

View File

@@ -1,15 +1,15 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // for unique_ptr, shared_ptr #include <memory> // para unique_ptr, shared_ptr
#include "define_buttons.h" // for DefineButtons #include "define_buttons.h" // para DefineButtons
#include "fade.h" // for Fade #include "fade.h" // para Fade
#include "game_logo.h" // for GameLogo #include "game_logo.h" // para GameLogo
#include "sprite.h" // for Sprite #include "sprite.h" // para Sprite
#include "text.h" // for Text #include "text.h" // para Text
#include "tiled_bg.h" // for TiledBG #include "tiled_bg.h" // para TiledBG
class Input; // lines 17-17 class Input; // lines 17-17
#include "section.h" // for Options, options, Name, name #include "section.h" // para Options, options, Name, name
class Screen; // lines 18-18 class Screen; // lines 18-18
class Texture; // lines 20-20 class Texture; // lines 20-20
namespace section namespace section

View File

@@ -2,10 +2,10 @@
#include <filesystem> #include <filesystem>
#include <iostream> #include <iostream>
#include <string> #include <string>
#include <algorithm> // for min, clamp, find_if_not, transform #include <algorithm> // para min, clamp, find_if_not, transform
#include <cctype> // for tolower, isspace #include <cctype> // para tolower, isspace
#include <cmath> // for cos, pow, M_PI #include <cmath> // para cos, pow, M_PI
#include <compare> // for operator< #include <compare> // para operator<
struct JA_Music_t; // lines 7-7 struct JA_Music_t; // lines 7-7
struct JA_Sound_t; // lines 8-8 struct JA_Sound_t; // lines 8-8

View File

@@ -1,12 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton #include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8 #include <SDL2/SDL_stdinc.h> // para Uint8
#include <stdint.h> // for int32_t #include <stdint.h> // para int32_t
#include <string> // for string #include <string> // para string
#include <vector> // for vector #include <vector> // para vector
enum class InputType : int; enum class InputType : int;
enum class ScreenFilter; // lines 14-14 enum class ScreenFilter; // lines 14-14
enum class ScreenVideoMode; // lines 15-15 enum class ScreenVideoMode; // lines 15-15
@@ -49,7 +49,7 @@ struct Circle
int x, y, r; int x, y, r;
// Constructor por defecto // Constructor por defecto
Circle() : x(0), y(0), r(0) {} Circle() : x(0), y(0), r(0) {}
// Constructor // Constructor
Circle(int xCoord, int yCoord, int radius) Circle(int xCoord, int yCoord, int radius)

View File

@@ -1,5 +1,5 @@
#include "writer.h" #include "writer.h"
#include "text.h" // for Text #include "text.h" // para Text
// Actualiza el objeto // Actualiza el objeto
void Writer::update() void Writer::update()

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <memory> // for shared_ptr #include <memory> // para shared_ptr
#include <string> // for string #include <string> // para string
class Text; class Text;
// Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un objeto Text // Clase Writer. Pinta texto en pantalla letra a letra a partir de una cadena y un objeto Text