forked from jaildesigner-jailgames/jaildoctors_dilemma
v1.09
This commit is contained in:
@@ -277,6 +277,16 @@ void Director::initInput()
|
|||||||
void Director::initJailAudio()
|
void Director::initJailAudio()
|
||||||
{
|
{
|
||||||
JA_Init(48000, AUDIO_S16, 2);
|
JA_Init(48000, AUDIO_S16, 2);
|
||||||
|
if (options.audio.enabled)
|
||||||
|
{
|
||||||
|
JA_SetMusicVolume(options.audio.music.volume);
|
||||||
|
JA_SetSoundVolume(options.audio.sound.volume);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JA_SetMusicVolume(0);
|
||||||
|
JA_SetSoundVolume(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Arranca SDL y crea la ventana
|
// Arranca SDL y crea la ventana
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include "notifier.h"
|
#include "notifier.h"
|
||||||
#include "global_inputs.h"
|
#include "global_inputs.h"
|
||||||
#include "global_events.h"
|
#include "global_events.h"
|
||||||
#include "surface.h"
|
//#include "surface.h"
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Game::Game()
|
Game::Game()
|
||||||
@@ -37,7 +37,7 @@ Game::Game()
|
|||||||
cheevos_(Cheevos::get())
|
cheevos_(Cheevos::get())
|
||||||
{
|
{
|
||||||
// Inicia algunas variables
|
// Inicia algunas variables
|
||||||
test_surface_ = std::make_shared<Surface>(Screen::get()->getSurface(), "test.gif");
|
//test_surface_ = std::make_shared<Surface>(Screen::get()->getSurface(), "test.gif");
|
||||||
board_ = std::make_shared<ScoreboardData>();
|
board_ = std::make_shared<ScoreboardData>();
|
||||||
board_->ini_clock = SDL_GetTicks();
|
board_->ini_clock = SDL_GetTicks();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@@ -262,7 +262,7 @@ void Game::render()
|
|||||||
{
|
{
|
||||||
// Prepara para dibujar el frame
|
// Prepara para dibujar el frame
|
||||||
screen_->start();
|
screen_->start();
|
||||||
test_surface_->render(0, 0, 10, 10, 64, 64);
|
//test_surface_->render(0, 0, 10, 10, 64, 64);
|
||||||
|
|
||||||
// Dibuja los elementos del juego en orden
|
// Dibuja los elementos del juego en orden
|
||||||
room_->renderMap();
|
room_->renderMap();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "player.h" // Para playerSpawn_t
|
#include "player.h" // Para playerSpawn_t
|
||||||
#include "scoreboard.h" // Para board_t
|
#include "scoreboard.h" // Para board_t
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "surface.h"
|
//#include "surface.h"
|
||||||
class Asset;
|
class Asset;
|
||||||
class Cheevos;
|
class Cheevos;
|
||||||
class Debug;
|
class Debug;
|
||||||
@@ -43,7 +43,7 @@ private:
|
|||||||
std::shared_ptr<Scoreboard> scoreboard_; // Objeto encargado de gestionar el marcador
|
std::shared_ptr<Scoreboard> scoreboard_; // Objeto encargado de gestionar el marcador
|
||||||
std::shared_ptr<Stats> stats_; // Objeto encargado de gestionar las estadísticas
|
std::shared_ptr<Stats> stats_; // Objeto encargado de gestionar las estadísticas
|
||||||
SDL_Texture *room_name_texture_; // Textura para escribir el nombre de la habitación
|
SDL_Texture *room_name_texture_; // Textura para escribir el nombre de la habitación
|
||||||
std::shared_ptr<Surface> test_surface_;
|
//std::shared_ptr<Surface> test_surface_;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
JA_Music_t *music_; // Musica que suena durante el juego
|
JA_Music_t *music_; // Musica que suena durante el juego
|
||||||
|
|||||||
@@ -117,8 +117,10 @@ void Notifier::update()
|
|||||||
else if (notifications_[i].state == NotificationStatus::VANISHING)
|
else if (notifications_[i].state == NotificationStatus::VANISHING)
|
||||||
{
|
{
|
||||||
|
|
||||||
const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
//const float step = (notifications_[i].counter / (float)notifications_[i].travel_dist);
|
||||||
const int alpha = 255 * (1 - step);
|
//const int ALPHA = 255 * (1 - step);
|
||||||
|
constexpr int ALPHA = 255;
|
||||||
|
|
||||||
|
|
||||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||||
{
|
{
|
||||||
@@ -128,7 +130,7 @@ void Notifier::update()
|
|||||||
{
|
{
|
||||||
notifications_[i].rect.y++;
|
notifications_[i].rect.y++;
|
||||||
}
|
}
|
||||||
notifications_[i].texture->setAlpha(alpha);
|
notifications_[i].texture->setAlpha(ALPHA);
|
||||||
|
|
||||||
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
if (notifications_[i].rect.y == notifications_[i].y - notifications_[i].travel_dist)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <string> // for string, basic_string
|
#include <string> // for string, basic_string
|
||||||
#include "screen.h" // for ScreenFilter
|
#include "screen.h" // for ScreenFilter
|
||||||
#include "utils.h" // for Color, Palette
|
#include "utils.h" // for Color, Palette
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
// Secciones del programa
|
// Secciones del programa
|
||||||
enum class Section
|
enum class Section
|
||||||
@@ -68,6 +69,12 @@ constexpr bool DEFAULT_VIDEO_KEEP_ASPECT = true;
|
|||||||
constexpr bool DEFAULT_BORDER_ENABLED = true; // Borde activado por defecto
|
constexpr bool DEFAULT_BORDER_ENABLED = true; // Borde activado por defecto
|
||||||
constexpr int DEFAULT_BORDER_WIDTH = 32; // Ancho del borde por defecto
|
constexpr int DEFAULT_BORDER_WIDTH = 32; // Ancho del borde por defecto
|
||||||
constexpr int DEFAULT_BORDER_HEIGHT = 24; // Alto del borde por defecto
|
constexpr int DEFAULT_BORDER_HEIGHT = 24; // Alto del borde por defecto
|
||||||
|
constexpr int DEFAULT_SOUND_VOLUME = 100; // Volumen por defecto de los efectos de sonido
|
||||||
|
constexpr bool DEFAULT_SOUND_ENABLED = true; // Sonido habilitado por defecto
|
||||||
|
constexpr int DEFAULT_MUSIC_VOLUME = 80; // Volumen por defecto de la musica
|
||||||
|
constexpr bool DEFAULT_MUSIC_ENABLED = true; // Musica habilitada por defecto
|
||||||
|
constexpr int DEFAULT_AUDIO_VOLUME = 100; // Volumen por defecto
|
||||||
|
constexpr bool DEFAULT_AUDIO_ENABLED = true; // Audio por defecto
|
||||||
constexpr Palette DEFAULT_PALETTE = Palette::ZXSPECTRUM; // Paleta por defecto
|
constexpr Palette DEFAULT_PALETTE = Palette::ZXSPECTRUM; // Paleta por defecto
|
||||||
constexpr Section DEFAULT_SECTION = Section::LOGO; // Sección por defecto
|
constexpr Section DEFAULT_SECTION = Section::LOGO; // Sección por defecto
|
||||||
constexpr Subsection DEFAULT_SUBSECTION = Subsection::LOGO_TO_INTRO; // Subsección por defecto
|
constexpr Subsection DEFAULT_SUBSECTION = Subsection::LOGO_TO_INTRO; // Subsección por defecto
|
||||||
@@ -283,6 +290,89 @@ struct OptionsVideo
|
|||||||
palette(p) {}
|
palette(p) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Estructura para las opciones de musica
|
||||||
|
struct OptionsMusic
|
||||||
|
{
|
||||||
|
bool enabled; // Indica si la música suena o no
|
||||||
|
int volume; // Volumen al que suena la música (0 a 128 internamente)
|
||||||
|
|
||||||
|
// Constructor por defecto
|
||||||
|
OptionsMusic()
|
||||||
|
: enabled(DEFAULT_MUSIC_ENABLED),
|
||||||
|
volume(convertVolume(DEFAULT_MUSIC_VOLUME)) {} // Usa el método estático para la conversión
|
||||||
|
|
||||||
|
// Constructor con parámetros
|
||||||
|
OptionsMusic(bool e, int v)
|
||||||
|
: enabled(e),
|
||||||
|
volume(convertVolume(v)) {} // Convierte el volumen usando el método estático
|
||||||
|
|
||||||
|
// Método para establecer el volumen
|
||||||
|
void setVolume(int v)
|
||||||
|
{
|
||||||
|
v = std::clamp(v, 0, 100); // Ajusta v al rango [0, 100]
|
||||||
|
volume = convertVolume(v); // Convierte al rango interno
|
||||||
|
}
|
||||||
|
|
||||||
|
// Método estático para convertir de 0-100 a 0-128
|
||||||
|
static int convertVolume(int v)
|
||||||
|
{
|
||||||
|
return (v * 128) / 100;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Estructura para las opciones de sonido
|
||||||
|
struct OptionsSound
|
||||||
|
{
|
||||||
|
bool enabled; // Indica si los sonidos suenan o no
|
||||||
|
int volume; // Volumen al que suenan los sonidos (0 a 128 internamente)
|
||||||
|
|
||||||
|
// Constructor por defecto
|
||||||
|
OptionsSound()
|
||||||
|
: enabled(DEFAULT_SOUND_ENABLED),
|
||||||
|
volume(convertVolume(DEFAULT_SOUND_VOLUME)) {} // Usa el método estático para la conversión
|
||||||
|
|
||||||
|
// Constructor con parámetros
|
||||||
|
OptionsSound(bool e, int v)
|
||||||
|
: enabled(e),
|
||||||
|
volume(convertVolume(v)) {} // También lo integra aquí
|
||||||
|
|
||||||
|
// Método para establecer el volumen
|
||||||
|
void setVolume(int v)
|
||||||
|
{
|
||||||
|
v = std::clamp(v, 0, 100); // Ajusta v al rango [0, 100]
|
||||||
|
volume = convertVolume(v); // Convierte al rango interno
|
||||||
|
}
|
||||||
|
|
||||||
|
// Método estático para convertir de 0-100 a 0-128
|
||||||
|
static int convertVolume(int v)
|
||||||
|
{
|
||||||
|
return (v * 128) / 100;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Estructura para las opciones de audio
|
||||||
|
struct OptionsAudio
|
||||||
|
{
|
||||||
|
OptionsMusic music; // Opciones para la música
|
||||||
|
OptionsSound sound; // Opciones para los efectos de sonido
|
||||||
|
bool enabled; // Indica si el audio está activo o no
|
||||||
|
int volume; // Volumen al que suenan el audio
|
||||||
|
|
||||||
|
// Constructor por defecto
|
||||||
|
OptionsAudio()
|
||||||
|
: music(OptionsMusic()),
|
||||||
|
sound(OptionsSound()),
|
||||||
|
enabled(DEFAULT_AUDIO_ENABLED),
|
||||||
|
volume(DEFAULT_AUDIO_VOLUME) {}
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
OptionsAudio(OptionsMusic m, OptionsSound s, bool e, int v)
|
||||||
|
: music(m),
|
||||||
|
sound(s),
|
||||||
|
enabled(e),
|
||||||
|
volume(v) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Estructura para las opciones de juego
|
// Estructura para las opciones de juego
|
||||||
struct OptionsGame
|
struct OptionsGame
|
||||||
{
|
{
|
||||||
@@ -311,6 +401,7 @@ struct Options
|
|||||||
OptionsStats stats; // Datos con las estadisticas de juego
|
OptionsStats stats; // Datos con las estadisticas de juego
|
||||||
OptionsNotification notifications; // Opciones relativas a las notificaciones;
|
OptionsNotification notifications; // Opciones relativas a las notificaciones;
|
||||||
OptionsWindow window; // Opciones relativas a la ventana
|
OptionsWindow window; // Opciones relativas a la ventana
|
||||||
|
OptionsAudio audio; // Opciones relativas al audio
|
||||||
ControlScheme keys; // Teclas usadas para jugar
|
ControlScheme keys; // Teclas usadas para jugar
|
||||||
SectionState section; // Sección actual del programa
|
SectionState section; // Sección actual del programa
|
||||||
|
|
||||||
@@ -324,11 +415,12 @@ struct Options
|
|||||||
stats(OptionsStats()),
|
stats(OptionsStats()),
|
||||||
notifications(OptionsNotification()),
|
notifications(OptionsNotification()),
|
||||||
window(OptionsWindow()),
|
window(OptionsWindow()),
|
||||||
|
audio(OptionsAudio()),
|
||||||
keys(DEFAULT_CONTROL_SCHEME),
|
keys(DEFAULT_CONTROL_SCHEME),
|
||||||
section(SectionState()) {}
|
section(SectionState()) {}
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Options(std::string cv, bool c, Cheat ch, OptionsGame g, OptionsVideo v, OptionsStats s, OptionsNotification n, OptionsWindow sw, ControlScheme k, SectionState sec)
|
Options(std::string cv, bool c, Cheat ch, OptionsGame g, OptionsVideo v, OptionsStats s, OptionsNotification n, OptionsWindow sw, OptionsAudio a, ControlScheme k, SectionState sec)
|
||||||
: version(cv),
|
: version(cv),
|
||||||
console(c),
|
console(c),
|
||||||
cheats(ch),
|
cheats(ch),
|
||||||
@@ -337,6 +429,7 @@ struct Options
|
|||||||
stats(s),
|
stats(s),
|
||||||
notifications(n),
|
notifications(n),
|
||||||
window(sw),
|
window(sw),
|
||||||
|
audio(a),
|
||||||
keys(k),
|
keys(k),
|
||||||
section(sec) {}
|
section(sec) {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include "notifier.h" // Para Notify
|
#include "notifier.h" // Para Notify
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "surface.h"
|
//#include "surface.h"
|
||||||
|
|
||||||
// [SINGLETON]
|
// [SINGLETON]
|
||||||
Screen *Screen::screen_ = nullptr;
|
Screen *Screen::screen_ = nullptr;
|
||||||
@@ -84,8 +84,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer)
|
|||||||
setBorderColor(border_color_);
|
setBorderColor(border_color_);
|
||||||
|
|
||||||
// Crea la surface donde se pinta el juego
|
// Crea la surface donde se pinta el juego
|
||||||
surface_ = std::make_shared<Surface>(nullptr, options.game.width, options.game.height);
|
//surface_ = std::make_shared<Surface>(nullptr, options.game.width, options.game.height);
|
||||||
surface_->loadPalette(Asset::get()->get("test.gif"));
|
//surface_->loadPalette(Asset::get()->get("test.gif"));
|
||||||
|
|
||||||
// Establece el modo de video
|
// Establece el modo de video
|
||||||
setVideoMode(options.video.mode);
|
setVideoMode(options.video.mode);
|
||||||
@@ -113,7 +113,7 @@ void Screen::clean(Color color)
|
|||||||
// Prepara para empezar a dibujar en la textura de juego
|
// Prepara para empezar a dibujar en la textura de juego
|
||||||
void Screen::start()
|
void Screen::start()
|
||||||
{
|
{
|
||||||
surface_->clear(surface_->getSurface(), surface_->getTransparentColor());
|
//surface_->clear(surface_->getSurface(), surface_->getTransparentColor());
|
||||||
SDL_SetRenderTarget(renderer_, game_texture_);
|
SDL_SetRenderTarget(renderer_, game_texture_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,9 +129,9 @@ void Screen::render()
|
|||||||
// Renderiza sobre gameCanvas los overlays
|
// Renderiza sobre gameCanvas los overlays
|
||||||
renderNotifications();
|
renderNotifications();
|
||||||
|
|
||||||
fillTextureWithColor(renderer_, surface_texture_, 0xFF, 0x00, 0xFF, 0xFF);
|
//fillTextureWithColor(renderer_, surface_texture_, 0xFF, 0x00, 0xFF, 0xFF);
|
||||||
surface_->copyToTexture(renderer_, surface_texture_);
|
//surface_->copyToTexture(renderer_, surface_texture_);
|
||||||
SDL_RenderCopy(renderer_, surface_texture_, nullptr, nullptr);
|
//SDL_RenderCopy(renderer_, surface_texture_, nullptr, nullptr);
|
||||||
|
|
||||||
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
// Si está el borde activo, vuelca gameCanvas sobre borderCanvas
|
||||||
if (options.video.border.enabled)
|
if (options.video.border.enabled)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <vector> // for vector
|
#include <vector> // for vector
|
||||||
#include <memory> // for shared_ptr
|
#include <memory> // for shared_ptr
|
||||||
#include "utils.h" // for Color
|
#include "utils.h" // for Color
|
||||||
#include "surface.h"
|
//#include "surface.h"
|
||||||
|
|
||||||
// Tipos de filtro
|
// Tipos de filtro
|
||||||
enum class ScreenFilter : Uint32
|
enum class ScreenFilter : Uint32
|
||||||
@@ -32,7 +32,7 @@ private:
|
|||||||
SDL_Texture *surface_texture_; // Textura donde se dibuja el juego
|
SDL_Texture *surface_texture_; // Textura donde se dibuja el juego
|
||||||
SDL_Texture *game_texture_; // Textura donde se dibuja el juego
|
SDL_Texture *game_texture_; // Textura donde se dibuja el juego
|
||||||
SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego
|
SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego
|
||||||
std::shared_ptr<Surface> surface_; // Objeto para trabajar con surfaces
|
//std::shared_ptr<Surface> surface_; // Objeto para trabajar con surfaces
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
int window_width_; // Ancho de la pantalla o ventana
|
int window_width_; // Ancho de la pantalla o ventana
|
||||||
@@ -135,7 +135,7 @@ public:
|
|||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
SDL_Renderer *getRenderer() { return renderer_; }
|
SDL_Renderer *getRenderer() { return renderer_; }
|
||||||
std::shared_ptr<SurfaceData> getSurface() { return surface_->getSurface(); }
|
//std::shared_ptr<SurfaceData> getSurface() { return surface_->getSurface(); }
|
||||||
SDL_Texture *getGameTexture() { return game_texture_; };
|
SDL_Texture *getGameTexture() { return game_texture_; };
|
||||||
SDL_Texture *getBorderTexture() { return border_texture_; }
|
SDL_Texture *getBorderTexture() { return border_texture_; }
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user