Pasaeta de IWYU

This commit is contained in:
2025-03-14 21:22:55 +01:00
parent 3ee47ba906
commit 6c7cfaae59
27 changed files with 350 additions and 408 deletions

View File

@@ -9,9 +9,8 @@
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "stage.h" // Para power #include "stage.h" // Para addPower
#include "texture.h" // Para Texture #include "utils.h" // Para Zone, Color, flash_color
#include "utils.h" // Para Zone, BLOCK, Color, flash_color
// Constructor // Constructor
BalloonManager::BalloonManager() BalloonManager::BalloonManager()

View File

@@ -4,7 +4,6 @@
#include "options.h" // Para OptionsController, Options, options #include "options.h" // Para OptionsController, Options, options
#include "param.h" // Para Param, param, ParamGame, ParamTitle #include "param.h" // Para Param, param, ParamGame, ParamTitle
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "section.h" // Para Name, Options, name, options
#include "text.h" // Para Text #include "text.h" // Para Text
// Constructor // Constructor

View File

@@ -4,10 +4,12 @@
#include <SDL2/SDL_audio.h> // Para AUDIO_S16 #include <SDL2/SDL_audio.h> // Para AUDIO_S16
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_events.h> // Para SDL_DISABLE
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO... #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_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_mouse.h> // Para SDL_ShowCursor
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN #include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_0, SDL_SCANCODE_DOWN
#include <SDL2/SDL_stdinc.h> // Para SDL_bool, Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32, SDL_bool
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO... #include <errno.h> // Para errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // Para printf, perror #include <stdio.h> // Para printf, perror
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU #include <sys/stat.h> // Para mkdir, stat, S_IRWXU
@@ -53,7 +55,7 @@ Director::Director(int argc, const char *argv[])
section::name = section::Name::GAME; section::name = section::Name::GAME;
section::options = section::Options::GAME_PLAY_1P; section::options = section::Options::GAME_PLAY_1P;
#elif DEBUG #elif DEBUG
section::name = section::Name::INTRO; section::name = section::Name::LOGO;
#else // NORMAL GAME #else // NORMAL GAME
section::name = section::Name::LOGO; section::name = section::Name::LOGO;
section::options = section::Options::NONE; section::options = section::Options::NONE;

View File

@@ -1,9 +1,6 @@
#include "enter_name.h" #include "enter_name.h"
#include "utils.h"
#include <stddef.h> // Para size_t #include <stddef.h> // Para size_t
#include <algorithm> // Para max, min #include "utils.h" // Para trim
#include <cassert> // Para assert
#include <iostream>
// Constructor // Constructor
EnterName::EnterName() EnterName::EnterName()

View File

@@ -1,6 +1,6 @@
#include "game.h" #include "game.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_KEYDOWN #include <SDL2/SDL_events.h> // Para SDL_Event, SDL_PollEvent, SDL_KEYDOWN
#include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4 #include <SDL2/SDL_keycode.h> // Para SDLK_1, SDLK_2, SDLK_3, SDLK_4
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
@@ -14,15 +14,14 @@
#include "balloon.h" // Para Balloon, BALLOON_SPEED #include "balloon.h" // Para Balloon, BALLOON_SPEED
#include "balloon_manager.h" // Para BalloonManager #include "balloon_manager.h" // Para BalloonManager
#include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus #include "bullet.h" // Para Bullet, BulletType, BulletMoveStatus
#include "enter_name.h" // Para NAME_LENGHT
#include "fade.h" // Para Fade, FadeType, FadeMode #include "fade.h" // Para Fade, FadeType, FadeMode
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update #include "global_inputs.h" // Para check, update
#include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL... #include "input.h" // Para InputType, Input, INPUT_DO_NOT_ALL...
#include "item.h" // Para Item, ItemType #include "item.h" // Para Item, ItemType
#include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState #include "jail_audio.h" // Para JA_PlaySound, JA_GetMusicState
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry #include "manage_hiscore_table.h" // Para ManageHiScoreTable, HiScoreEntry
#include "global_events.h" // Para handleEvent
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "path_sprite.h" // Para Path, PathSprite, createPath, Path... #include "path_sprite.h" // Para Path, PathSprite, createPath, Path...
@@ -30,10 +29,10 @@
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB... #include "scoreboard.h" // Para Scoreboard, ScoreboardMode, SCOREB...
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, AttractMode, Options #include "section.h" // Para Name, name, AttractMode, attract_mode
#include "smart_sprite.h" // Para SmartSprite #include "smart_sprite.h" // Para SmartSprite
#include "stage.h" // Para number, get, Stage, total_power #include "stage.h" // Para number, get, Stage, total_power
#include "tabe.h" // Para Tabe #include "tabe.h" // Para Tabe, TabeState
#include "text.h" // Para Text #include "text.h" // Para Text
#include "texture.h" // Para Texture #include "texture.h" // Para Texture

View File

@@ -1,6 +1,6 @@
#include "gif.h" #include "gif.h"
#include <stdio.h> // for NULL, fprintf, stderr #include <stdio.h> // Para NULL, fprintf, stderr
#include <stdlib.h> // for malloc, realloc, exit, calloc, free #include <stdlib.h> // Para malloc, realloc, exit, calloc, free
void uncompress(int code_length, void uncompress(int code_length,
const unsigned char *input, const unsigned char *input,
@@ -232,7 +232,8 @@ unsigned char* process_image_descriptor( unsigned char* buffer,
uncompress(lzw_code_size, compressed_data, compressed_data_length, uncompress(lzw_code_size, compressed_data, compressed_data_length,
uncompressed_data); uncompressed_data);
if ( compressed_data ) free( compressed_data ); if (compressed_data)
free(compressed_data);
// if ( uncompressed_data ) // if ( uncompressed_data )
// free( uncompressed_data ); // free( uncompressed_data );
@@ -247,7 +248,8 @@ unsigned char* process_image_descriptor( unsigned char* buffer,
*/ */
#define rb (*(buffer++)) #define rb (*(buffer++))
uint32_t* LoadPalette(unsigned char *buffer) { uint32_t *LoadPalette(unsigned char *buffer)
{
unsigned char header[7]; unsigned char header[7];
screen_descriptor_t screen_descriptor; screen_descriptor_t screen_descriptor;
// int color_resolution_bits; // int color_resolution_bits;
@@ -261,12 +263,14 @@ uint32_t* LoadPalette(unsigned char *buffer) {
// color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1; // color_resolution_bits = ((screen_descriptor.fields & 0x70) >> 4) + 1;
global_color_table = (uint32_t *)calloc(1, 1024); global_color_table = (uint32_t *)calloc(1, 1024);
if (screen_descriptor.fields & 0x80) { if (screen_descriptor.fields & 0x80)
{
global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1)); global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
// global_color_table = (rgb *)malloc(3 * global_color_table_size); // global_color_table = (rgb *)malloc(3 * global_color_table_size);
// READ(global_color_table, 3 * global_color_table_size); // READ(global_color_table, 3 * global_color_table_size);
for (int i=0; i<global_color_table_size;++i) { for (int i = 0; i < global_color_table_size; ++i)
{
global_color_table[i] = (buffer[0] << 16) + (buffer[1] << 8) + buffer[2]; global_color_table[i] = (buffer[0] << 16) + (buffer[1] << 8) + buffer[2];
buffer += 3; buffer += 3;
} }
@@ -315,8 +319,7 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
{ {
// int i; // int i;
// If bit 7 is set, the next block is a global color table; read it // If bit 7 is set, the next block is a global color table; read it
global_color_table_size = 1 << global_color_table_size = 1 << (((screen_descriptor.fields & 0x07) + 1));
( ( ( screen_descriptor.fields & 0x07 ) + 1 ) );
global_color_table = (rgb *)malloc(3 * global_color_table_size); global_color_table = (rgb *)malloc(3 * global_color_table_size);
@@ -341,7 +344,8 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
buffer++; buffer++;
size = *(buffer++); size = *(buffer++);
buffer += size; buffer += size;
do { do
{
size = *(buffer++); size = *(buffer++);
buffer += size; buffer += size;
} while (size != 0); } while (size != 0);
@@ -362,8 +366,8 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
return NULL; return NULL;
} }
unsigned char *LoadGif(unsigned char *buffer, unsigned short *w, unsigned short *h)
unsigned char* LoadGif(unsigned char *buffer, unsigned short* w, unsigned short* h) { {
return process_gif_stream(buffer, w, h); return process_gif_stream(buffer, w, h);
} }

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#include <stdint.h> // for uint32_t #include <stdint.h> // Para uint32_t
#include <string.h> // for memcpy #include <string.h> // Para memcpy
#define EXTENSION_INTRODUCER 0x21 #define EXTENSION_INTRODUCER 0x21
#define IMAGE_DESCRIPTOR 0x2C #define IMAGE_DESCRIPTOR 0x2C
@@ -11,9 +11,12 @@
#define COMMENT_EXTENSION 0xFE #define COMMENT_EXTENSION 0xFE
#define PLAINTEXT_EXTENSION 0x01 #define PLAINTEXT_EXTENSION 0x01
#define READ(dst, size) memcpy(dst, buffer, size); buffer += size #define READ(dst, size) \
memcpy(dst, buffer, size); \
buffer += size
typedef struct { typedef struct
{
unsigned short width; unsigned short width;
unsigned short height; unsigned short height;
unsigned char fields; unsigned char fields;
@@ -21,11 +24,13 @@ typedef struct {
unsigned char pixel_aspect_ratio; unsigned char pixel_aspect_ratio;
} screen_descriptor_t; } screen_descriptor_t;
typedef struct { typedef struct
{
unsigned char r, g, b; unsigned char r, g, b;
} rgb; } rgb;
typedef struct { typedef struct
{
unsigned short image_left_position; unsigned short image_left_position;
unsigned short image_top_position; unsigned short image_top_position;
unsigned short image_width; unsigned short image_width;
@@ -33,29 +38,34 @@ typedef struct {
unsigned char fields; unsigned char fields;
} image_descriptor_t; } image_descriptor_t;
typedef struct { typedef struct
{
unsigned char byte; unsigned char byte;
int prev; int prev;
int len; int len;
} dictionary_entry_t; } dictionary_entry_t;
typedef struct { typedef struct
{
unsigned char extension_code; unsigned char extension_code;
unsigned char block_size; unsigned char block_size;
} extension_t; } extension_t;
typedef struct { typedef struct
{
unsigned char fields; unsigned char fields;
unsigned short delay_time; unsigned short delay_time;
unsigned char transparent_color_index; unsigned char transparent_color_index;
} graphic_control_extension_t; } graphic_control_extension_t;
typedef struct { typedef struct
{
unsigned char application_id[8]; unsigned char application_id[8];
unsigned char version[3]; unsigned char version[3];
} application_extension_t; } application_extension_t;
typedef struct { typedef struct
{
unsigned short left, top, width, height; unsigned short left, top, width, height;
unsigned char cell_width, cell_height; unsigned char cell_width, cell_height;
unsigned char foreground_color, background_color; unsigned char foreground_color, background_color;

View File

@@ -1,8 +1,8 @@
#include "global_events.h" #include "global_events.h"
#include "section.h" #include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include "mouse.h" #include <iostream> // Para char_traits, basic_ostream, operator<<
#include "resource.h" #include "mouse.h" // Para handleEvent
#include <iostream> #include "section.h" // Para Name, Options, name, options
namespace globalEvents namespace globalEvents
{ {
@@ -17,13 +17,11 @@ namespace globalEvents
return; return;
case SDL_RENDER_DEVICE_RESET: case SDL_RENDER_DEVICE_RESET:
case SDL_RENDER_TARGETS_RESET: case SDL_RENDER_TARGETS_RESET:
// Resource::get()->reloadTextures();
std::cout << "SDL_RENDER_TARGETS_RESET" << std::endl; std::cout << "SDL_RENDER_TARGETS_RESET" << std::endl;
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) if (event.window.event == SDL_WINDOWEVENT_SIZE_CHANGED)
{ {
// Resource::get()->reloadTextures();
std::cout << "SDL_WINDOWEVENT_SIZE_CHANGED" << std::endl; std::cout << "SDL_WINDOWEVENT_SIZE_CHANGED" << std::endl;
} }
break; break;

View File

@@ -1,16 +1,18 @@
#include "global_inputs.h" #include "global_inputs.h"
#include <SDL2/SDL_render.h> // Para SDL_RenderSetIntegerScale
#include <SDL2/SDL_stdinc.h> // Para SDL_FALSE, SDL_TRUE
#include <string> // Para operator+, string, to_string, basic_string #include <string> // Para operator+, string, to_string, basic_string
#include <vector> // Para vector #include <vector> // Para vector
#include "asset.h" // Para Asset #include "asset.h" // Para Asset
#include "input.h" // Para Input, InputDeviceToUse, InputType, INPU... #include "input.h" // Para Input, InputDeviceToUse, InputType, INP...
#include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume #include "jail_audio.h" // Para JA_SetMusicVolume, JA_SetSoundVolume
#include "lang.h" // Para Code, getText, change, loadFromFile #include "lang.h" // Para getText, Code, getNextLangCode, loadFro...
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "on_screen_help.h" // Para OnScreenHelp #include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // Para Options, options, OptionsGame, OptionsAudio #include "options.h" // Para Options, options, OptionsGame, OptionsV...
#include "screen.h" // Para Screen, ScreenVideoMode #include "screen.h" // Para Screen, ScreenVideoMode
#include "section.h" // Para Name, Options, name, options #include "section.h" // Para Name, name, Options, options, AttractMode
#include "utils.h" // Para boolToOnOff, stringInVector #include "utils.h" // Para boolToOnOff
namespace globalInputs namespace globalInputs
{ {
@@ -33,7 +35,7 @@ namespace globalInputs
// Si la notificación de salir no está activa, muestra la notificación // Si la notificación de salir no está activa, muestra la notificación
#ifdef ARCADE #ifdef ARCADE
const int INDEX = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94; const int INDEX = code == section::Options::QUIT_WITH_CONTROLLER ? 116 : 94;
Notifier::get()->showText({lang::getText(INDEX), std::string()}, -1, CODE); Notifier::get()->show({lang::getText(INDEX), std::string()}, -1, CODE);
#else #else
Notifier::get()->show({lang::getText(94), std::string()}, -1, CODE); Notifier::get()->show({lang::getText(94), std::string()}, -1, CODE);
#endif #endif

View File

@@ -1,31 +1,29 @@
#include "hiscore_table.h" #include "hiscore_table.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED #include <stdlib.h> // Para rand, size_t
#include <stdlib.h> // Para rand
#include <algorithm> // Para max #include <algorithm> // Para max
#include <functional> // Para function #include <functional> // Para function
#include <vector> // Para vector #include <vector> // Para vector
#include "background.h" // Para Background #include "background.h" // Para Background
#include "fade.h" // Para Fade, FadeMode, FadeType #include "fade.h" // Para Fade, FadeMode, FadeType
#include "global_events.h" // Para check
#include "global_inputs.h" // Para check, update #include "global_inputs.h" // Para check, update
#include "input.h" // Para Input
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para HiScoreEntry #include "manage_hiscore_table.h" // Para HiScoreEntry
#include "global_events.h" // Para handleEvent
#include "options.h" // Para Options, OptionsGame, options #include "options.h" // Para Options, OptionsGame, options
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
#include "path_sprite.h" // Para PathSprite, Path, PathType #include "path_sprite.h" // Para PathSprite, Path, PathType
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options, Attr... #include "section.h" // Para Name, name
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text, TEXT_COLOR, TEXT_SHADOW #include "text.h" // Para Text, TEXT_SHADOW, TEXT_COLOR
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "utils.h" // Para Color, easeOutQuint, fade_color #include "utils.h" // Para Color, easeOutQuint, fade_color, Zone
// Constructor // Constructor
HiScoreTable::HiScoreTable() HiScoreTable::HiScoreTable()

View File

@@ -1,14 +1,14 @@
#include "instructions.h" #include "instructions.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <algorithm> // Para max #include <algorithm> // Para max
#include <utility> // Para move #include <utility> // Para move
#include <vector> // Para vector
#include "fade.h" // Para Fade, FadeMode, FadeType #include "fade.h" // Para Fade, FadeMode, FadeType
#include "global_inputs.h" // Para check #include "global_events.h" // Para check
#include "input.h" // Para Input #include "global_inputs.h" // Para check, update
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state #include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "param.h" // Para Param, param, ParamGame, ParamFade #include "param.h" // Para Param, param, ParamGame, ParamFade
@@ -17,14 +17,8 @@
#include "section.h" // Para Name, name, Options, options #include "section.h" // Para Name, name, Options, options
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_... #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR, TEXT_...
#include "texture.h" // Para Texture
#include "tiled_bg.h" // Para TiledBG, TiledBGMode #include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, shdw_txt_color, Zone, no_color #include "utils.h" // Para Color, shdw_txt_color, Zone, no_color
#include "global_events.h"
#include <SDL2/SDL.h>
#include <vector>
#include <cmath>
// Constructor // Constructor
Instructions::Instructions() Instructions::Instructions()

View File

@@ -1,24 +1,27 @@
#include "intro.h" #include "intro.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND, SDL_BLENDMODE_MOD
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_SetTextureBlendMode, SDL_GetRend...
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED #include <array> // Para array
#include <functional> // Para function
#include <string> // Para basic_string, string
#include <utility> // Para move #include <utility> // Para move
#include "global_inputs.h" // Para check #include "global_events.h" // Para check
#include "input.h" // Para Input #include "global_inputs.h" // Para check, update
#include "jail_audio.h" // Para JA_StopMusic, JA_PlayMusic #include "jail_audio.h" // Para JA_PlayMusic, JA_StopMusic
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "path_sprite.h" // Para PathSprite, PathType
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options #include "section.h" // Para Name, name, Options, options
#include "path_sprite.h" // Para PathSprite
#include "text.h" // Para Text
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "utils.h" // Para Zone, BLOCK, Color, bg_color #include "tiled_bg.h" // Para TiledBG, TiledBGMode
#include "utils.h" // Para Color, Zone, easeOutQuint, BLOCK
#include "writer.h" // Para Writer #include "writer.h" // Para Writer
#include "global_events.h"
#include "tiled_bg.h"
#include <array>
// Constructor // Constructor
Intro::Intro() Intro::Intro()

View File

@@ -1,14 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32, Uint8
#include <SDL2/SDL.h> // Para SDL_Texture #include <memory> // Para unique_ptr
#include <memory> // Para unique_ptr, shared_ptr
#include <vector> // Para vector #include <vector> // Para vector
#include "path_sprite.h" // Para PathSprite #include "path_sprite.h" // Para PathSprite
#include "tiled_bg.h" // Para TiledBG
#include "writer.h" // Para Writer #include "writer.h" // Para Writer
#include "tiled_bg.h"
class Text; // lines 8-8
class Texture; // lines 9-9
/* /*
Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia Esta clase gestiona un estado del programa. Se encarga de mostrar la secuencia

View File

@@ -1,20 +1,17 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event, SDL_QUIT, SDL... #include <SDL2/SDL_events.h> // Para SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <SDL2/SDL_video.h> // Para SDL_WINDOWEVENT_SIZE_CHANGED
#include <utility> // Para move #include <utility> // Para move
#include <iostream> #include "global_events.h" // Para check
#include "global_inputs.h" // Para check #include "global_inputs.h" // Para check, update
#include "input.h" // Para Input #include "jail_audio.h" // Para JA_FadeOutMusic, JA_PlaySound, JA_StopC...
#include "jail_audio.h" // Para JA_StopMusic
#include "param.h" // Para Param, ParamGame, param #include "param.h" // Para Param, ParamGame, param
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "section.h" // Para Name, name, Options, options #include "section.h" // Para Name, name
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
#include "utils.h" // Para Color, Zone #include "utils.h" // Para Color, Zone
#include "global_events.h"
// Constructor // Constructor
Logo::Logo() Logo::Logo()
@@ -114,17 +111,10 @@ void Logo::updateJAILGAMES()
// Comprueba si ha terminado el logo // Comprueba si ha terminado el logo
if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION) if (counter_ == END_LOGO_COUNTER_MARK + POST_LOGO_DURATION)
{
state_ = LogoState::RETROWEEKEND;
ticks_start_ = SDL_GetTicks();
}
}
// Gestiona el logo de RETROWEEKEND
void Logo::updateRETROWEEKEND()
{ {
section::name = section::Name::INTRO; section::name = section::Name::INTRO;
} }
}
// Gestiona el color de las texturas // Gestiona el color de las texturas
void Logo::updateTextureColors() void Logo::updateTextureColors()
@@ -165,20 +155,8 @@ void Logo::update()
// Comprueba las entradas // Comprueba las entradas
checkInput(); checkInput();
switch (state_)
{
case LogoState::JAILGAMES:
updateJAILGAMES(); updateJAILGAMES();
updateTextureColors(); updateTextureColors();
break;
case LogoState::RETROWEEKEND:
updateRETROWEEKEND();
break;
default:
break;
}
// Gestiona el contador // Gestiona el contador
counter_++; counter_++;
@@ -194,18 +172,7 @@ void Logo::render()
Screen::get()->start(); Screen::get()->start();
Screen::get()->clean(); Screen::get()->clean();
switch (state_)
{
case LogoState::JAILGAMES:
renderJAILGAMES(); renderJAILGAMES();
break;
case LogoState::RETROWEEKEND:
break;
default:
break;
}
Screen::get()->render(); Screen::get()->render();
} }

View File

@@ -2,12 +2,11 @@
#include <SDL2/SDL_rect.h> // Para SDL_Point #include <SDL2/SDL_rect.h> // Para SDL_Point
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL.h>
#include <memory> // Para shared_ptr, unique_ptr #include <memory> // Para shared_ptr, unique_ptr
#include <vector> // Para vector #include <vector> // Para vector
class Sprite; class Sprite; // lines 8-8
class Texture; // lines 9-9 class Texture; // lines 9-9
struct Color; struct Color; // lines 10-10
/* /*
Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el Esta clase gestiona un estado del programa. Se encarga de dibujar por pantalla el
@@ -17,31 +16,10 @@ struct Color;
ZX Spectrum ZX Spectrum
*/ */
struct Pixel
{
int x, y; // Coordenadas del píxel
Uint8 r, g, b, a; // Color del píxel
// Método para ascender y desvanecerse
void evaporate()
{
y -= 1; // Asciende hacia arriba
a = (a > 5) ? a - 5 : 0; // Desvanece el alfa (transparencia)
// Añadir movimiento zig-zag aleatorio
x += (rand() % 3 - 1); // Movimiento horizontal aleatorio (-1, 0, 1)
}
};
// Clase Logo // Clase Logo
class Logo class Logo
{ {
private: private:
enum class LogoState
{
JAILGAMES,
RETROWEEKEND,
};
// Constantes // Constantes
static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998" static constexpr int SHOW_SINCE_SPRITE_COUNTER_MARK = 70; // Tiempo del contador en el que empieza a verse el sprite de "SINCE 1998"
static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro static constexpr int INIT_FADE_COUNTER_MARK = 300; // Tiempo del contador cuando inicia el fade a negro
@@ -60,8 +38,6 @@ private:
int counter_ = 0; // Contador int counter_ = 0; // Contador
Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa Uint32 ticks_ = 0; // Contador de ticks para ajustar la velocidad del programa
SDL_Point dest_; // Posición X donde dibujar el logo SDL_Point dest_; // Posición X donde dibujar el logo
LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando
Uint32 ticks_start_ = 0; // Almacena el valor actual de los ticks de SDL
// Actualiza las variables // Actualiza las variables
void update(); void update();
@@ -78,15 +54,9 @@ private:
// Gestiona el logo de JAILGAMES // Gestiona el logo de JAILGAMES
void updateJAILGAMES(); void updateJAILGAMES();
// Gestiona el logo de RETROWEEKEND
void updateRETROWEEKEND();
// Renderiza el logo de JAILGAMES // Renderiza el logo de JAILGAMES
void renderJAILGAMES(); void renderJAILGAMES();
// Renderiza el logo de RETROWEEKEND
void renderRETROWEEKEND();
// Gestiona el color de las texturas // Gestiona el color de las texturas
void updateTextureColors(); void updateTextureColors();

View File

@@ -1,9 +1,10 @@
#include "manage_hiscore_table.h" #include "manage_hiscore_table.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // Para SDL_GetError
#include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile #include <SDL2/SDL_rwops.h> // Para SDL_RWread, SDL_RWwrite, SDL_RWFromFile
#include <algorithm> // Para sort #include <algorithm> // Para find_if, sort
#include <iostream> // Para basic_ostream, operator<<, cout, endl #include <iostream> // Para basic_ostream, operator<<, cout, endl
#include "utils.h" // Para HiScoreEntry, getFileName #include <iterator> // Para distance
#include "utils.h" // Para getFileName
// Resetea la tabla a los valores por defecto // Resetea la tabla a los valores por defecto
void ManageHiScoreTable::clear() void ManageHiScoreTable::clear()

View File

@@ -1,5 +1,4 @@
#include "moving_sprite.h" #include "moving_sprite.h"
#include <algorithm> // Para max
#include "texture.h" // Para Texture #include "texture.h" // Para Texture
// Constructor // Constructor

View File

@@ -1,16 +1,17 @@
#pragma once #pragma once
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO... #include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
#include "input.h" // Para InputType, InputDeviceToUse #include "input.h" // Para InputType, InputDeviceToUse
#include "manage_hiscore_table.h" // Para HiScoreEntry #include "manage_hiscore_table.h" // Para HiScoreEntry
enum class ScreenFilter : int; // lines 10-10 enum class ScreenFilter : int; // lines 8-8
enum class ScreenVideoMode : Uint32; // lines 11-11 enum class ScreenVideoMode : Uint32; // lines 9-9
namespace lang namespace lang
{ {
enum class Code : int; enum class Code : int;
} // lines 14-14 } // lines 12-12
// Dificultad del juego // Dificultad del juego
enum class GameDifficulty enum class GameDifficulty

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_stdinc.h> // Para Uint32
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector
#include "utils.h" // Para Color, Zone #include "utils.h" // Para Color, Zone

View File

@@ -2,14 +2,13 @@
#include <algorithm> // Para find_if #include <algorithm> // Para find_if
#include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr #include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include <utility> // Para pair
#include "asset.h" // Para Asset, AssetType #include "asset.h" // Para Asset, AssetType
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound #include "jail_audio.h" // Para JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "text.h" // Para Text, loadTextFile #include "text.h" // Para Text, loadTextFile
struct JA_Music_t; // lines 10-10 struct JA_Music_t; // lines 11-11
struct JA_Sound_t; // lines 11-11 struct JA_Sound_t; // lines 12-12
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Resource *Resource::resource_ = nullptr; Resource *Resource::resource_ = nullptr;

View File

@@ -5,13 +5,12 @@
#include <math.h> // Para roundf #include <math.h> // Para roundf
#include <iomanip> // Para operator<<, setfill, setw #include <iomanip> // Para operator<<, setfill, setw
#include <sstream> // Para basic_ostream, basic_ostringstream #include <sstream> // Para basic_ostream, basic_ostringstream
#include "enter_name.h" // Para MAX_NAME_LENGHT
#include "lang.h" // Para getText #include "lang.h" // Para getText
#include "resource.h" // Para Resource #include "resource.h" // Para Resource
#include "screen.h" // Para Screen #include "screen.h" // Para Screen
#include "sprite.h" // Para Sprite #include "sprite.h" // Para Sprite
#include "text.h" // Para Text #include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR
#include "enter_name.h" // Para NAME_LENGHT
#include <iostream>
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado // [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
Scoreboard *Scoreboard::scoreboard_ = nullptr; Scoreboard *Scoreboard::scoreboard_ = nullptr;
@@ -297,6 +296,7 @@ void Scoreboard::fillPanelTextures()
// NAME // NAME
text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106)); text_scoreboard_->writeCentered(slot4_3_.x, slot4_3_.y, lang::getText(106));
text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5)); text_scoreboard_->writeDX(TEXT_CENTER | TEXT_COLOR, slot4_4_.x, slot4_4_.y, record_name_[i], 1, getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
// text_scoreboard_->writeColored(enter_name_pos_.x, enter_name_pos_.y, record_name_[i], getColorLikeKnightRider(name_colors_, loop_counter_ / 5));
break; break;
} }
case ScoreboardMode::GAME_COMPLETED: case ScoreboardMode::GAME_COMPLETED:
@@ -439,9 +439,12 @@ void Scoreboard::renderSeparator()
// Inicializa el vector de colores para el nombre // Inicializa el vector de colores para el nombre
void Scoreboard::iniNameColors() void Scoreboard::iniNameColors()
{ {
// Color color = orange_soft_color;
Color color = green_color;
name_colors_.clear(); name_colors_.clear();
name_colors_.emplace_back(green_color.lighten(50)); name_colors_.emplace_back(color.lighten(50));
name_colors_.emplace_back(green_color.lighten(25)); name_colors_.emplace_back(color.lighten(25));
name_colors_.emplace_back(green_color); name_colors_.emplace_back(color);
name_colors_.emplace_back(green_color.darken(25)); name_colors_.emplace_back(color.darken(25));
} }

View File

@@ -1,9 +1,7 @@
#include "screen.h" #include "screen.h"
#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_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <algorithm> // Para clamp, max, min #include <algorithm> // Para max, min
#include <fstream> // Para basic_ifstream, ifstream #include <fstream> // Para basic_ifstream, ifstream
#include <iterator> // Para istreambuf_iterator, operator== #include <iterator> // Para istreambuf_iterator, operator==
#include <string> // Para allocator, operator+, char_traits, to_s... #include <string> // Para allocator, operator+, char_traits, to_s...
@@ -11,11 +9,11 @@
#include "asset.h" // Para Asset #include "asset.h" // Para Asset
#include "dbgtxt.h" // Para dbg_print #include "dbgtxt.h" // Para dbg_print
#include "global_inputs.h" // Para service_pressed_counter #include "global_inputs.h" // Para service_pressed_counter
#include "jail_shader.h" // Para init, render
#include "mouse.h" // Para updateCursorVisibility
#include "notifier.h" // Para Notifier #include "notifier.h" // Para Notifier
#include "on_screen_help.h" // Para OnScreenHelp #include "on_screen_help.h" // Para OnScreenHelp
#include "options.h" // Para Options, OptionsVideo, options, Options... #include "options.h" // Para Options, OptionsVideo, options, Options...
#include "mouse.h"
#include "jail_shader.h" // para init, render
// [SINGLETON] // [SINGLETON]
Screen *Screen::screen_ = nullptr; Screen *Screen::screen_ = nullptr;

View File

@@ -1,6 +1,5 @@
#include "smart_sprite.h" #include "smart_sprite.h"
#include "moving_sprite.h" // Para MovingSprite #include "moving_sprite.h" // Para MovingSprite
class Texture; // lines 2-2
// Actualiza la posición y comprueba si ha llegado a su destino // Actualiza la posición y comprueba si ha llegado a su destino
void SmartSprite::update() void SmartSprite::update()

View File

@@ -1,7 +1,6 @@
// IWYU pragma: no_include <bits/std_abs.h> // IWYU pragma: no_include <bits/std_abs.h>
#include "tabe.h" #include "tabe.h"
#include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE #include <SDL2/SDL_render.h> // Para SDL_FLIP_HORIZONTAL, SDL_FLIP_NONE
#include <SDL2/SDL.h>
#include <stdlib.h> // Para rand, abs #include <stdlib.h> // Para rand, abs
#include <algorithm> // Para max #include <algorithm> // Para max
#include "jail_audio.h" // Para JA_PlaySound #include "jail_audio.h" // Para JA_PlaySound

View File

@@ -1,7 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL.h> #include <SDL2/SDL_stdinc.h> // Para Uint32
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include <stdlib.h> // Para rand
#include <memory> // Para unique_ptr #include <memory> // Para unique_ptr
#include "animated_sprite.h" // Para AnimatedSprite #include "animated_sprite.h" // Para AnimatedSprite

View File

@@ -1,8 +1,9 @@
#include "utils.h" #include "utils.h"
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread #include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWread
#include <stddef.h> // Para size_t
#include <algorithm> // Para min, clamp, find_if_not, find, transform #include <algorithm> // Para min, clamp, find_if_not, find, transform
#include <cctype> // Para tolower, isspace #include <cctype> // Para tolower, isspace
#include <cmath> // Para cos, pow, M_PI #include <cmath> // Para pow, sin, M_PI, cos
#include <compare> // Para operator< #include <compare> // Para operator<
#include <filesystem> // Para path #include <filesystem> // Para path
#include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios #include <iostream> // Para basic_ostream, cout, basic_ios, endl, ios
@@ -254,7 +255,6 @@ double easeInElastic(double t)
return t == 0 ? 0 : (t == 1 ? 1 : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * (2 * M_PI) / 3)); return t == 0 ? 0 : (t == 1 ? 1 : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * (2 * M_PI) / 3));
} }
// Función de suavizado // Función de suavizado
double easeOutBounce(double t) double easeOutBounce(double t)
{ {

View File

@@ -4,6 +4,7 @@
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <SDL2/SDL_stdinc.h> // Para Uint8 #include <SDL2/SDL_stdinc.h> // Para Uint8
#include <stdint.h> // Para int32_t #include <stdint.h> // Para int32_t
#include <algorithm> // Para max, min
#include <string> // Para string #include <string> // Para string
#include <vector> // Para vector #include <vector> // Para vector