De moment ja compila i executa, encara que no troba alguns fitxers

This commit is contained in:
2025-02-25 23:03:16 +01:00
parent 32c31a8cb6
commit a07a08adb7
45 changed files with 537 additions and 680 deletions

View File

@@ -1,12 +1,11 @@
#include "cheevos.h" #include "cheevos.h"
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_rwops.h> // Para SDL_RWFromFile, SDL_RWclose, SDL_RWwrite #include <SDL2/SDL_rwops.h> // for SDL_RWFromFile, SDL_RWclose, SDL_RWwrite
#include <stddef.h> // Para NULL #include <stddef.h> // for NULL
#include <iostream> // Para basic_ostream, operator<<, cout, endl #include <fstream> // for basic_ostream, operator<<, basic_ofstream
#include "notifier.h" // Para Screen #include <iostream> // for cout, cerr
#include "utils.h" // Para options_t #include "notifier.h" // for Notifier
#include "options.h" #include "options.h" // for Options, options
#include <fstream> // Para fstream
// [SINGLETON] // [SINGLETON]
Cheevos *Cheevos::cheevos_ = nullptr; Cheevos *Cheevos::cheevos_ = nullptr;

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <string> // Para string
#include <vector> // Para vector #include <string> // for string
class Screen; #include <vector> // for vector
struct Options;
// Struct para los logros // Struct para los logros
struct Achievement struct Achievement

View File

@@ -1,22 +1,22 @@
#include "credits.h" #include "credits.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <algorithm> // Para min #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <iostream> // Para char_traits, basic_ostream, operator<< #include <algorithm> // for min
#include "animated_sprite.h" // Para AnimatedSprite #include <iostream> // for basic_ostream, operator<<, cout, endl
#include "defines.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH #include "animated_sprite.h" // for AnimatedSprite
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "asset.h" // for Asset
#include "resource.h" // Para Resource #include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
#include "screen.h" // Para Screen #include "global_events.h" // for check
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR #include "global_inputs.h" // for check
#include "asset.h" #include "input.h" // for Input
#include "options.h" #include "options.h" // for Options, options, OptionsVideo, Sect...
#include "global_inputs.h" #include "resource.h" // for Resource
#include "global_events.h" #include "screen.h" // for Screen
class Asset; #include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR
// Constructor // Constructor
Credits::Credits() Credits::Credits()

View File

@@ -1,18 +1,17 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_render.h> // for SDL_Texture, SDL_Renderer
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <string> // Para basic_string, string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
#include <memory> // Para shared_ptr #include "utils.h" // for Color
#include "utils.h" // Para color_t class AnimatedSprite; // lines 10-10
class AnimatedSprite; class Asset; // lines 11-11
class Asset; class Input; // lines 12-12
class Input; class Resource; // lines 13-13
class Resource; class Screen; // lines 14-14
class Screen; class Text; // lines 15-15
class Text;
class Credits class Credits
{ {

View File

@@ -1,11 +1,9 @@
#include "debug.h" #include "debug.h"
#include <algorithm> // Para max #include <algorithm> // for max
#include "asset.h" // Para Asset #include "resource.h" // for Resource
#include "text.h" // Para Text #include "screen.h" // for Screen
#include "texture.h" // Para Texture #include "text.h" // for Text
#include "utils.h" #include "utils.h" // for Color
#include "screen.h"
#include "resource.h"
// [SINGLETON] // [SINGLETON]
Debug *Debug::debug_ = nullptr; Debug *Debug::debug_ = nullptr;
@@ -36,7 +34,7 @@ Debug::Debug()
{ {
// Reserva memoria para los punteros // Reserva memoria para los punteros
texture_ = Resource::get()->getTexture("debug.png"); texture_ = Resource::get()->getTexture("debug.png");
text_ = Resource::get()->getText("debug.txt"); text_ = Resource::get()->getText("debug");
} }
// Actualiza las variables // Actualiza las variables

View File

@@ -1,14 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <string> // Para string #include <memory> // for shared_ptr
#include <vector> // Para vector #include <string> // for string
#include <memory> #include <vector> // for vector
class Asset; class Screen; // lines 9-9
class Screen; class Text; // lines 10-10
class Text; class Texture; // lines 11-11
class Texture;
// Clase Debug // Clase Debug
class Debug class Debug

View File

@@ -1,20 +1,21 @@
#include "demo.h" #include "demo.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <iostream> // Para basic_ostream, basic_ios, operator<<, cout #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include "asset.h" // Para Asset #include <iostream> // for basic_ostream, operator<<, cout, endl
#include "defines.h" // Para BLOCK, PLAY_AREA_WIDTH, SECTION_DEMO #include "asset.h" // for Asset
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "debug.h" // for Debug
#include "item_tracker.h" // Para ItemTracker #include "defines.h" // for BLOCK, PLAY_AREA_WIDTH, GAMECANVAS_CENT...
#include "resource.h" // Para Resource #include "global_events.h" // for check
#include "room.h" // Para Room #include "global_inputs.h" // for check
#include "screen.h" // Para Screen #include "input.h" // for Input
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR #include "item_tracker.h" // for ItemTracker
#include "utils.h" // Para color_t, stringToColor, options_t, secti... #include "options.h" // for Options, options, OptionsVideo, Section...
#include "options.h" #include "resource.h" // for Resource
#include "debug.h" #include "room.h" // for Room
#include "global_inputs.h" #include "screen.h" // for Screen
#include "global_events.h" #include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR
#include "utils.h" // for Color, stringToColor, colorAreEqual
// Constructor // Constructor
Demo::Demo() Demo::Demo()
@@ -43,7 +44,7 @@ Demo::Demo()
itemTracker = std::make_shared<ItemTracker>(); itemTracker = std::make_shared<ItemTracker>();
scoreboard = std::make_shared<Scoreboard>(&board); scoreboard = std::make_shared<Scoreboard>(&board);
room = std::make_shared<Room>(resource->getRoom(currentRoom), itemTracker, &board.items, false); room = std::make_shared<Room>(resource->getRoom(currentRoom), itemTracker, &board.items, false);
text = resource->getText("smb2.txt"); text = resource->getText("smb2");
// Inicializa el resto de variables // Inicializa el resto de variables
counter = 0; counter = 0;

View File

@@ -1,23 +1,19 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <string> // Para string, basic_string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
#include <memory> // Para shared_ptr #include "scoreboard.h" // for board_t
#include "scoreboard.h" // Para board_t class Asset; // lines 11-11
#include "room.h" class Debug; // lines 12-12
class Asset; class Input; // lines 13-13
class Debug; class ItemTracker; // lines 14-14
class Input; class Resource; // lines 15-15
class ItemTracker; class Room; // lines 16-16
class Resource; class Screen; // lines 17-17
class Room; class Text; // lines 18-18
class Screen;
class Text;
struct Options;
struct SectionState;
class Demo class Demo
{ {

View File

@@ -1,44 +1,42 @@
#include "director.h" #include "director.h"
#include <SDL2/SDL.h> // Para SDL_Init, SDL_Quit, SDL_INIT_E... #include <SDL2/SDL.h> // for SDL_Init, SDL_Quit, SDL_INIT_EV...
#include <SDL2/SDL_audio.h> // Para AUDIO_S16 #include <SDL2/SDL_audio.h> // for AUDIO_S16
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_gamecontroller.h> // Para SDL_CONTROLLER_BUTTON_B, SDL_C... #include <SDL2/SDL_gamecontroller.h> // for SDL_CONTROLLER_BUTTON_B, SDL_CO...
#include <SDL2/SDL_hints.h> // Para SDL_SetHint, SDL_HINT_RENDER_D... #include <SDL2/SDL_hints.h> // for SDL_SetHint, SDL_HINT_RENDER_DR...
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_A, SDL_SCANCODE_E... #include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_A, SDL_SCANCODE_ES...
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <errno.h> // Para errno, EEXIST, EACCES, ENAMETO... #include <errno.h> // for errno, EEXIST, EACCES, ENAMETOO...
#include <stdio.h> // Para printf, perror #include <stdio.h> // for printf, perror
#include <string.h> // Para strcmp #include <string.h> // for strcmp
#include <sys/stat.h> // Para mkdir, stat, S_IRWXU #include <sys/stat.h> // for mkdir, stat, S_IRWXU
#include <unistd.h> // Para getuid #include <unistd.h> // for getuid
#include <cstdlib> // Para exit, EXIT_FAILURE, srand #include <cstdlib> // for exit, EXIT_FAILURE, srand
#include <fstream> // Para basic_ofstream, basic_ifstream #include <iostream> // for basic_ostream, operator<<, cout
#include <iostream> // Para basic_ostream, operator<<, cout #include <memory> // for make_unique, unique_ptr
#include <string> // Para basic_string, operator+, char_... #include <string> // for operator+, allocator, char_traits
#include <vector> // Para vector #include "asset.h" // for Asset, AssetType
#include <memory> // Para std::make_unique #include "cheevos.h" // for Cheevos
#include "asset.h" // Para Asset, assetType #include "credits.h" // for Credits
#include "defines.h" // Para Section::LOGO, Section::TITLE #include "debug.h" // for Debug
#include "debug.h" // Para Debug #include "defines.h" // for WINDOW_CAPTION, borderColor
#include "credits.h" // Para Credits #include "demo.h" // for Demo
#include "demo.h" // Para Demo #include "ending.h" // for Ending
#include "ending.h" // Para Ending #include "ending2.h" // for Ending2
#include "ending2.h" // Para Ending2 #include "game.h" // for Game
#include "game.h" // Para Game #include "game_over.h" // for GameOver
#include "game_over.h" // Para GameOver #include "input.h" // for Input, inputs_e
#include "loading_screen.h" // Para LoadingScreen #include "jail_audio.h" // for JA_GetMusicState, JA_DeleteMusic
#include "logo.h" // Para Logo #include "loading_screen.h" // for LoadingScreen
#include "title.h" // Para Title #include "logo.h" // for Logo
#include "input.h" // Para Input, inputs_e #include "notifier.h" // for Notifier
#include "jail_audio.h" // Para JA_GetMusicState, JA_DeleteMusic #include "options.h" // for Options, options, Section, Cheat
#include "resource.h" // Para Resource #include "resource.h" // for Resource
#include "screen.h" // Para Screen, FILTER_NEAREST, FILTER... #include "screen.h" // for Screen
#include "utils.h" // Para options_t, section_t, op_notif... #include "title.h" // for Title
#include "notifier.h" #include "utils.h" // for Color
#include "options.h"
#include "cheevos.h"
#ifndef _WIN32 #ifndef _WIN32
#include <pwd.h> #include <pwd.h>

View File

@@ -3,14 +3,7 @@
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_video.h> // for SDL_Window #include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for string #include <string> // for string
class Asset; // lines 6-6 struct JA_Music_t; // lines 11-11
class Debug; // lines 8-8
class Input; // lines 14-14
class Resource; // lines 17-17
class Screen; // lines 18-18
struct JA_Music_t; // lines 20-20
struct Options; // lines 21-21
struct SectionState; // lines 22-22
class Director class Director
{ {

View File

@@ -1,24 +1,25 @@
#include "ending.h" #include "ending.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <algorithm> // Para min #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <iostream> // Para basic_ostream, operator<<, basic_ios #include <algorithm> // for min
#include "asset.h" // Para Asset #include <iostream> // for basic_ostream, operator<<, cout, endl
#include "defines.h" // Para GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH #include "asset.h" // for Asset
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
#include "jail_audio.h" // Para JA_SetVolume, JA_DeleteMusic, JA_Loa... #include "global_events.h" // for check
#include "resource.h" // Para Resource #include "global_inputs.h" // for check
#include "screen.h" // Para Screen #include "input.h" // for Input
#include "sprite.h" // Para Sprite #include "jail_audio.h" // for JA_SetVolume, JA_PlayMusic, JA_StopM...
#include "text.h" // Para Text, TEXT_STROKE #include "options.h" // for Options, options, OptionsVideo, Sect...
#include "texture.h" // Para Texture #include "resource.h" // for Resource
#include "utils.h" // Para color_t, stringToColor, options_t #include "screen.h" // for Screen
#include "options.h" #include "sprite.h" // for Sprite
#include "global_inputs.h" #include "text.h" // for Text, TEXT_STROKE
#include "global_events.h" #include "texture.h" // for Texture
#include "utils.h" // for Color, stringToColor, Palette
// Constructor // Constructor
Ending::Ending() Ending::Ending()
@@ -29,7 +30,7 @@ Ending::Ending()
input(Input::get()) input(Input::get())
{ {
// Reserva memoria para los punteros a objetos // Reserva memoria para los punteros a objetos
text = resource->getText("smb2.txt"); text = resource->getText("smb2");
music = resource->getMusic("ending1.ogg"); music = resource->getMusic("ending1.ogg");
// Inicializa variables // Inicializa variables

View File

@@ -1,21 +1,18 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <string> // Para basic_string, string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
#include <memory> // Para shared_ptr class Asset; // lines 9-9
class Asset; class Input; // lines 10-10
class Input; class Resource; // lines 11-11
class Resource; class Screen; // lines 12-12
class Screen; class Sprite; // lines 13-13
class Sprite; class Text; // lines 14-14
class Text; class Texture; // lines 15-15
class Texture; struct JA_Music_t; // lines 16-16
struct JA_Music_t;
struct Options;
struct SectionState;
class Ending class Ending
{ {

View File

@@ -1,21 +1,23 @@
#include "ending2.h" #include "ending2.h"
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <algorithm> // for max, min, replace #include <algorithm> // for max, min, replace
#include "animated_sprite.h" // for AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_CENTER_X #include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_CENTER_X
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "global_events.h" // for check
#include "jail_audio.h" // for JA_SetVolume, JA_DeleteMusic, JA_Loa... #include "global_inputs.h" // for check
#include "input.h" // for Input
#include "jail_audio.h" // for JA_SetVolume, JA_PlayMusic, JA_StopM...
#include "moving_sprite.h" // for MovingSprite #include "moving_sprite.h" // for MovingSprite
#include "options.h" // for Options, options, OptionsVideo, Sect...
#include "resource.h" // for Resource #include "resource.h" // for Resource
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "text.h" // for Text #include "text.h" // for Text
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for color_t, stringToColor, options_t #include "utils.h" // for Color, stringToColor
#include "options.h"
#include "global_inputs.h"
#include "global_events.h"
// Constructor // Constructor
Ending2::Ending2() Ending2::Ending2()
@@ -26,7 +28,7 @@ Ending2::Ending2()
input(Input::get()) input(Input::get())
{ {
// Reserva memoria para los punteros a objetos // Reserva memoria para los punteros a objetos
text = resource->getText("smb2.txt"); text = resource->getText("smb2");
music = resource->getMusic("ending2.ogg"); music = resource->getMusic("ending2.ogg");
// Inicializa variables // Inicializa variables

View File

@@ -1,11 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <memory> // for shared_ptr
#include <string> // for string #include <string> // for string
#include <vector> // for vector #include <vector> // for vector
#include <memory> // for shared_ptr #include "utils.h" // for Color
class AnimatedSprite; // lines 9-9 class AnimatedSprite; // lines 9-9
class Asset; // lines 10-10 class Asset; // lines 10-10
class Input; // lines 11-11 class Input; // lines 11-11
@@ -14,9 +14,6 @@ class Resource; // lines 13-13
class Screen; // lines 14-14 class Screen; // lines 14-14
class Text; // lines 15-15 class Text; // lines 15-15
struct JA_Music_t; // lines 16-16 struct JA_Music_t; // lines 16-16
struct Color;
struct Options;
struct SectionState;
class Ending2 class Ending2
{ {

View File

@@ -1,11 +1,10 @@
#include "enemy.h" #include "enemy.h"
#include <SDL2/SDL.h> #include <SDL2/SDL_render.h> // for SDL_RendererFlip, SDL_FLIP_NONE, SDL_FL...
#include <stdlib.h> // Para rand #include <stdlib.h> // for rand
#include <algorithm> // Para min #include "animated_sprite.h" // for AnimatedSprite
#include "animated_sprite.h" // Para AnimatedSprite #include "options.h" // for Options, OptionsVideo, options
#include "texture.h" // Para Texture #include "resource.h" // for Resource
#include "resource.h" // Para Resource #include "texture.h" // for Texture
#include "options.h" // Para options
// Constructor // Constructor
Enemy::Enemy(EnemyData enemy) Enemy::Enemy(EnemyData enemy)

View File

@@ -1,11 +1,10 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <memory> // for shared_ptr
#include <string> // Para basic_string, string #include <string> // for string
#include "utils.h" // Para palette_e, color_t #include "utils.h" // for Color
#include <memory> // Para shared_ptr class AnimatedSprite;
#include "animated_sprite.h" // Para AnimatedSprite
// Estructura para pasar los datos de un enemigo // Estructura para pasar los datos de un enemigo
struct EnemyData struct EnemyData

View File

@@ -59,7 +59,7 @@ Game::Game()
const std::string playerANI = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani"; const std::string playerANI = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani";
const player_t player = {spawn_point_, playerPNG, playerANI, room_}; const player_t player = {spawn_point_, playerPNG, playerANI, room_};
player_ = std::make_shared<Player>(player); player_ = std::make_shared<Player>(player);
text_ = resource_->getText("smb2.txt"); text_ = resource_->getText("smb2");
music_ = resource_->getMusic("game.ogg"); music_ = resource_->getMusic("game.ogg");
death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str()); death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str());
stats_ = std::make_shared<Stats>(asset_->get("stats.csv"), asset_->get("stats_buffer.csv")); stats_ = std::make_shared<Stats>(asset_->get("stats.csv"), asset_->get("stats_buffer.csv"));
@@ -155,19 +155,19 @@ void Game::checkEvents()
break; break;
case SDL_SCANCODE_F6: case SDL_SCANCODE_F6:
Notifier::get()->show("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 2); Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS"}, 2);
break; break;
case SDL_SCANCODE_F7: case SDL_SCANCODE_F7:
Notifier::get()->show("ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS", 3); Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", "I LIKE MY MULTICOLOURED FRIENDS"}, 3);
break; break;
case SDL_SCANCODE_F8: case SDL_SCANCODE_F8:
Notifier::get()->show("JAILDESIGNER IS LOGGED IN", "", 4); Notifier::get()->show({"JAILDESIGNER IS LOGGED IN", ""}, 4);
break; break;
case SDL_SCANCODE_F9: case SDL_SCANCODE_F9:
Notifier::get()->show("JAILDESIGNER IS LOGGED IN", "", 5); Notifier::get()->show({"JAILDESIGNER IS LOGGED IN", ""}, 5);
break; break;
default: default:
break; break;

View File

@@ -1,19 +1,20 @@
#include "game_over.h" #include "game_over.h"
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <algorithm> // Para min, max #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <string> // Para basic_string, operator+, to_string, char... #include <algorithm> // for min, max
#include "animated_sprite.h" // Para AnimatedSprite #include <string> // for basic_string, operator+, to_string, cha...
#include "asset.h" // Para Asset #include "animated_sprite.h" // for AnimatedSprite
#include "defines.h" // Para GAMECANVAS_CENTER_X, SECTION_GAME_OVER #include "asset.h" // for Asset
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e #include "defines.h" // for GAMECANVAS_CENTER_X
#include "jail_audio.h" // Para JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic #include "global_events.h" // for check
#include "resource.h" // Para Resource #include "global_inputs.h" // for check
#include "screen.h" // Para Screen #include "input.h" // for Input
#include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR #include "jail_audio.h" // for JA_PlayMusic
#include "texture.h" // Para Texture #include "options.h" // for Options, options, OptionsStats, Section...
#include "options.h" #include "resource.h" // for Resource
#include "global_inputs.h" #include "screen.h" // for Screen
#include "global_events.h" #include "text.h" // for TEXT_CENTER, TEXT_COLOR, Text
#include "texture.h" // for Texture
// Constructor // Constructor
GameOver::GameOver() GameOver::GameOver()
@@ -24,7 +25,7 @@ GameOver::GameOver()
input(Input::get()) input(Input::get())
{ {
// Reserva memoria para los punteros a objetos // Reserva memoria para los punteros a objetos
text = resource->getText("smb2.txt"); text = resource->getText("smb2");
playerSprite = std::make_shared<AnimatedSprite>(resource->getTexture("player_game_over.png"), resource->getAnimation("player_game_over.ani")); playerSprite = std::make_shared<AnimatedSprite>(resource->getTexture("player_game_over.png"), resource->getAnimation("player_game_over.ani"));
tvSprite = std::make_shared<AnimatedSprite>(resource->getTexture("tv.png"), resource->getAnimation("tv.ani")); tvSprite = std::make_shared<AnimatedSprite>(resource->getTexture("tv.png"), resource->getAnimation("tv.ani"));
music = resource->getMusic("game_over.ogg"); music = resource->getMusic("game_over.ogg");

View File

@@ -1,18 +1,17 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <vector> // Para vector #include <vector> // for vector
#include "utils.h" // Para color_t #include "utils.h" // for Color
#include <memory> // Para shared_ptr class AnimatedSprite; // lines 9-9
class AnimatedSprite; class Asset; // lines 10-10
class Asset; class Input; // lines 11-11
class Input; class Resource; // lines 12-12
class Resource; class Screen; // lines 13-13
class Screen; class Text; // lines 14-14
class Text; struct JA_Music_t; // lines 15-15
struct JA_Music_t;
class GameOver class GameOver
{ {

View File

@@ -1,8 +1,11 @@
#include "global_inputs.h" #include "global_inputs.h"
#include "input.h" // Para Input, InputDeviceToUse, InputType, INPU... #include <string> // for basic_string
#include "notifier.h" // Para Notifier #include <vector> // for vector
#include "options.h" // Para Options, options, OptionsGame, OptionsAudio #include "input.h" // for Input, REPEAT_FALSE, inputs_e
#include "screen.h" // Para Screen, ScreenVideoMode #include "notifier.h" // for Notifier
#include "options.h" // for Section, Options, options, SectionState, Optio...
#include "screen.h" // for Screen
#include "utils.h" // for Palette
namespace globalInputs namespace globalInputs
{ {

View File

@@ -1,14 +1,13 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <string> // Para basic_string, string #include <memory> // for shared_ptr, __shared_ptr_access
#include <vector> // Para vector #include <string> // for string
#include "utils.h" // Para color_t #include <vector> // for vector
#include <memory> // Para shared_ptr #include "sprite.h" // for Sprite
#include "sprite.h" #include "texture.h" // for Texture
#include "texture.h" #include "utils.h" // for Color
class Texture;
struct item_t struct item_t
{ {

View File

@@ -2,8 +2,8 @@
#include <SDL2/SDL_audio.h> // for SDL_AudioFormat #include <SDL2/SDL_audio.h> // for SDL_AudioFormat
#include <SDL2/SDL_stdinc.h> // for Uint32, Uint8 #include <SDL2/SDL_stdinc.h> // for Uint32, Uint8
struct JA_Music_t; // lines 8-8 struct JA_Music_t; // lines 5-5
struct JA_Sound_t; // lines 7-7 struct JA_Sound_t; // lines 6-6
enum JA_Channel_state enum JA_Channel_state
{ {

View File

@@ -1,18 +1,19 @@
#include "loading_screen.h" #include "loading_screen.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <stdlib.h> // for rand #include <stdlib.h> // for rand
#include "asset.h" // for Asset #include "asset.h" // for Asset
#include "defines.h" // for SECTION_LOADING_SCREEN, SECTION_QUIT #include "defines.h" // for GAMECANVAS_HEIGHT, GAMECANVAS_WIDTH
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "global_events.h" // for check
#include "jail_audio.h" // for JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic #include "global_inputs.h" // for check
#include "input.h" // for Input
#include "jail_audio.h" // for JA_PlayMusic, JA_SetVolume, JA_StopMusic
#include "options.h" // for Options, options, OptionsVideo, Section...
#include "resource.h" // for Resource #include "resource.h" // for Resource
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for options_t, section_t, color_t, stringToC... #include "utils.h" // for Color, stringToColor, Palette
#include "options.h"
#include "global_inputs.h"
#include "global_events.h"
// Constructor // Constructor
LoadingScreen::LoadingScreen() LoadingScreen::LoadingScreen()
@@ -66,6 +67,12 @@ LoadingScreen::LoadingScreen()
screen_->setBorderColor(stringToColor(options.video.palette, "black")); screen_->setBorderColor(stringToColor(options.video.palette, "black"));
} }
// Destructor
LoadingScreen::~LoadingScreen()
{
JA_StopMusic();
}
// Comprueba el manejador de eventos // Comprueba el manejador de eventos
void LoadingScreen::checkEvents() void LoadingScreen::checkEvents()
{ {
@@ -88,7 +95,7 @@ void LoadingScreen::updateLoad()
// Primera parte de la carga, la parte en blanco y negro // Primera parte de la carga, la parte en blanco y negro
if (loading_first_part_) if (loading_first_part_)
{ {
// Cada 5 pasos el loadCounter se incrementa en uno // Cada 5 pasos el load_counter_ se incrementa en uno
const int numSteps = 5; const int numSteps = 5;
const int step = 51; const int step = 51;
load_counter_ = counter_ / numSteps; load_counter_ = counter_ / numSteps;
@@ -182,18 +189,10 @@ void LoadingScreen::update()
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego // Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - ticks_ > ticks_speed_) if (SDL_GetTicks() - ticks_ > ticks_speed_)
{ {
// Actualiza el contador de ticks
ticks_ = SDL_GetTicks(); ticks_ = SDL_GetTicks();
// Comprueba las entradas
checkInput(); checkInput();
// Gestiona el contador interno
updateCounter(); updateCounter();
// Gestiona el contador de carga
updateLoad(); updateLoad();
screen_->update(); screen_->update();
} }
} }

View File

@@ -1,19 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_render.h> // Para SDL_Renderer #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <memory> // Para shared_ptr class Asset; // lines 8-8
class Asset; class Input; // lines 9-9
class Input; class Resource; // lines 10-10
class Resource; class Screen; // lines 11-11
class Screen; class Sprite; // lines 12-12
class Sprite; class Texture; // lines 13-13
class Texture; struct JA_Music_t; // lines 14-14
struct JA_Music_t;
struct Options;
struct SectionState;
class LoadingScreen class LoadingScreen
{ {
@@ -74,7 +71,7 @@ public:
LoadingScreen(); LoadingScreen();
// Destructor // Destructor
~LoadingScreen() = default; ~LoadingScreen();
// Bucle principal // Bucle principal
void run(); void run();

View File

@@ -1,19 +1,18 @@
#include "logo.h" #include "logo.h"
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event
#include <SDL2/SDL_timer.h> // for SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include <string> // for basic_string, string #include <string> // for basic_string, string
#include "defines.h" // for SECTION_LOGO, SECTION_TITLE, SUBSECTION_... #include "asset.h" // for Asset
#include "input.h" // for Input, REPEAT_FALSE, inputs_e #include "global_events.h" // for check
#include "global_inputs.h" // for check
#include "input.h" // for Input
#include "jail_audio.h" // for JA_StopMusic #include "jail_audio.h" // for JA_StopMusic
#include "options.h" // for Options, options, SectionState, Section
#include "resource.h" // for Resource #include "resource.h" // for Resource
#include "screen.h" // for Screen #include "screen.h" // for Screen
#include "sprite.h" // for Sprite #include "sprite.h" // for Sprite
#include "texture.h" // for Texture #include "texture.h" // for Texture
#include "utils.h" // for color_t, section_t, options_t, stringToC... #include "utils.h" // for Color, stringToColor
#include "asset.h"
#include "options.h"
#include "global_inputs.h"
#include "global_events.h"
class Asset; // lines 11-11
// Constructor // Constructor
Logo::Logo() Logo::Logo()

View File

@@ -1,19 +1,16 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // for SDL_Event
#include <SDL2/SDL_render.h> // for SDL_Renderer #include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_stdinc.h> // for Uint32 #include <SDL2/SDL_stdinc.h> // for Uint32
#include <vector> // for vector
#include <memory> // for shared_ptr #include <memory> // for shared_ptr
#include <vector> // for vector
#include "utils.h" // for Color
class Asset; // lines 8-8 class Asset; // lines 8-8
class Input; // lines 9-9 class Input; // lines 9-9
class Resource; // lines 10-10 class Resource; // lines 10-10
class Screen; // lines 11-11 class Screen; // lines 11-11
class Sprite; // lines 12-12 class Sprite; // lines 12-12
class Texture; // lines 13-13 class Texture; // lines 13-13
struct Color;
struct Options;
struct SectionState;
class Logo class Logo
{ {

View File

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

View File

@@ -1,12 +1,11 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_RendererFlip #include <SDL2/SDL_render.h> // for SDL_RendererFlip, SDL_FLIP_HORIZONTAL
#include <memory> // Para shared_ptr #include <algorithm> // for max
#include "sprite.h" // Para Sprite #include <memory> // for shared_ptr
#include <cmath> #include "sprite.h" // for Sprite
#include <algorithm> class Texture; // lines 9-9
class Texture; // lines 8-8
// Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite // Clase MovingSprite. Añade movimiento y efectos de rotación, zoom y flip al sprite
class MovingSprite : public Sprite class MovingSprite : public Sprite

View File

@@ -1,10 +1,10 @@
#include "options.h" #include "options.h"
#include "defines.h" #include <SDL2/SDL_video.h> // for SDL_WINDOW_FULLSCREEN, SDL_WINDOW_FULLSC...
#include "screen.h" #include <fstream> // for basic_ostream, operator<<, basic_ofstream
#include <fstream> // Para basic_ofstream, basic_ifstream #include <functional> // for function
#include <iostream> // Para basic_ostream, operator<<, cout #include <iostream> // for cout, cerr
#include <unordered_map> // Para unordered_map #include <unordered_map> // for unordered_map, operator==, _Node_const_i...
#include <functional> // Para std::function #include <utility> // for pair
// Variables // Variables
Options options; Options options;

View File

@@ -1,10 +1,9 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint32 #include <string> // for string, basic_string
#include <string> // Para string, basic_string #include "screen.h" // for ScreenFilter
#include "utils.h" #include "utils.h" // for Color, Palette
#include "screen.h"
// Secciones del programa // Secciones del programa
enum class Section enum class Section

View File

@@ -123,8 +123,8 @@ void Player::render()
{ {
// Pinta los underfeet // Pinta los underfeet
SDL_SetRenderDrawColor(renderer_, 255, 0, 255, 255); SDL_SetRenderDrawColor(renderer_, 255, 0, 255, 255);
SDL_RenderDrawPoint(renderer_, underFeet[0].x, underFeet[0].y); SDL_RenderDrawPoint(renderer_, under_feet_[0].x, under_feet_[0].y);
SDL_RenderDrawPoint(renderer_, underFeet[1].x, underFeet[1].y); SDL_RenderDrawPoint(renderer_, under_feet_[1].x, under_feet_[1].y);
// Pinta rectangulo del jugador // Pinta rectangulo del jugador
SDL_SetRenderDrawColor(renderer_, debugColor.r, debugColor.g, debugColor.b, 192); SDL_SetRenderDrawColor(renderer_, debugColor.r, debugColor.g, debugColor.b, 192);
@@ -135,11 +135,11 @@ void Player::render()
// Pinta el rectangulo de movimiento // Pinta el rectangulo de movimiento
SDL_SetRenderDrawColor(renderer_, 255, 0, 0, 255); SDL_SetRenderDrawColor(renderer_, 255, 0, 0, 255);
if (vx != 0.0f) if (vx_ != 0.0f)
{ {
SDL_RenderFillRect(renderer_, &rx); SDL_RenderFillRect(renderer_, &rx);
} }
if (vy != 0.0f) if (vy_ != 0.0f)
{ {
SDL_RenderFillRect(renderer_, &ry); SDL_RenderFillRect(renderer_, &ry);
} }
@@ -177,7 +177,8 @@ void Player::checkInput()
} }
if (!auto_movement_) if (!auto_movement_)
{ // Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica {
// Comprueba las entradas de desplazamiento lateral solo en el caso de no estar enganchado a una superficie automatica
if (input_->checkInput(input_left)) if (input_->checkInput(input_left))
{ {
vx_ = -0.6f; vx_ = -0.6f;
@@ -675,12 +676,12 @@ bool Player::isOnFloor()
if (onSlopeL) if (onSlopeL)
{ {
debug_->add("ON_SLOPE_L: " + std::to_string(underFeet[0].x) + "," + std::to_string(underFeet[0].y)); debug_->add("ON_SLOPE_L: " + std::to_string(under_feet_[0].x) + "," + std::to_string(under_feet_[0].y));
} }
if (onSlopeR) if (onSlopeR)
{ {
debug_->add("ON_SLOPE_R: " + std::to_string(underFeet[1].x) + "," + std::to_string(underFeet[1].y)); debug_->add("ON_SLOPE_R: " + std::to_string(under_feet_[1].x) + "," + std::to_string(under_feet_[1].y));
} }
#endif #endif

View File

@@ -1,12 +1,12 @@
#include "resource.h" #include "resource.h"
#include <algorithm> // Para find_if #include <algorithm> // for find_if
#include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr #include <iostream> // for basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // Para runtime_error #include <stdexcept> // for runtime_error
#include <utility> // Para pair #include "asset.h" // for Asset, AssetType
#include "asset.h" // Para Asset, AssetType #include "jail_audio.h" // for JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound #include "screen.h" // for Screen
#include "screen.h" // Para Screen #include "text.h" // for Text, loadTextFile
#include "text.h" // Para Text, loadTextFile #include "utils.h" // for getFileName, printWithDots
struct JA_Music_t; // lines 10-10 struct JA_Music_t; // lines 10-10
struct JA_Sound_t; // lines 11-11 struct JA_Sound_t; // lines 11-11
@@ -140,7 +140,7 @@ std::shared_ptr<Text> Resource::getText(const std::string &name)
} }
std::cerr << "Error: Text no encontrado " << name << std::endl; std::cerr << "Error: Text no encontrado " << name << std::endl;
throw std::runtime_error("Text no encontrado: " + name); throw std::runtime_error("Texto no encontrado: " + name);
} }
// Obtiene la animación a partir de un nombre // Obtiene la animación a partir de un nombre

View File

@@ -1,15 +1,14 @@
#pragma once #pragma once
#include <memory> // Para shared_ptr #include <memory> // for shared_ptr
#include <string> // Para string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
#include "animated_sprite.h" // Para AnimationsFileBuffer #include "animated_sprite.h" // for AnimationsFileBuffer
#include "text.h" // Para TextFile #include "room.h" // for room_t
#include "texture.h" // Para Texture #include "text.h" // for Text, TextFile
#include "utils.h" // Para DemoData #include "texture.h" // for Texture
#include "room.h" struct JA_Music_t; // lines 11-11
struct JA_Music_t; struct JA_Sound_t; // lines 12-12
struct JA_Sound_t;
// Estructura para almacenar ficheros de sonido y su nombre // Estructura para almacenar ficheros de sonido y su nombre
struct ResourceSound struct ResourceSound

View File

@@ -1,20 +1,20 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <string> // Para string, basic_string #include <memory> // for shared_ptr
#include <vector> // Para vector #include <string> // for string
#include "enemy.h" // Para enemy_t #include <vector> // for vector
#include "item.h" // Para item_t #include "enemy.h" // for EnemyData
#include "utils.h" // Para h_line_t, color_t, d_line_t, v_line_t #include "item.h" // for item_t
#include "item_tracker.h" // Para ItemTracker #include "utils.h" // for Color
#include <memory> // Para shared_ptr class Asset; // lines 12-12
class Asset; class Debug; // lines 13-13
class Debug; class ItemTracker;
class Screen; class Screen; // lines 14-14
class Sprite; class Sprite; // lines 15-15
class Texture; class Texture; // lines 16-16
struct JA_Sound_t; struct JA_Sound_t; // lines 17-17
enum tile_e enum tile_e
{ {

View File

@@ -1,16 +1,14 @@
#include "scoreboard.h" #include "scoreboard.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include "animated_sprite.h" // Para AnimatedSprite #include "animated_sprite.h" // for AnimatedSprite
#include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH #include "asset.h" // for Asset
#include "resource.h" // Para Resource #include "defines.h" // for BLOCK, GAMECANVAS_HEIGHT, PLAY_AREA_HEIGHT
#include "text.h" // Para Text #include "options.h" // for Options, options, OptionsVideo, Cheat
#include "texture.h" // Para Texture #include "resource.h" // for Resource
#include "options.h" #include "screen.h" // for Screen
#include "screen.h" #include "text.h" // for Text
#include "asset.h" #include "texture.h" // for Texture
#include "resource.h"
class Asset;
// Constructor // Constructor
Scoreboard::Scoreboard(board_t *board) Scoreboard::Scoreboard(board_t *board)
@@ -21,11 +19,11 @@ Scoreboard::Scoreboard(board_t *board)
{ {
// Reserva memoria para los objetos // Reserva memoria para los objetos
itemTexture = resource->getTexture("items.png"); itemTexture = resource->getTexture("items.png");
const std::string playerJPG = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.jpg" : "player.jpg"; const std::string playerPNG = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.png" : "player.png";
const std::string playerANI = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani"; const std::string playerANI = options.cheats.alternate_skin == Cheat::CheatState::ENABLED ? "player2.ani" : "player.ani";
sprite = std::make_shared<AnimatedSprite>(resource->getTexture(playerJPG), resource->getAnimation(playerANI)); sprite = std::make_shared<AnimatedSprite>(resource->getTexture(playerPNG), resource->getAnimation(playerANI));
sprite->setCurrentAnimation("walk_menu"); sprite->setCurrentAnimation("walk_menu");
text = resource->getText("smb2.txt"); text = resource->getText("smb2");
// Inicializa las variables // Inicializa las variables
counter = 0; counter = 0;

View File

@@ -1,14 +1,12 @@
#pragma once #pragma once
#include <SDL2/SDL_blendmode.h> // Para SDL_BlendMode #include <SDL2/SDL_blendmode.h> // for SDL_BlendMode
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_video.h> // Para SDL_Window #include <SDL2/SDL_stdinc.h> // for Uint32
#include <string> // Para basic_string, string #include <SDL2/SDL_video.h> // for SDL_Window
#include <vector> // Para vector #include <vector> // for vector
#include "utils.h" // Para color_t #include "utils.h" // for Color
class Asset;
class Notifier;
// Tipos de filtro // Tipos de filtro
enum class ScreenFilter : Uint32 enum class ScreenFilter : Uint32

View File

@@ -1,8 +1,7 @@
#include "stats.h" #include "stats.h"
#include <fstream> // Para basic_ostream, basic_ifstream, basic_istream, ope... #include <fstream> // for basic_ostream, basic_ifstream, basic_istream
#include <sstream> // Para basic_stringstream #include <sstream> // for basic_stringstream
#include "utils.h" // Para op_stats_t, options_t #include "options.h" // for Options, OptionsStats, options
#include "options.h"
// Constructor // Constructor
Stats::Stats(std::string file, std::string buffer) Stats::Stats(std::string file, std::string buffer)

View File

@@ -1,8 +1,7 @@
#pragma once #pragma once
#include <string> // Para string, basic_string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
struct Options;
class Stats class Stats
{ {

View File

@@ -292,6 +292,6 @@ void Text::setPalette(int number)
{ {
auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer()); auto temp = SDL_GetRenderTarget(Screen::get()->getRenderer());
SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr); SDL_SetRenderTarget(Screen::get()->getRenderer(), nullptr);
sprite_->getTexture()->setPalette(number); //sprite_->getTexture()->setPalette(number);
SDL_SetRenderTarget(Screen::get()->getRenderer(), temp); SDL_SetRenderTarget(Screen::get()->getRenderer(), temp);
} }

View File

@@ -7,7 +7,6 @@
#include <stdexcept> // Para runtime_error #include <stdexcept> // Para runtime_error
#include <string> // Para char_traits, operator<<, operator+ #include <string> // Para char_traits, operator<<, operator+
#include <vector> // Para vector #include <vector> // Para vector
#include "gif.c" // Para LoadGif, LoadPalette
#include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_a... #include "stb_image.h" // Para stbi_image_free, stbi_load, STBI_rgb_a...
#include "utils.h" // Para getFileName, printWithDots #include "utils.h" // Para getFileName, printWithDots
@@ -32,7 +31,7 @@ Texture::Texture(SDL_Renderer *renderer, const std::string &path)
} }
// .gif // .gif
else if (extension == "gif") /*else if (extension == "gif")
{ {
// Crea la surface desde un fichero // Crea la surface desde un fichero
surface_ = loadSurface(path_); surface_ = loadSurface(path_);
@@ -45,7 +44,7 @@ Texture::Texture(SDL_Renderer *renderer, const std::string &path)
createBlank(width_, height_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING); createBlank(width_, height_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING);
SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(texture_, SDL_BLENDMODE_BLEND);
flipSurface(); flipSurface();
} }*/
} }
} }
@@ -53,7 +52,7 @@ Texture::Texture(SDL_Renderer *renderer, const std::string &path)
Texture::~Texture() Texture::~Texture()
{ {
unloadTexture(); unloadTexture();
unloadSurface(); //unloadSurface();
palettes_.clear(); palettes_.clear();
} }
@@ -240,15 +239,15 @@ SDL_Texture *Texture::getSDLTexture()
} }
// Desencadenar la superficie actual // Desencadenar la superficie actual
void Texture::unloadSurface() /*void Texture::unloadSurface()
{ {
surface_.reset(); // Resetea el shared_ptr surface_.reset(); // Resetea el shared_ptr
width_ = 0; width_ = 0;
height_ = 0; height_ = 0;
} }*/
// Crea una surface desde un fichero .gif // Crea una surface desde un fichero .gif
std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path) /*std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path)
{ {
// Desencadenar la superficie actual // Desencadenar la superficie actual
unloadSurface(); unloadSurface();
@@ -293,10 +292,10 @@ std::shared_ptr<Surface> Texture::loadSurface(const std::string &file_path)
height_ = h; height_ = h;
return surface; return surface;
} }*/
// Vuelca la surface en la textura // Vuelca la surface en la textura
void Texture::flipSurface() /*void Texture::flipSurface()
{ {
// Limpia la textura // Limpia la textura
auto temp = SDL_GetRenderTarget(renderer_); auto temp = SDL_GetRenderTarget(renderer_);
@@ -314,16 +313,16 @@ void Texture::flipSurface()
pixels[i] = palettes_[current_palette_][surface_->data[i]]; pixels[i] = palettes_[current_palette_][surface_->data[i]];
} }
SDL_UnlockTexture(texture_); SDL_UnlockTexture(texture_);
} }*/
// Establece un color de la paleta // Establece un color de la paleta
void Texture::setPaletteColor(int palette, int index, Uint32 color) /*void Texture::setPaletteColor(int palette, int index, Uint32 color)
{ {
palettes_.at(palette)[index] = color; palettes_.at(palette)[index] = color;
} }*/
// Carga una paleta desde un fichero // Carga una paleta desde un fichero
std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path) /*std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
{ {
std::vector<Uint32> palette; std::vector<Uint32> palette;
@@ -360,10 +359,10 @@ std::vector<Uint32> Texture::loadPaletteFromFile(const std::string &file_path)
} }
return palette; return palette;
} }*/
// Añade una paleta a la lista // Añade una paleta a la lista
void Texture::addPaletteFromFile(const std::string &path) /*void Texture::addPaletteFromFile(const std::string &path)
{ {
palettes_.emplace_back(loadPaletteFromFile(path)); palettes_.emplace_back(loadPaletteFromFile(path));
setPaletteColor((int)palettes_.size() - 1, 0, 0x00000000); setPaletteColor((int)palettes_.size() - 1, 0, 0x00000000);
@@ -377,7 +376,7 @@ void Texture::setPalette(int palette)
current_palette_ = palette; current_palette_ = palette;
flipSurface(); flipSurface();
} }
} }*/
// Obtiene el renderizador // Obtiene el renderizador
SDL_Renderer *Texture::getRenderer() SDL_Renderer *Texture::getRenderer()

View File

@@ -37,19 +37,19 @@ private:
int current_palette_ = 0; // Indice de la paleta en uso int current_palette_ = 0; // Indice de la paleta en uso
// Crea una surface desde un fichero .gif // Crea una surface desde un fichero .gif
std::shared_ptr<Surface> loadSurface(const std::string &file_name); //std::shared_ptr<Surface> loadSurface(const std::string &file_name);
// Vuelca la surface en la textura // Vuelca la surface en la textura
void flipSurface(); //void flipSurface();
// Carga una paleta desde un fichero // Carga una paleta desde un fichero
std::vector<Uint32> loadPaletteFromFile(const std::string &file_name); //std::vector<Uint32> loadPaletteFromFile(const std::string &file_name);
// Libera la memoria de la textura // Libera la memoria de la textura
void unloadTexture(); void unloadTexture();
// Desencadenar la superficie actual // Desencadenar la superficie actual
void unloadSurface(); //void unloadSurface();
public: public:
// Constructor // Constructor
@@ -93,13 +93,13 @@ public:
SDL_Texture *getSDLTexture(); SDL_Texture *getSDLTexture();
// Añade una paleta a la lista // Añade una paleta a la lista
void addPaletteFromFile(const std::string &path); //void addPaletteFromFile(const std::string &path);
// Establece un color de la paleta // Establece un color de la paleta
void setPaletteColor(int palette, int index, Uint32 color); //void setPaletteColor(int palette, int index, Uint32 color);
// Cambia la paleta de la textura // Cambia la paleta de la textura
void setPalette(int palette); //void setPalette(int palette);
// Obtiene el renderizador // Obtiene el renderizador
SDL_Renderer *getRenderer(); SDL_Renderer *getRenderer();

View File

@@ -1,23 +1,24 @@
#include "title.h" #include "title.h"
#include <SDL2/SDL_blendmode.h> // Para SDL_BLENDMODE_BLEND #include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
#include <SDL2/SDL_error.h> // Para SDL_GetError #include <SDL2/SDL_error.h> // for SDL_GetError
#include <SDL2/SDL_pixels.h> // Para SDL_PIXELFORMAT_RGBA8888 #include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_Event, SDL_KEYDOWN
#include <SDL2/SDL_scancode.h> // Para SDL_SCANCODE_1, SDL_SCANCODE_2 #include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks #include <SDL2/SDL_scancode.h> // for SDL_SCANCODE_1, SDL_SCANCODE_2
#include <iostream> // Para basic_ostream, operator<<, basic_ios #include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include "asset.h" // Para Asset #include <iostream> // for basic_ostream, operator<<, cout, endl
#include "cheevos.h" // Para cheevos_t, Cheevos #include "asset.h" // for Asset
#include "defines.h" // Para PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH #include "cheevos.h" // for Achievement, Cheevos
#include "input.h" // Para Input, inputs_e, REPEAT_FALSE, REPEA... #include "defines.h" // for PLAY_AREA_CENTER_X, GAMECANVAS_WIDTH
#include "resource.h" // Para Resource #include "global_events.h" // for check
#include "screen.h" // Para Screen #include "global_inputs.h" // for check
#include "sprite.h" // Para Sprite #include "input.h" // for Input, inputs_e, REPEAT_FALSE, REPEA...
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR #include "options.h" // for Options, options, OptionsVideo, Sect...
#include "texture.h" // Para Texture #include "resource.h" // for Resource
#include "utils.h" // Para color_t, stringToColor, options_t #include "screen.h" // for Screen
#include "options.h" #include "sprite.h" // for Sprite
#include "global_inputs.h" #include "text.h" // for Text, TEXT_CENTER, TEXT_COLOR
#include "global_events.h" #include "texture.h" // for Texture
#include "utils.h" // for Color, stringToColor, Palette
// Constructor // Constructor
Title::Title() Title::Title()
@@ -36,8 +37,8 @@ Title::Title()
texture_ = resource_->getTexture("title_logo.png"); texture_ = resource_->getTexture("title_logo.png");
} }
sprite_ = std::make_shared<Sprite>(texture_, 0, 0, texture_->getWidth(), texture_->getHeight()); sprite_ = std::make_shared<Sprite>(texture_, 0, 0, texture_->getWidth(), texture_->getHeight());
text_ = resource_->getText("smb2.txt"); text_ = resource_->getText("smb2");
info_text_ = resource_->getText("subatomic.txt"); info_text_ = resource_->getText("subatomic");
// Crea la textura para los graficos que aparecen en el fondo de la pantalla de titulo // Crea la textura para los graficos que aparecen en el fondo de la pantalla de titulo
bg_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); bg_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT);

View File

@@ -1,23 +1,18 @@
#pragma once #pragma once
#include <SDL2/SDL_events.h> // Para SDL_Event #include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_rect.h> // Para SDL_Rect #include <SDL2/SDL_render.h> // for SDL_Renderer, SDL_Texture
#include <SDL2/SDL_render.h> // Para SDL_Renderer, SDL_Texture #include <SDL2/SDL_stdinc.h> // for Uint32
#include <SDL2/SDL_stdinc.h> // Para Uint32 #include <memory> // for shared_ptr
#include <string> // Para basic_string, string #include <string> // for string
#include <vector> // Para vector #include <vector> // for vector
#include <memory> #include "paleta.h" // for jSurface
#include "paleta.h" // Para jSurface class Input; // lines 13-13
class Asset; class Resource; // lines 14-14
class Cheevos; class Screen; // lines 15-15
class Input; class Sprite; // lines 16-16
class Resource; class Text; // lines 17-17
class Screen; class Texture; // lines 18-18
class Sprite;
class Text;
class Texture;
struct Options;
struct SectionState;
class Title class Title
{ {

View File

@@ -1,10 +1,13 @@
#include "utils.h" #include "utils.h"
#include <filesystem> // Para path #include <stdlib.h> // for free, malloc, abs
#include <stdlib.h> // Para free, malloc, abs #include <algorithm> // for transform
#include <cmath> // Para round, abs #include <cctype> // for tolower
#include <algorithm> #include <cmath> // for round, abs
#include <iostream> #include <exception> // for exception
#include <cctype> #include <filesystem> // for path
#include <iostream> // for basic_ostream, cout, basic_ios, ios, endl
#include <unordered_map> // for unordered_map
#include <string> // for string
// Calcula el cuadrado de la distancia entre dos puntos // Calcula el cuadrado de la distancia entre dos puntos
double distanceSquared(int x1, int y1, int x2, int y2) double distanceSquared(int x1, int y1, int x2, int y2)
@@ -352,177 +355,75 @@ bool checkCollision(SDL_Point &p, d_line_t &l)
return true; return true;
} }
// Devuelve un color_t a partir de un string // Convierte una cadena a un color
Color stringToColor(Palette pal, std::string str) Color stringToColor(Palette pal, const std::string &str)
{ {
// Mapas de colores para cada paleta
static const std::unordered_map<std::string, Color> zxSpectrumColors = {
{"black", {0x00, 0x00, 0x00}},
{"bright_black", {0x00, 0x00, 0x00}},
{"blue", {0x00, 0x00, 0xD8}},
{"bright_blue", {0x00, 0x00, 0xFF}},
{"red", {0xD8, 0x00, 0x00}},
{"bright_red", {0xFF, 0x00, 0x00}},
{"magenta", {0xD8, 0x00, 0xD8}},
{"bright_magenta", {0xFF, 0x00, 0xFF}},
{"green", {0x00, 0xD8, 0x00}},
{"bright_green", {0x00, 0xFF, 0x00}},
{"cyan", {0x00, 0xD8, 0xD8}},
{"bright_cyan", {0x00, 0xFF, 0xFF}},
{"yellow", {0xD8, 0xD8, 0x00}},
{"bright_yellow", {0xFF, 0xFF, 0x00}},
{"white", {0xD8, 0xD8, 0xD8}},
{"bright_white", {0xFF, 0xFF, 0xFF}}};
static const std::unordered_map<std::string, Color> zxArneColors = {
{"black", {0x00, 0x00, 0x00}},
{"bright_black", {0x3C, 0x35, 0x1F}},
{"blue", {0x31, 0x33, 0x90}},
{"bright_blue", {0x15, 0x59, 0xDB}},
{"red", {0xA7, 0x32, 0x11}},
{"bright_red", {0xD8, 0x55, 0x25}},
{"magenta", {0xA1, 0x55, 0x89}},
{"bright_magenta", {0xCD, 0x7A, 0x50}},
{"green", {0x62, 0x9A, 0x31}},
{"bright_green", {0x9C, 0xD3, 0x3C}},
{"cyan", {0x28, 0xA4, 0xCB}},
{"bright_cyan", {0x65, 0xDC, 0xD6}},
{"yellow", {0xE8, 0xBC, 0x50}},
{"bright_yellow", {0xF1, 0xE7, 0x82}},
{"white", {0xBF, 0xBF, 0xBD}},
{"bright_white", {0xF2, 0xF1, 0xED}}};
// Selecciona el mapa de colores adecuado según la paleta
const std::unordered_map<std::string, Color> *paletteMap = nullptr;
if (pal == Palette::ZXSPECTRUM) if (pal == Palette::ZXSPECTRUM)
{ {
if (str == "black") paletteMap = &zxSpectrumColors;
{
return {0x00, 0x00, 0x00};
} }
else if (str == "bright_black")
{
return {0x00, 0x00, 0x00};
}
else if (str == "blue")
{
return {0x00, 0x00, 0xd8};
}
else if (str == "bright_blue")
{
return {0x00, 0x00, 0xFF};
}
else if (str == "red")
{
return {0xd8, 0x00, 0x00};
}
else if (str == "bright_red")
{
return {0xFF, 0x00, 0x00};
}
else if (str == "magenta")
{
return {0xd8, 0x00, 0xd8};
}
else if (str == "bright_magenta")
{
return {0xFF, 0x00, 0xFF};
}
else if (str == "green")
{
return {0x00, 0xd8, 0x00};
}
else if (str == "bright_green")
{
return {0x00, 0xFF, 0x00};
}
else if (str == "cyan")
{
return {0x00, 0xd8, 0xd8};
}
else if (str == "bright_cyan")
{
return {0x00, 0xFF, 0xFF};
}
else if (str == "yellow")
{
return {0xd8, 0xd8, 0x00};
}
else if (str == "bright_yellow")
{
return {0xFF, 0xFF, 0x00};
}
else if (str == "white")
{
return {0xd8, 0xd8, 0xd8};
}
else if (str == "bright_white")
{
return {0xFF, 0xFF, 0xFF};
}
}
else if (pal == Palette::ZXARNE) else if (pal == Palette::ZXARNE)
{ {
if (str == "black") paletteMap = &zxArneColors;
}
else
{ {
// Paleta desconocida, devolvemos negro por defecto
return {0x00, 0x00, 0x00}; return {0x00, 0x00, 0x00};
} }
else if (str == "bright_black") // Busca el color en el mapa
auto it = paletteMap->find(str);
if (it != paletteMap->end())
{ {
return {0x3C, 0x35, 0x1F}; return it->second;
} }
else
else if (str == "blue")
{ {
return {0x31, 0x33, 0x90}; // Si no se encuentra el color, devolvemos negro por defecto
}
else if (str == "bright_blue")
{
return {0x15, 0x59, 0xDB};
}
else if (str == "red")
{
return {0xA7, 0x32, 0x11};
}
else if (str == "bright_red")
{
return {0xD8, 0x55, 0x25};
}
else if (str == "magenta")
{
return {0xA1, 0x55, 0x89};
}
else if (str == "bright_magenta")
{
return {0xCD, 0x7A, 0x50};
}
else if (str == "green")
{
return {0x62, 0x9A, 0x31};
}
else if (str == "bright_green")
{
return {0x9C, 0xD3, 0x3C};
}
else if (str == "cyan")
{
return {0x28, 0xA4, 0xCB};
}
else if (str == "bright_cyan")
{
return {0x65, 0xDC, 0xD6};
}
else if (str == "yellow")
{
return {0xE8, 0xBC, 0x50};
}
else if (str == "bright_yellow")
{
return {0xF1, 0xE7, 0x82};
}
else if (str == "white")
{
return {0xBF, 0xBF, 0xBD};
}
else if (str == "bright_white")
{
return {0xF2, 0xF1, 0xED};
}
}
return {0x00, 0x00, 0x00}; return {0x00, 0x00, 0x00};
} }
}
// Convierte una cadena a un entero de forma segura // Convierte una cadena a un entero de forma segura
int safeStoi(const std::string &value, int defaultValue) int safeStoi(const std::string &value, int defaultValue)

View File

@@ -1,9 +1,8 @@
#pragma once #pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect, SDL_Point #include <SDL2/SDL_rect.h> // for SDL_Rect, SDL_Point
#include <SDL2/SDL_stdinc.h> // Para Uint8, Uint32 #include <SDL2/SDL_stdinc.h> // for Uint8
#include <string> // Para string, basic_string #include <string> // for string
#include <vector> // Para vector
// Tipos de paleta // Tipos de paleta
enum class Palette : int enum class Palette : int
@@ -95,8 +94,8 @@ bool checkCollision(SDL_Point &p, d_line_t &l);
// Normaliza una linea diagonal // Normaliza una linea diagonal
void normalizeLine(d_line_t &l); void normalizeLine(d_line_t &l);
// Devuelve un color_t a partir de un string // Devuelve un Color a partir de un string
Color stringToColor(Palette pal, std::string str); Color stringToColor(Palette pal, const std::string &str);
// Convierte una cadena a un entero de forma segura // Convierte una cadena a un entero de forma segura
int safeStoi(const std::string &value, int defaultValue = 0); int safeStoi(const std::string &value, int defaultValue = 0);