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 <algorithm> // for copy
#include <fstream> // for basic_ostream, operator<<, basic_istream, basic...
#include <iostream> // for cout
#include <iterator> // for back_insert_iterator, back_inserter
#include <sstream> // for basic_stringstream
#include "texture.h" // for Texture
#include <algorithm> // para copy
#include <fstream> // para basic_ostream, operator<<, basic_istream, basic...
#include <iostream> // para cout
#include <iterator> // para back_insert_iterator, back_inserter
#include <sstream> // para basic_stringstream
#include "texture.h" // para Texture
#include "utils.h"
// 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
void AnimatedSprite::setAnimationSpeed(int index, int 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
void AnimatedSprite::setAnimationLoop(int index, int 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
void AnimatedSprite::setAnimationCompleted(int index, bool value)
{
@@ -222,21 +175,6 @@ void AnimatedSprite::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
void AnimatedSprite::resetAnimation()
{

View File

@@ -1,11 +1,11 @@
#pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint8
#include <memory> // for shared_ptr
#include <string> // for string
#include <vector> // for vector
#include "moving_sprite.h" // for MovingSprite
#include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // para Uint8
#include <memory> // para shared_ptr
#include <string> // para string
#include <vector> // para vector
#include "moving_sprite.h" // para MovingSprite
class Texture;
struct Animation
@@ -52,25 +52,15 @@ public:
// Actualiza las variables del objeto
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
void setAnimationSpeed(const std::string &name, int speed);
void setAnimationSpeed(int index, int speed);
// 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);
// 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);
// Comprueba si ha terminado la animación
@@ -87,12 +77,6 @@ public:
void setCurrentAnimation(const std::string &name = "default");
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
void resetAnimation();
};

View File

@@ -1,11 +1,12 @@
#include "asset.h"
#include "utils.h"
#include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_RWops
#include <SDL2/SDL_stdinc.h> // for SDL_max
#include <stddef.h> // for size_t
#include <iostream> // for basic_ostream, operator<<, cout, endl
#include <SDL2/SDL_rwops.h> // para SDL_RWFromFile, SDL_RWclose, SDL_RWops
#include <SDL2/SDL_stdinc.h> // para SDL_max
#include <stddef.h> // para size_t
#include <iostream> // para basic_ostream, operator<<, cout, endl
#include <fstream>
#include <string>
#include <algorithm> // Para std::find_if
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Asset *Asset::asset_ = nullptr;
@@ -38,17 +39,22 @@ 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
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 f.file;
}
}
return getFileName(f.file) == text;
});
std::cout << "Warning: file " << text.c_str() << " not found" << std::endl;
if (it != file_list_.end())
{
return it->file;
}
else
{
std::cout << "Warning: file " << text << " not found" << std::endl;
return "";
}
}
// Comprueba que existen todos los elementos
bool Asset::check() const

View File

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

View File

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

View File

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

View File

@@ -1,10 +1,10 @@
#include "balloon.h"
#include <cmath> // for abs
#include "animated_sprite.h" // for SpriteAnimated
#include "moving_sprite.h" // for MovingSprite
#include "param.h" // for param
#include "sprite.h" // for Sprite
#include "texture.h" // for Texture
#include <cmath> // para abs
#include "animated_sprite.h" // para SpriteAnimated
#include "moving_sprite.h" // para MovingSprite
#include "param.h" // para param
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
// 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)

View File

@@ -1,11 +1,11 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // for Uint8, Uint16, Uint32
#include <memory> // for shared_ptr, unique_ptr
#include <string> // for string
#include <vector> // for vector
#include "animated_sprite.h" // for SpriteAnimated
#include "utils.h" // for Circle
#include <SDL2/SDL_stdinc.h> // para Uint8, Uint16, Uint32
#include <memory> // para shared_ptr, unique_ptr
#include <string> // para string
#include <vector> // para vector
#include "animated_sprite.h" // para SpriteAnimated
#include "utils.h" // para Circle
class Texture;
// 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.h" // for BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include "param.h" // for param
#include "utils.h" // for ParamGame, Param, Zone, BLOCK
#include "balloon.h" // para BALLOON_VELX_NEGATIVE, BALLOON_VELX_POSITIVE
#include "param.h" // para param
#include "utils.h" // para ParamGame, Param, Zone, BLOCK
// Constructor
BalloonFormations::BalloonFormations()

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
#pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint8
void dbg_init(SDL_Renderer *renderer);
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 <utility> // for move
#include "input.h" // for Input, InputType
#include "lang.h" // for getText
#include "options.h" // for options
#include "param.h" // for param
#include "section.h" // for Name, Options, name, options
#include "text.h" // for Text
#include "utils.h" // for OptionsController, Options, Param, ParamGame
#include <utility> // para move
#include "input.h" // para Input, InputType
#include "lang.h" // para getText
#include "options.h" // para options
#include "param.h" // para param
#include "section.h" // para Name, Options, name, options
#include "text.h" // para Text
#include "utils.h" // para OptionsController, Options, Param, ParamGame
// Constructor
DefineButtons::DefineButtons(std::unique_ptr<Text> text_)

View File

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

View File

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

View File

@@ -1,9 +1,9 @@
#pragma once
#include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for string
#include <vector> // for vector
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_video.h> // para SDL_Window
#include <string> // para string
#include <vector> // para vector
namespace lang
{
enum class Code : int;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,16 +1,16 @@
#include "game_logo.h"
#include <SDL2/SDL_render.h> // for SDL_FLIP_HORIZONTAL
#include <algorithm> // for max
#include "animated_sprite.h" // for SpriteAnimated
#include "asset.h" // for Asset
#include <SDL2/SDL_render.h> // para SDL_FLIP_HORIZONTAL
#include <algorithm> // para max
#include "animated_sprite.h" // para SpriteAnimated
#include "asset.h" // para Asset
#include "jail_audio.h" // JA_PlaySound
#include "param.h" // for param
#include "resource.h" // for Resource
#include "screen.h" // for Screen
#include "smart_sprite.h" // for SpriteSmart
#include "sprite.h" // for Sprite
#include "texture.h" // for Texture
#include "utils.h" // for Param, ParamGame, ParamTitle
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "smart_sprite.h" // para SpriteSmart
#include "sprite.h" // para Sprite
#include "texture.h" // para Texture
#include "utils.h" // para Param, ParamGame, ParamTitle
// Constructor
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())),
x_(x),
y_(y)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,10 +1,10 @@
#pragma once
#include <SDL2/SDL_rect.h> // for SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include <vector> // for vector
#include <SDL2/SDL_rect.h> // para SDL_Point, SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Texture, SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // para unique_ptr, shared_ptr
#include <vector> // para vector
class Fade;
class Sprite;
class Text;

View File

@@ -1,22 +1,22 @@
#include "intro.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <SDL2/SDL_video.h> // for SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // for move
#include "asset.h" // for Asset
#include "global_inputs.h" // for check
#include "input.h" // for Input
#include "jail_audio.h" // for JA_StopMusic, JA_PlayMusic
#include "lang.h" // for getText
#include "param.h" // for param
#include "resource.h" // for Resource
#include "screen.h" // for Screen
#include "section.h" // for Name, name, Options, options
#include "smart_sprite.h" // for SpriteSmart
#include "text.h" // for Text
#include "texture.h" // for Texture
#include "utils.h" // for Param, ParamGame, Zone, BLOCK, Color
#include "writer.h" // for Writer
#include <SDL2/SDL_events.h> // para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL...
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <SDL2/SDL_video.h> // para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // para move
#include "asset.h" // para Asset
#include "global_inputs.h" // para check
#include "input.h" // para Input
#include "jail_audio.h" // para JA_StopMusic, JA_PlayMusic
#include "lang.h" // para getText
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "section.h" // para Name, name, Options, options
#include "smart_sprite.h" // para SpriteSmart
#include "text.h" // para Text
#include "texture.h" // para Texture
#include "utils.h" // para Param, ParamGame, Zone, BLOCK, Color
#include "writer.h" // para Writer
struct JA_Music_t; // lines 19-19
// Constructor

View File

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

View File

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

View File

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

View File

@@ -1,26 +1,29 @@
#ifndef JA_USESDLMIXER
#include "jail_audio.h"
#include <stdint.h> // for uint8_t
#include <stdio.h> // for NULL, fseek, fclose, fopen, fread, ftell, FILE
#include <stdlib.h> // for free, malloc
#include "stb_vorbis.c" // for stb_vorbis_decode_memory
#include <stdint.h> // para uint8_t
#include <stdio.h> // para NULL, fseek, fclose, fopen, fread, ftell, FILE
#include <stdlib.h> // para free, malloc
#include "stb_vorbis.c" // para stb_vorbis_decode_memory
#define JA_MAX_SIMULTANEOUS_CHANNELS 5
struct JA_Sound_t {
struct JA_Sound_t
{
Uint32 length{0};
Uint8 *buffer{NULL};
};
struct JA_Channel_t {
struct JA_Channel_t
{
JA_Sound_t *sound;
int pos{0};
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 times{0};
@@ -40,35 +43,49 @@ bool JA_musicEnabled = true;
bool JA_soundEnabled = true;
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);
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);
current_music->pos += size / 2;
if (size < len) {
if (current_music->times != 0) {
if (size < len)
{
if (current_music->times != 0)
{
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 {
if (current_music->times > 0)
current_music->times--;
}
else
{
current_music->pos = 0;
current_music->state = JA_MUSIC_STOPPED;
}
}
}
// Mixar els channels mi amol
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
if (channels[i].state == JA_CHANNEL_PLAYING) {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
if (channels[i].state == JA_CHANNEL_PLAYING)
{
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);
channels[i].pos += size;
if (size < len) {
if (channels[i].times != 0) {
if (size < len)
{
if (channels[i].times != 0)
{
SDL_MixAudioFormat(stream + size, channels[i].sound->buffer, AUDIO_S16, len - size, JA_soundVolume);
channels[i].pos = len - size;
if (channels[i].times > 0) channels[i].times--;
} else {
if (channels[i].times > 0)
channels[i].times--;
}
else
{
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_format = format;
JA_channels = channels;
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);
SDL_PauseAudioDevice(sdlAudioDevice, 0);
}
void JA_Quit() {
void JA_Quit()
{
SDL_PauseAudioDevice(sdlAudioDevice, 1);
if (sdlAudioDevice != 0) SDL_CloseAudioDevice(sdlAudioDevice);
if (sdlAudioDevice != 0)
SDL_CloseAudioDevice(sdlAudioDevice);
sdlAudioDevice = 0;
}
JA_Music_t *JA_LoadMusic(const char* filename) {
JA_Music_t *JA_LoadMusic(const char *filename)
{
int chan, samplerate;
// [RZC 28/08/22] Carreguem primer el arxiu en memòria i després el descomprimim. Es algo més rapid.
@@ -101,7 +123,8 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
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);
JA_Music_t *music = new JA_Music_t();
@@ -113,7 +136,8 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
SDL_AudioCVT cvt;
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.buf = (Uint8 *)SDL_malloc(cvt.len * cvt.len_mult);
SDL_memcpy(cvt.buf, music->output, cvt.len);
@@ -129,9 +153,11 @@ JA_Music_t *JA_LoadMusic(const char* filename) {
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->state = JA_MUSIC_STOPPED;
}
@@ -143,67 +169,78 @@ void JA_PlayMusic(JA_Music_t *music, const int loop)
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;
}
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;
}
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->state = JA_MUSIC_STOPPED;
}
JA_Music_state JA_GetMusicState() {
if (!JA_musicEnabled) return JA_MUSIC_DISABLED;
JA_Music_state JA_GetMusicState()
{
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;
}
void JA_DeleteMusic(JA_Music_t *music) {
if (current_music == music) current_music = NULL;
void JA_DeleteMusic(JA_Music_t *music)
{
if (current_music == music)
current_music = NULL;
free(music->output);
delete music;
}
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;
}
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_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();
sound->buffer = buffer;
sound->length = length;
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();
SDL_AudioSpec wavSpec;
SDL_LoadWAV(filename, &wavSpec, &sound->buffer, &sound->length);
@@ -223,11 +260,16 @@ JA_Sound_t *JA_LoadSound(const char* filename) {
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;
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE) { channel++; }
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS) channel = 0;
while (channel < JA_MAX_SIMULTANEOUS_CHANNELS && channels[channel].state != JA_CHANNEL_FREE)
{
channel++;
}
if (channel == JA_MAX_SIMULTANEOUS_CHANNELS)
channel = 0;
channels[channel].sound = sound;
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)
{
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
if (channels[i].sound == sound) JA_StopChannel(i);
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
if (channels[i].sound == sound)
JA_StopChannel(i);
}
SDL_free(sound->buffer);
delete sound;
@@ -247,41 +291,60 @@ void JA_DeleteSound(JA_Sound_t *sound)
void JA_PauseChannel(const int channel)
{
if (!JA_soundEnabled) return;
if (!JA_soundEnabled)
return;
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;
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;
}
} 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)
{
if (!JA_soundEnabled) return;
if (!JA_soundEnabled)
return;
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;
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;
}
} 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)
{
if (!JA_soundEnabled) return;
if (!JA_soundEnabled)
return;
if (channel == -1) {
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++) {
if (channel == -1)
{
for (int i = 0; i < JA_MAX_SIMULTANEOUS_CHANNELS; i++)
{
channels[i].state = JA_CHANNEL_FREE;
channels[i].pos = 0;
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].pos = 0;
channels[channel].sound = NULL;
@@ -290,15 +353,18 @@ void JA_StopChannel(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;
}
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;
}
@@ -306,14 +372,16 @@ void JA_EnableSound(const bool value)
{
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;
}
int JA_SetVolume(int volume)
{
JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0 : volume;
JA_musicVolume = volume > 128 ? 128 : volume < 0 ? 0
: volume;
JA_soundVolume = JA_musicVolume / 2;
return JA_musicVolume;
}

View File

@@ -1,12 +1,26 @@
#pragma once
#include <SDL2/SDL_audio.h> // for SDL_AudioFormat
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8
#include <SDL2/SDL_audio.h> // para SDL_AudioFormat
#include <SDL2/SDL_stdinc.h> // para Uint32, Uint8
struct JA_Music_t; // lines 5-5
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_Music_state { JA_MUSIC_INVALID, JA_MUSIC_PLAYING, JA_MUSIC_PAUSED, JA_MUSIC_STOPPED, JA_MUSIC_DISABLED };
enum JA_Channel_state
{
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_Quit();

View File

@@ -1,10 +1,10 @@
#ifndef NO_SHADERS
#include "jail_shader.h"
#include <SDL2/SDL_rect.h> // for SDL_Point
#include <stdlib.h> // for NULL, free, malloc, exit
#include <string.h> // for strncmp
#include <iostream> // for basic_ostream, char_traits, operator<<
#include <SDL2/SDL_rect.h> // para SDL_Point
#include <stdlib.h> // para NULL, free, malloc, exit
#include <string.h> // para strncmp
#include <iostream> // para basic_ostream, char_traits, operator<<
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
@@ -47,7 +47,8 @@ namespace shader
PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
PFNGLUSEPROGRAMPROC glUseProgram;
bool initGLExtensions() {
bool initGLExtensions()
{
glCreateShader = (PFNGLCREATESHADERPROC)SDL_GL_GetProcAddress("glCreateShader");
glShaderSource = (PFNGLSHADERSOURCEPROC)SDL_GL_GetProcAddress("glShaderSource");
glCompileShader = (PFNGLCOMPILESHADERPROC)SDL_GL_GetProcAddress("glCompileShader");
@@ -70,7 +71,8 @@ namespace shader
#endif
GLuint compileShader(const char* source, GLuint shaderType) {
GLuint compileShader(const char *source, GLuint shaderType)
{
// Create ID for shader
GLuint result = glCreateShader(shaderType);
// Add define depending on shader type
@@ -83,7 +85,8 @@ namespace shader
// Check vertex shader for errors
GLint shaderCompiled = GL_FALSE;
glGetShaderiv(result, GL_COMPILE_STATUS, &shaderCompiled);
if( shaderCompiled != GL_TRUE ) {
if (shaderCompiled != GL_TRUE)
{
std::cout << "Error en la compilación: " << result << "!" << std::endl;
GLint logLength;
glGetShaderiv(result, GL_INFO_LOG_LENGTH, &logLength);
@@ -102,7 +105,8 @@ namespace shader
return result;
}
GLuint compileProgram(const char* vertexShaderSource, const char* fragmentShaderSource) {
GLuint compileProgram(const char *vertexShaderSource, const char *fragmentShaderSource)
{
GLuint programId = 0;
GLuint vtxShaderId, fragShaderId;
@@ -111,7 +115,8 @@ namespace shader
vtxShaderId = compileShader(vertexShaderSource, GL_VERTEX_SHADER);
fragShaderId = compileShader(fragmentShaderSource ? fragmentShaderSource : vertexShaderSource, GL_FRAGMENT_SHADER);
if(vtxShaderId && fragShaderId) {
if (vtxShaderId && fragShaderId)
{
// Associate shader with program
glAttachShader(programId, vtxShaderId);
glAttachShader(programId, fragShaderId);
@@ -121,18 +126,22 @@ namespace shader
// Check the status of the compile/link
GLint logLen;
glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &logLen);
if(logLen > 0) {
if (logLen > 0)
{
char *log = (char *)malloc(logLen * sizeof(char));
// Show any errors as appropriate
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);
}
}
if(vtxShaderId) {
if (vtxShaderId)
{
glDeleteShader(vtxShaderId);
}
if(fragShaderId) {
if (fragShaderId)
{
glDeleteShader(fragShaderId);
}
return programId;
@@ -155,10 +164,12 @@ namespace shader
SDL_RendererInfo 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__
if (!initGLExtensions()) {
if (!initGLExtensions())
{
std::cout << "WARNING: No s'han pogut inicialitzar les extensions d'OpenGL!" << std::endl;
usingOpenGL = false;
return false;
@@ -167,7 +178,9 @@ namespace shader
// Compilar el shader y dejarlo listo para usar.
programId = compileProgram(vertexShader, fragmentShader);
// std::cout << "programId = " << programId << std::endl;
} else {
}
else
{
std::cout << "WARNING: El driver del renderer no es OpenGL." << std::endl;
usingOpenGL = false;
return false;
@@ -186,9 +199,11 @@ namespace shader
SDL_SetRenderTarget(renderer, NULL);
SDL_RenderClear(renderer);
if (usingOpenGL) {
if (usingOpenGL)
{
SDL_GL_BindTexture(backBuffer, NULL, NULL);
if(programId != 0) {
if (programId != 0)
{
glGetIntegerv(GL_CURRENT_PROGRAM, &oldProgramId);
glUseProgram(programId);
}
@@ -221,10 +236,13 @@ namespace shader
glEnd();
SDL_GL_SwapWindow(win);
if(programId != 0) {
if (programId != 0)
{
glUseProgram(oldProgramId);
}
} else {
}
else
{
SDL_RenderCopy(renderer, backBuffer, NULL, NULL);
SDL_RenderPresent(renderer);
}

View File

@@ -2,8 +2,8 @@
#pragma once
#include <SDL2/SDL_render.h> // for SDL_Texture
#include <SDL2/SDL_video.h> // for SDL_Window
#include <SDL2/SDL_render.h> // para SDL_Texture
#include <SDL2/SDL_video.h> // para SDL_Window
// TIPS:
// =======================================================================

View File

@@ -1,6 +1,6 @@
#include "lang.h"
#include <fstream> // for basic_ifstream, basic_istream, ifstream
#include <vector> // for vector
#include <fstream> // para basic_ifstream, basic_istream, ifstream
#include <vector> // para vector
namespace lang
{

View File

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

View File

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

View File

@@ -1,11 +1,11 @@
#pragma once
#include <SDL2/SDL_rect.h> // for SDL_Point
#include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include <vector> // for vector
#include "sprite.h" // for Sprite
#include "utils.h" // for Color
#include <SDL2/SDL_rect.h> // para SDL_Point
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // para unique_ptr, shared_ptr
#include <vector> // para vector
#include "sprite.h" // para Sprite
#include "utils.h" // para Color
class Texture;
/*

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 <memory> // for make_unique, unique_ptr
#include "director.h" // for Director
#include <iostream> // para char_traits, basic_ostream, operator<<, cout
#include <memory> // para make_unique, unique_ptr
#include "director.h" // para Director
int main(int argc, char *argv[])
{

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
#include "moving_sprite.h"
#include "texture.h" // for Texture
#include "texture.h" // para Texture
// Constructor
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
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // for Uint16
#include <memory> // for shared_ptr
#include "sprite.h" // for Sprite
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_RendererFlip
#include <SDL2/SDL_stdinc.h> // para Uint16
#include <memory> // para shared_ptr
#include "sprite.h" // para Sprite
class Texture;
// 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 <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <string> // for string
#include "jail_audio.h" // for JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "param.h" // for param
#include "resource.h" // for Resource
#include "screen.h" // for Screen
#include "sprite.h" // for Sprite
#include "text.h" // for Text
#include "texture.h" // for Texture
#include <SDL2/SDL_blendmode.h> // para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <string> // para string
#include "jail_audio.h" // para JA_DeleteSound, JA_LoadSound, JA_Pla...
#include "param.h" // para param
#include "resource.h" // para Resource
#include "screen.h" // para Screen
#include "sprite.h" // para Sprite
#include "text.h" // para Text
#include "texture.h" // para Texture
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Notifier *Notifier::notifier_ = nullptr;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,14 +1,14 @@
#pragma once
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include <string> // for string
#include <vector> // for vector
#include "animated_sprite.h" // for SpriteAnimated
#include "smart_sprite.h" // for SpriteAnimated
#include "enter_name.h" // for EnterName
#include "utils.h" // for Circle
#include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // para unique_ptr, shared_ptr
#include <string> // para string
#include <vector> // para vector
#include "animated_sprite.h" // para SpriteAnimated
#include "smart_sprite.h" // para SpriteAnimated
#include "enter_name.h" // para EnterName
#include "utils.h" // para Circle
class Texture;
enum class InputType : int;
enum class ScoreboardMode; // lines 12-12

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
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; });
if (it != animations_.end())

View File

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

View File

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

View File

@@ -1,24 +1,23 @@
#include "screen.h"
#include <SDL2/SDL_events.h> // for SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // for SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <algorithm> // for max, min
#include <fstream> // for basic_ifstream, ifstream
#include <iterator> // for istreambuf_iterator, operator!=
#include <string> // for basic_string, operator+, to_string, cha...
#include <vector> // for vector
#include "asset.h" // for Asset
#include "dbgtxt.h" // for dbg_print
#include "global_inputs.h" // for servicePressedCounter
#include "input.h" // for Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT
#include "notifier.h" // for Notify
#include "on_screen_help.h" // for OnScreenHelp
#include "options.h" // for options
#include "param.h" // for param
#include <SDL2/SDL_events.h> // para SDL_DISABLE, SDL_ENABLE
#include <SDL2/SDL_mouse.h> // para SDL_ShowCursor
#include <SDL2/SDL_pixels.h> // para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // para SDL_GetTicks
#include <algorithm> // para max, min
#include <fstream> // para basic_ifstream, ifstream
#include <iterator> // para istreambuf_iterator, operator!=
#include <string> // para basic_string, operator+, to_string, cha...
#include <vector> // para vector
#include "asset.h" // para Asset
#include "dbgtxt.h" // para dbg_print
#include "global_inputs.h" // para servicePressedCounter
#include "input.h" // para Input, inputs_e, INPUT_DO_NOT_ALLOW_REPEAT
#include "notifier.h" // para Notify
#include "on_screen_help.h" // para OnScreenHelp
#include "options.h" // para options
#ifndef NO_SHADERS
#include "jail_shader.h" // for init, render
#include "jail_shader.h" // para init, render
#endif
// [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)
: window_(window),
renderer_(renderer),
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)),
src_rect_({0, 0, param.game.width, param.game.height}),
dst_rect_({0, 0, param.game.width, param.game.height})
{
// 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_GetCurrentDisplayMode(0, &DM);
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
#include <SDL2/SDL_blendmode.h> // for SDL_BlendMode
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for basic_string, string
#include "utils.h" // for Color
#include <SDL2/SDL_blendmode.h> // para SDL_BlendMode
#include <SDL2/SDL_rect.h> // para SDL_Rect
#include <SDL2/SDL_render.h> // para SDL_Renderer, SDL_Texture
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <SDL2/SDL_video.h> // para SDL_Window
#include <string> // para basic_string, string
#include "utils.h" // para Color
#include <memory>
#include "param.h" // para param
enum class ScreenFilter : int
{
@@ -40,7 +41,7 @@ private:
bool attenuate_effect_ = false; // Indica si la pantalla ha de estar atenuada
Uint32 fps_ticks_ = 0; // Ticks para contar los 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
#ifdef DEBUG
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 lenght; // Duración 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
@@ -66,6 +71,10 @@ private:
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
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

View File

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

View File

@@ -1,6 +1,6 @@
#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 <memory>

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,15 +1,15 @@
#pragma once
#include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for unique_ptr, shared_ptr
#include "define_buttons.h" // for DefineButtons
#include "fade.h" // for Fade
#include "game_logo.h" // for GameLogo
#include "sprite.h" // for Sprite
#include "text.h" // for Text
#include "tiled_bg.h" // for TiledBG
#include <SDL2/SDL_stdinc.h> // para Uint32
#include <memory> // para unique_ptr, shared_ptr
#include "define_buttons.h" // para DefineButtons
#include "fade.h" // para Fade
#include "game_logo.h" // para GameLogo
#include "sprite.h" // para Sprite
#include "text.h" // para Text
#include "tiled_bg.h" // para TiledBG
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 Texture; // lines 20-20
namespace section

View File

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

View File

@@ -1,12 +1,12 @@
#pragma once
#include <SDL2/SDL_gamecontroller.h> // for SDL_GameControllerButton
#include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint8
#include <stdint.h> // for int32_t
#include <string> // for string
#include <vector> // for vector
#include <SDL2/SDL_gamecontroller.h> // para SDL_GameControllerButton
#include <SDL2/SDL_rect.h> // para SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // para Uint8
#include <stdint.h> // para int32_t
#include <string> // para string
#include <vector> // para vector
enum class InputType : int;
enum class ScreenFilter; // lines 14-14
enum class ScreenVideoMode; // lines 15-15

View File

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

View File

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