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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -3,14 +3,7 @@
#include <SDL2/SDL_render.h> // for SDL_Renderer
#include <SDL2/SDL_video.h> // for SDL_Window
#include <string> // for string
class Asset; // lines 6-6
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
struct JA_Music_t; // lines 11-11
class Director
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,10 @@
#pragma once
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_render.h> // Para SDL_Renderer
#include <string> // Para basic_string, string
#include "utils.h" // Para palette_e, color_t
#include <memory> // Para shared_ptr
#include "animated_sprite.h" // Para AnimatedSprite
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <memory> // for shared_ptr
#include <string> // for string
#include "utils.h" // for Color
class AnimatedSprite;
// Estructura para pasar los datos de un enemigo
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 player_t player = {spawn_point_, playerPNG, playerANI, room_};
player_ = std::make_shared<Player>(player);
text_ = resource_->getText("smb2.txt");
text_ = resource_->getText("smb2");
music_ = resource_->getMusic("game.ogg");
death_sound_ = JA_LoadSound(asset_->get("death.wav").c_str());
stats_ = std::make_shared<Stats>(asset_->get("stats.csv"), asset_->get("stats_buffer.csv"));
@@ -155,19 +155,19 @@ void Game::checkEvents()
break;
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;
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;
case SDL_SCANCODE_F8:
Notifier::get()->show("JAILDESIGNER IS LOGGED IN", "", 4);
Notifier::get()->show({"JAILDESIGNER IS LOGGED IN", ""}, 4);
break;
case SDL_SCANCODE_F9:
Notifier::get()->show("JAILDESIGNER IS LOGGED IN", "", 5);
Notifier::get()->show({"JAILDESIGNER IS LOGGED IN", ""}, 5);
break;
default:
break;

View File

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

View File

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

View File

@@ -1,8 +1,11 @@
#include "global_inputs.h"
#include "input.h" // Para Input, InputDeviceToUse, InputType, INPU...
#include "notifier.h" // Para Notifier
#include "options.h" // Para Options, options, OptionsGame, OptionsAudio
#include "screen.h" // Para Screen, ScreenVideoMode
#include <string> // for basic_string
#include <vector> // for vector
#include "input.h" // for Input, REPEAT_FALSE, inputs_e
#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
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -123,8 +123,8 @@ void Player::render()
{
// Pinta los underfeet
SDL_SetRenderDrawColor(renderer_, 255, 0, 255, 255);
SDL_RenderDrawPoint(renderer_, underFeet[0].x, underFeet[0].y);
SDL_RenderDrawPoint(renderer_, underFeet[1].x, underFeet[1].y);
SDL_RenderDrawPoint(renderer_, under_feet_[0].x, under_feet_[0].y);
SDL_RenderDrawPoint(renderer_, under_feet_[1].x, under_feet_[1].y);
// Pinta rectangulo del jugador
SDL_SetRenderDrawColor(renderer_, debugColor.r, debugColor.g, debugColor.b, 192);
@@ -135,11 +135,11 @@ void Player::render()
// Pinta el rectangulo de movimiento
SDL_SetRenderDrawColor(renderer_, 255, 0, 0, 255);
if (vx != 0.0f)
if (vx_ != 0.0f)
{
SDL_RenderFillRect(renderer_, &rx);
}
if (vy != 0.0f)
if (vy_ != 0.0f)
{
SDL_RenderFillRect(renderer_, &ry);
}
@@ -177,7 +177,8 @@ void Player::checkInput()
}
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))
{
vx_ = -0.6f;
@@ -675,12 +676,12 @@ bool Player::isOnFloor()
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)
{
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

View File

@@ -1,12 +1,12 @@
#include "resource.h"
#include <algorithm> // Para find_if
#include <iostream> // Para basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // Para runtime_error
#include <utility> // Para pair
#include "asset.h" // Para Asset, AssetType
#include "jail_audio.h" // Para JA_LoadMusic, JA_LoadSound
#include "screen.h" // Para Screen
#include "text.h" // Para Text, loadTextFile
#include <algorithm> // for find_if
#include <iostream> // for basic_ostream, operator<<, endl, cout, cerr
#include <stdexcept> // for runtime_error
#include "asset.h" // for Asset, AssetType
#include "jail_audio.h" // for JA_DeleteMusic, JA_DeleteSound, JA_LoadMusic
#include "screen.h" // for Screen
#include "text.h" // for Text, loadTextFile
#include "utils.h" // for getFileName, printWithDots
struct JA_Music_t; // lines 10-10
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;
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

View File

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

View File

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

View File

@@ -1,16 +1,14 @@
#include "scoreboard.h"
#include <SDL2/SDL_rect.h> // Para SDL_Rect
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
#include "animated_sprite.h" // Para AnimatedSprite
#include "defines.h" // Para BLOCK, PLAY_AREA_HEIGHT, PLAY_AREA_WIDTH
#include "resource.h" // Para Resource
#include "text.h" // Para Text
#include "texture.h" // Para Texture
#include "options.h"
#include "screen.h"
#include "asset.h"
#include "resource.h"
class Asset;
#include <SDL2/SDL_rect.h> // for SDL_Rect
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
#include "animated_sprite.h" // for AnimatedSprite
#include "asset.h" // for Asset
#include "defines.h" // for BLOCK, GAMECANVAS_HEIGHT, PLAY_AREA_HEIGHT
#include "options.h" // for Options, options, OptionsVideo, Cheat
#include "resource.h" // for Resource
#include "screen.h" // for Screen
#include "text.h" // for Text
#include "texture.h" // for Texture
// Constructor
Scoreboard::Scoreboard(board_t *board)
@@ -21,11 +19,11 @@ Scoreboard::Scoreboard(board_t *board)
{
// Reserva memoria para los objetos
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";
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");
text = resource->getText("smb2.txt");
text = resource->getText("smb2");
// Inicializa las variables
counter = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -37,19 +37,19 @@ private:
int current_palette_ = 0; // Indice de la paleta en uso
// 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
void flipSurface();
//void flipSurface();
// 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
void unloadTexture();
// Desencadenar la superficie actual
void unloadSurface();
//void unloadSurface();
public:
// Constructor
@@ -93,13 +93,13 @@ public:
SDL_Texture *getSDLTexture();
// 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
void setPaletteColor(int palette, int index, Uint32 color);
//void setPaletteColor(int palette, int index, Uint32 color);
// Cambia la paleta de la textura
void setPalette(int palette);
//void setPalette(int palette);
// Obtiene el renderizador
SDL_Renderer *getRenderer();

View File

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

View File

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

View File

@@ -1,10 +1,13 @@
#include "utils.h"
#include <filesystem> // Para path
#include <stdlib.h> // Para free, malloc, abs
#include <cmath> // Para round, abs
#include <algorithm>
#include <iostream>
#include <cctype>
#include <stdlib.h> // for free, malloc, abs
#include <algorithm> // for transform
#include <cctype> // for tolower
#include <cmath> // for round, abs
#include <exception> // for exception
#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
double distanceSquared(int x1, int y1, int x2, int y2)
@@ -352,176 +355,74 @@ bool checkCollision(SDL_Point &p, d_line_t &l)
return true;
}
// Devuelve un color_t a partir de un string
Color stringToColor(Palette pal, std::string str)
// Convierte una cadena a un color
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 (str == "black")
{
return {0x00, 0x00, 0x00};
paletteMap = &zxSpectrumColors;
}
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)
{
if (str == "black")
paletteMap = &zxArneColors;
}
else
{
// Paleta desconocida, devolvemos negro por defecto
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 if (str == "blue")
else
{
return {0x31, 0x33, 0x90};
}
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};
}
}
// Si no se encuentra el color, devolvemos negro por defecto
return {0x00, 0x00, 0x00};
}
}
// Convierte una cadena a un entero de forma segura

View File

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