Estandaritzant noms segons convencions
This commit is contained in:
216
source/utils.h
216
source/utils.h
@@ -25,128 +25,104 @@ enum class GameDifficulty
|
||||
#define BLOCK 8
|
||||
|
||||
// Estructura para definir un circulo
|
||||
struct circle_t
|
||||
struct Circle
|
||||
{
|
||||
int x, y, r;
|
||||
};
|
||||
|
||||
// Estructura para definir una linea horizontal
|
||||
struct h_line_t
|
||||
{
|
||||
int x1, x2, y;
|
||||
};
|
||||
|
||||
// Estructura para definir una linea vertical
|
||||
struct v_line_t
|
||||
{
|
||||
int x, y1, y2;
|
||||
};
|
||||
|
||||
// Estructura para definir una linea diagonal
|
||||
struct d_line_t
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
};
|
||||
|
||||
// Estructura para definir una linea
|
||||
struct line_t
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
};
|
||||
|
||||
// Estructura para definir un color
|
||||
struct color_t
|
||||
struct Color
|
||||
{
|
||||
Uint8 r, g, b;
|
||||
};
|
||||
|
||||
// Posiciones de las notificaciones
|
||||
enum not_pos_e
|
||||
enum class NotifyPosition
|
||||
{
|
||||
pos_top,
|
||||
pos_bottom,
|
||||
pos_left,
|
||||
pos_middle,
|
||||
pos_right
|
||||
TOP,
|
||||
BOTTOM,
|
||||
LEFT,
|
||||
MIDDLE,
|
||||
RIGHT,
|
||||
};
|
||||
|
||||
// Estructura para saber la seccion y subseccion del programa
|
||||
struct section_t
|
||||
struct Section
|
||||
{
|
||||
Uint8 name;
|
||||
Uint8 options;
|
||||
};
|
||||
|
||||
// Estructura para las entradas de la tabla de recirds
|
||||
struct hiScoreEntry_t
|
||||
struct HiScoreEntry
|
||||
{
|
||||
std::string name; // Nombre
|
||||
int score; // Puntuación
|
||||
};
|
||||
|
||||
// Estructura para mapear el teclado usado en la demo
|
||||
struct demoKeys_t
|
||||
struct DemoKeys
|
||||
{
|
||||
Uint8 left;
|
||||
Uint8 right;
|
||||
Uint8 noInput;
|
||||
Uint8 no_input;
|
||||
Uint8 fire;
|
||||
Uint8 fireLeft;
|
||||
Uint8 fireRight;
|
||||
Uint8 fire_left;
|
||||
Uint8 fire_right;
|
||||
};
|
||||
|
||||
// Estructura para las opciones de la ventana
|
||||
struct op_window_t
|
||||
struct OptionsWindow
|
||||
{
|
||||
int size; // Contiene el valor por el que se multiplica el tamaño de la ventana
|
||||
};
|
||||
|
||||
// Estructura con opciones para el video
|
||||
struct op_video_t
|
||||
struct OptionsVideo
|
||||
{
|
||||
op_window_t window; // Opciones para la ventana del programa
|
||||
OptionsWindow window; // Opciones para la ventana del programa
|
||||
ScreenVideoMode mode; // Contiene el valor del modo de pantalla completa
|
||||
ScreenFilter filter; // Filtro usado para el escalado de la imagen
|
||||
bool vSync; // Indica si se quiere usar vsync o no
|
||||
bool v_sync; // Indica si se quiere usar vsync o no
|
||||
bool shaders; // Indica si se van a usar shaders para los filtros de video
|
||||
};
|
||||
|
||||
// Estructura para las opciones de musica
|
||||
struct op_music_t
|
||||
struct OptionsMusic
|
||||
{
|
||||
bool enabled; // Indica si la musica suena o no
|
||||
int volume; // Volumen al que suena la música
|
||||
};
|
||||
|
||||
// Estructura para las opciones de sonido
|
||||
struct op_sound_t
|
||||
struct OptionsSound
|
||||
{
|
||||
bool enabled; // Indica si los sonidos suenan o no
|
||||
int volume; // Volumen al que suenan los sonidos
|
||||
};
|
||||
|
||||
// Estructura para las opciones de audio
|
||||
struct op_audio_t
|
||||
struct OptionsAudio
|
||||
{
|
||||
op_music_t music; // Opciones para la música
|
||||
op_sound_t sound; // Opciones para los efectos de sonido
|
||||
OptionsMusic music; // Opciones para la música
|
||||
OptionsSound sound; // Opciones para los efectos de sonido
|
||||
};
|
||||
|
||||
// Estructura para las opciones del juego
|
||||
struct op_game_t
|
||||
struct OptionsGame
|
||||
{
|
||||
GameDifficulty difficulty; // Dificultad del juego
|
||||
Uint8 language; // Idioma usado en el juego
|
||||
bool autofire; // Indica si el jugador ha de pulsar repetidamente para disparar o basta con mantener pulsado
|
||||
std::vector<hiScoreEntry_t> hiScoreTable; // Tabla con las mejores puntuaciones
|
||||
std::vector<HiScoreEntry> hi_score_table; // Tabla con las mejores puntuaciones
|
||||
};
|
||||
|
||||
// Estructura para los controles del juego
|
||||
struct op_controller_t
|
||||
struct OptionsController
|
||||
{
|
||||
int index; // Indice en el vector de mandos
|
||||
int playerId; // Jugador asociado al mando
|
||||
Uint8 deviceType; // Indica si se utilizará teclado o mando o ambos
|
||||
int player_id; // Jugador asociado al mando
|
||||
Uint8 device_type; // Indica si se utilizará teclado o mando o ambos
|
||||
std::string name; // Nombre del dispositivo
|
||||
bool plugged; // Indica si el mando se encuentra conectado
|
||||
std::vector<inputs_e> inputs; // Listado de inputs
|
||||
@@ -154,100 +130,100 @@ struct op_controller_t
|
||||
};
|
||||
|
||||
// Estructura para las opciones de las notificaciones
|
||||
struct op_notification_t
|
||||
struct OptionsNotification
|
||||
{
|
||||
not_pos_e posH; // Ubicación de las notificaciones en pantalla
|
||||
not_pos_e posV; // Ubicación de las notificaciones en pantalla
|
||||
bool sound; // Indica si las notificaciones suenan
|
||||
color_t color; // Color de las notificaciones
|
||||
NotifyPosition pos_h; // Ubicación de las notificaciones en pantalla
|
||||
NotifyPosition pos_v; // Ubicación de las notificaciones en pantalla
|
||||
bool sound; // Indica si las notificaciones suenan
|
||||
Color color; // Color de las notificaciones
|
||||
};
|
||||
|
||||
// Estructura con todas las opciones de configuración del programa
|
||||
struct options_t
|
||||
struct Options
|
||||
{
|
||||
op_game_t game; // Opciones para el propio juego
|
||||
op_video_t video; // Opciones relativas a la clase screen
|
||||
op_audio_t audio; // Opciones para el audio
|
||||
op_notification_t notification; // Opciones para las notificaciones
|
||||
std::vector<op_controller_t> controller; // Opciones con las asignaciones del mando para cada jugador
|
||||
OptionsGame game; // Opciones para el propio juego
|
||||
OptionsVideo video; // Opciones relativas a la clase screen
|
||||
OptionsAudio audio; // Opciones para el audio
|
||||
OptionsNotification notification; // Opciones para las notificaciones
|
||||
std::vector<OptionsController> controller; // Opciones con las asignaciones del mando para cada jugador
|
||||
};
|
||||
|
||||
// Posiciones dentro de un rectangulo
|
||||
struct zone_t
|
||||
struct Zone
|
||||
{
|
||||
SDL_Rect rect; // Rectangulo que define la zona
|
||||
int centerX; // Anclaje al 50% del eje X
|
||||
int firstQuarterX; // Anclaje al 25% del eje X
|
||||
int thirdQuarterX; // Anclaje al 75% del eje X
|
||||
int centerY; // Anclaje al 50% del eje Y
|
||||
int firstQuarterY; // Anclaje al 25% del eje Y
|
||||
int thirdQuarterY; // Anclaje al 75% del eje X
|
||||
SDL_Rect rect; // Rectangulo que define la zona
|
||||
int center_x; // Anclaje al 50% del eje X
|
||||
int first_quarter_x; // Anclaje al 25% del eje X
|
||||
int third_quarter_x; // Anclaje al 75% del eje X
|
||||
int center_y; // Anclaje al 50% del eje Y
|
||||
int first_quarter_y; // Anclaje al 25% del eje Y
|
||||
int third_quarter_y; // Anclaje al 75% del eje X
|
||||
};
|
||||
|
||||
// param.game
|
||||
struct paramGame_t
|
||||
struct ParamGame
|
||||
{
|
||||
int width; // Ancho de la resolucion nativa del juego
|
||||
int height; // Alto de la resolucion nativa del juego
|
||||
int itemSize; // Tamaño de los items del juego
|
||||
zone_t playArea; // Rectangulo con la posición de la zona de juego
|
||||
zone_t gameArea; // Rectangulo con las dimensiones del juego
|
||||
int width; // Ancho de la resolucion nativa del juego
|
||||
int height; // Alto de la resolucion nativa del juego
|
||||
int item_size; // Tamaño de los items del juego
|
||||
Zone play_area; // Rectangulo con la posición de la zona de juego
|
||||
Zone game_area; // Rectangulo con las dimensiones del juego
|
||||
};
|
||||
|
||||
// param.fade
|
||||
struct paramFade_t
|
||||
struct ParamFade
|
||||
{
|
||||
int numSquaresWidth; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
|
||||
int numSquaresHeight; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
|
||||
int randomSquaresDelay; // Duración entre cada pintado de cuadrados
|
||||
int randomSquaresMult; // Cantidad de cuadrados que se pintaran cada vez
|
||||
int postDuration; // Duración final del fade
|
||||
int venetianSize; // Altura de los rectangulos para FadeType::VENETIAN
|
||||
int num_squares_width; // Cantidad total de cuadraditos en horizontal para el FadeType::RANDOM_SQUARE
|
||||
int num_squares_height; // Cantidad total de cuadraditos en vertical para el FadeType::RANDOM_SQUARE
|
||||
int random_squares_delay; // Duración entre cada pintado de cuadrados
|
||||
int random_squares_mult; // Cantidad de cuadrados que se pintaran cada vez
|
||||
int post_duration; // Duración final del fade
|
||||
int venetian_size; // Altura de los rectangulos para FadeType::VENETIAN
|
||||
};
|
||||
|
||||
// param.title
|
||||
struct paramTitle_t
|
||||
struct ParamTitle
|
||||
{
|
||||
int pressStartPosition; // Posición del texto para empezar a jugar
|
||||
int titleDuration; // Tiempo de inactividad del titulo
|
||||
int arcadeEditionPosition; // Posición del bitmap
|
||||
int titleCCPosition; // Posición del bitmap
|
||||
int press_start_position; // Posición del texto para empezar a jugar
|
||||
int title_duration; // Tiempo de inactividad del titulo
|
||||
int arcade_edition_position; // Posición del bitmap
|
||||
int title_c_c_position; // Posición del bitmap
|
||||
};
|
||||
|
||||
// param.background
|
||||
struct paramBackground_t
|
||||
struct ParamBackground
|
||||
{
|
||||
color_t attenuateColor;
|
||||
int attenuateAlpha;
|
||||
Color attenuate_color;
|
||||
int attenuate_alpha;
|
||||
};
|
||||
|
||||
// Estructura para guardar los parametros de un globo
|
||||
struct paramBalloon_t
|
||||
struct ParamBalloon
|
||||
{
|
||||
float grav; // Aceleración en el eje Y. Modifica la velocidad
|
||||
float vel; // Velocidad inicial que tienen al rebotar contra el suelo
|
||||
};
|
||||
|
||||
// Estructura para almacenar todos los parámetros del juego
|
||||
struct param_t
|
||||
struct Param
|
||||
{
|
||||
paramGame_t game; // Parametros relacionados con el juego
|
||||
paramFade_t fade; // Parametros para ajustar el fade
|
||||
SDL_Rect scoreboard; // Posición y tamaño del marcador
|
||||
paramTitle_t title; // Parametros con ajustes para la sección Title
|
||||
paramBackground_t background; // Parametros que afectan a la clase Background
|
||||
paramBalloon_t balloon1, balloon2, balloon3, balloon4; // Parametros de velocidad y gravedad de cada tipo de globo
|
||||
ParamGame game; // Parametros relacionados con el juego
|
||||
ParamFade fade; // Parametros para ajustar el fade
|
||||
SDL_Rect scoreboard; // Posición y tamaño del marcador
|
||||
ParamTitle title; // Parametros con ajustes para la sección Title
|
||||
ParamBackground background; // Parametros que afectan a la clase Background
|
||||
ParamBalloon balloon_1, balloon_2, balloon_3, balloon_4; // Parametros de velocidad y gravedad de cada tipo de globo
|
||||
};
|
||||
|
||||
// Estructura para almacenar ficheros de sonido y su nombre
|
||||
struct sound_file_t
|
||||
struct SoundFile
|
||||
{
|
||||
std::string name; // Nombre del sonido
|
||||
JA_Sound_t *file; // Fichero con el sonido
|
||||
};
|
||||
|
||||
// Estructura para almacenar ficheros musicales y su nombre
|
||||
struct music_file_t
|
||||
struct MusicFile
|
||||
{
|
||||
std::string name; // Nombre de la musica
|
||||
JA_Music_t *file; // Fichero con la música
|
||||
@@ -257,10 +233,10 @@ struct music_file_t
|
||||
double distanceSquared(int x1, int y1, int x2, int y2);
|
||||
|
||||
// Detector de colisiones entre dos circulos
|
||||
bool checkCollision(circle_t &a, circle_t &b);
|
||||
bool checkCollision(Circle &a, Circle &b);
|
||||
|
||||
// Detector de colisiones entre un circulo y un rectangulo
|
||||
bool checkCollision(circle_t &a, SDL_Rect &b);
|
||||
bool checkCollision(Circle &a, SDL_Rect &b);
|
||||
|
||||
// Detector de colisiones entre un dos rectangulos
|
||||
bool checkCollision(SDL_Rect &a, SDL_Rect &b);
|
||||
@@ -281,22 +257,22 @@ std::string boolToOnOff(bool value);
|
||||
std::string toLower(std::string str);
|
||||
|
||||
// Obtiene el fichero de sonido a partir de un nombre
|
||||
JA_Sound_t *getSound(std::vector<sound_file_t> sounds, std::string name);
|
||||
JA_Sound_t *getSound(std::vector<SoundFile> sounds, std::string name);
|
||||
|
||||
// Obtiene el fichero de música a partir de un nombre
|
||||
JA_Music_t *getMusic(std::vector<music_file_t> music, std::string name);
|
||||
JA_Music_t *getMusic(std::vector<MusicFile> music, std::string name);
|
||||
|
||||
// Ordena las entradas de la tabla de records
|
||||
hiScoreEntry_t sortHiScoreTable(hiScoreEntry_t entry1, hiScoreEntry_t entry2);
|
||||
HiScoreEntry sortHiScoreTable(HiScoreEntry entry1, HiScoreEntry entry2);
|
||||
|
||||
// Dibuja un circulo
|
||||
void DrawCircle(SDL_Renderer *renderer, int32_t centerX, int32_t centerY, int32_t radius);
|
||||
|
||||
// Aclara el color
|
||||
color_t lightenColor(color_t color, int amount);
|
||||
Color lightenColor(Color color, int amount);
|
||||
|
||||
// Oscurece el color
|
||||
color_t DarkenColor(color_t color, int amount);
|
||||
Color DarkenColor(Color color, int amount);
|
||||
|
||||
// Quita los espacioes en un string
|
||||
std::string trim(const std::string &str);
|
||||
@@ -308,14 +284,14 @@ double easeOutQuint(double t);
|
||||
double easeInOutSine(double t);
|
||||
|
||||
// Colores
|
||||
extern const color_t bgColor;
|
||||
extern const color_t noColor;
|
||||
extern const color_t shdwTxtColor;
|
||||
extern const color_t separatorColor;
|
||||
extern const color_t scoreboardColor;
|
||||
extern const color_t difficultyEasyColor;
|
||||
extern const color_t difficultyNormalColor;
|
||||
extern const color_t difficultyHardColor;
|
||||
extern const color_t flashColor;
|
||||
extern const color_t fadeColor;
|
||||
extern const color_t orangeColor;
|
||||
extern const Color bg_color;
|
||||
extern const Color no_color;
|
||||
extern const Color shdw_txt_color;
|
||||
extern const Color separator_color;
|
||||
extern const Color scoreboard_color;
|
||||
extern const Color difficulty_easy_color;
|
||||
extern const Color difficulty_normal_color;
|
||||
extern const Color difficulty_hard_color;
|
||||
extern const Color flash_color;
|
||||
extern const Color fade_color;
|
||||
extern const Color orange_color;
|
||||
Reference in New Issue
Block a user