forked from jaildesigner-jailgames/jaildoctors_dilemma
linter
This commit is contained in:
@@ -36,16 +36,16 @@ void Audio::update() {
|
|||||||
|
|
||||||
// Reproduce la música
|
// Reproduce la música
|
||||||
void Audio::playMusic(const std::string& name, const int loop) {
|
void Audio::playMusic(const std::string& name, const int loop) {
|
||||||
bool newLoop = (loop != 0);
|
bool new_loop = (loop != 0);
|
||||||
|
|
||||||
// Si ya está sonando exactamente la misma pista y mismo modo loop, no hacemos nada
|
// Si ya está sonando exactamente la misma pista y mismo modo loop, no hacemos nada
|
||||||
if (music_.state == MusicState::PLAYING && music_.name == name && music_.loop == newLoop) {
|
if (music_.state == MusicState::PLAYING && music_.name == name && music_.loop == new_loop) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Intentar obtener recurso; si falla, no tocar estado
|
// Intentar obtener recurso; si falla, no tocar estado
|
||||||
auto* resource = Resource::get()->getMusic(name);
|
auto* resource = Resource::get()->getMusic(name);
|
||||||
if (!resource) {
|
if (resource == nullptr) {
|
||||||
// manejo de error opcional
|
// manejo de error opcional
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ void Audio::playMusic(const std::string& name, const int loop) {
|
|||||||
|
|
||||||
// Actualizar estado y metadatos después de iniciar con éxito
|
// Actualizar estado y metadatos después de iniciar con éxito
|
||||||
music_.name = name;
|
music_.name = name;
|
||||||
music_.loop = newLoop;
|
music_.loop = new_loop;
|
||||||
music_.state = MusicState::PLAYING;
|
music_.state = MusicState::PLAYING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -277,7 +277,8 @@ bool Input::checkAxisInput(InputAction input, int controller_index, bool repeat)
|
|||||||
// Transición de inactivo a activo
|
// Transición de inactivo a activo
|
||||||
binding.axis_active = true;
|
binding.axis_active = true;
|
||||||
return true;
|
return true;
|
||||||
} else if (!axis_active_now && binding.axis_active) {
|
}
|
||||||
|
if (!axis_active_now && binding.axis_active) {
|
||||||
// Transición de activo a inactivo
|
// Transición de activo a inactivo
|
||||||
binding.axis_active = false;
|
binding.axis_active = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,17 +76,17 @@ class Gif {
|
|||||||
|
|
||||||
// Carga el stream GIF; devuelve un vector con los datos de imagen sin comprimir y
|
// Carga el stream GIF; devuelve un vector con los datos de imagen sin comprimir y
|
||||||
// asigna el ancho y alto mediante referencias.
|
// asigna el ancho y alto mediante referencias.
|
||||||
std::vector<uint8_t> loadGif(const uint8_t* buffer, uint16_t& w, uint16_t& h);
|
static std::vector<uint8_t> loadGif(const uint8_t* buffer, uint16_t& w, uint16_t& h);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Lee los sub-bloques de datos y los acumula en un std::vector<uint8_t>.
|
// Lee los sub-bloques de datos y los acumula en un std::vector<uint8_t>.
|
||||||
static std::vector<uint8_t> readSubBlocks(const uint8_t*& buffer);
|
static std::vector<uint8_t> readSubBlocks(const uint8_t*& buffer);
|
||||||
|
|
||||||
// Procesa el Image Descriptor y retorna el vector de datos sin comprimir.
|
// Procesa el Image Descriptor y retorna el vector de datos sin comprimir.
|
||||||
std::vector<uint8_t> processImageDescriptor(const uint8_t*& buffer, const std::vector<RGB>& gct, int resolution_bits);
|
static std::vector<uint8_t> processImageDescriptor(const uint8_t*& buffer, const std::vector<RGB>& gct, int resolution_bits);
|
||||||
|
|
||||||
// Procesa el stream completo del GIF y devuelve los datos sin comprimir.
|
// Procesa el stream completo del GIF y devuelve los datos sin comprimir.
|
||||||
std::vector<uint8_t> processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h);
|
static std::vector<uint8_t> processGifStream(const uint8_t* buffer, uint16_t& w, uint16_t& h);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GIF
|
} // namespace GIF
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ void OpenGLShader::render() {
|
|||||||
// Restaurar estados OpenGL
|
// Restaurar estados OpenGL
|
||||||
glUseProgram(old_program);
|
glUseProgram(old_program);
|
||||||
glBindTexture(GL_TEXTURE_2D, old_texture);
|
glBindTexture(GL_TEXTURE_2D, old_texture);
|
||||||
if (was_texture_enabled == 0u) {
|
if (was_texture_enabled == 0U) {
|
||||||
glDisable(GL_TEXTURE_2D);
|
glDisable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
glBindVertexArray(old_vao);
|
glBindVertexArray(old_vao);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ Screen::Screen()
|
|||||||
|
|
||||||
// Crea la textura donde se dibujan los graficos del juego
|
// Crea la textura donde se dibujan los graficos del juego
|
||||||
game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width, Options::game.height);
|
game_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width, Options::game.height);
|
||||||
if (!game_texture_) {
|
if (game_texture_ == nullptr) {
|
||||||
// Registrar el error si está habilitado
|
// Registrar el error si está habilitado
|
||||||
if (Options::console) {
|
if (Options::console) {
|
||||||
std::cerr << "Error: game_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
std::cerr << "Error: game_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
@@ -61,8 +61,8 @@ Screen::Screen()
|
|||||||
SDL_SetTextureScaleMode(game_texture_, SDL_SCALEMODE_NEAREST);
|
SDL_SetTextureScaleMode(game_texture_, SDL_SCALEMODE_NEAREST);
|
||||||
|
|
||||||
// Crea la textura donde se dibuja el borde que rodea el area de juego
|
// Crea la textura donde se dibuja el borde que rodea el area de juego
|
||||||
border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width + Options::video.border.width * 2, Options::game.height + Options::video.border.height * 2);
|
border_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Options::game.width + (Options::video.border.width * 2), Options::game.height + (Options::video.border.height * 2));
|
||||||
if (!border_texture_) {
|
if (border_texture_ == nullptr) {
|
||||||
// Registrar el error si está habilitado
|
// Registrar el error si está habilitado
|
||||||
if (Options::console) {
|
if (Options::console) {
|
||||||
std::cerr << "Error: border_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
std::cerr << "Error: border_texture_ could not be created!\nSDL Error: " << SDL_GetError() << std::endl;
|
||||||
@@ -76,7 +76,7 @@ Screen::Screen()
|
|||||||
game_surface_->clear(static_cast<Uint8>(PaletteColor::BLACK));
|
game_surface_->clear(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
// Crea la surface para el borde de colores
|
// Crea la surface para el borde de colores
|
||||||
border_surface_ = std::make_shared<Surface>(Options::game.width + Options::video.border.width * 2, Options::game.height + Options::video.border.height * 2);
|
border_surface_ = std::make_shared<Surface>(Options::game.width + (Options::video.border.width * 2), Options::game.height + (Options::video.border.height * 2));
|
||||||
border_surface_->setPalette(readPalFile(palettes_.at(current_palette_)));
|
border_surface_->setPalette(readPalFile(palettes_.at(current_palette_)));
|
||||||
border_surface_->clear(border_color_);
|
border_surface_->clear(border_color_);
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ void Screen::toggleVideoMode() {
|
|||||||
|
|
||||||
// Reduce el tamaño de la ventana
|
// Reduce el tamaño de la ventana
|
||||||
bool Screen::decWindowZoom() {
|
bool Screen::decWindowZoom() {
|
||||||
if (Options::video.fullscreen == 0) {
|
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||||
--Options::window.zoom;
|
--Options::window.zoom;
|
||||||
Options::window.zoom = std::max(Options::window.zoom, 1);
|
Options::window.zoom = std::max(Options::window.zoom, 1);
|
||||||
@@ -159,7 +159,7 @@ bool Screen::decWindowZoom() {
|
|||||||
|
|
||||||
// Aumenta el tamaño de la ventana
|
// Aumenta el tamaño de la ventana
|
||||||
bool Screen::incWindowZoom() {
|
bool Screen::incWindowZoom() {
|
||||||
if (Options::video.fullscreen == 0) {
|
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||||
const int PREVIOUS_ZOOM = Options::window.zoom;
|
const int PREVIOUS_ZOOM = Options::window.zoom;
|
||||||
++Options::window.zoom;
|
++Options::window.zoom;
|
||||||
Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom);
|
Options::window.zoom = std::min(Options::window.zoom, Options::window.max_zoom);
|
||||||
@@ -187,7 +187,7 @@ void Screen::toggleBorder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
void Screen::renderNotifications() {
|
void Screen::renderNotifications() const {
|
||||||
if (notifications_enabled_) {
|
if (notifications_enabled_) {
|
||||||
Notifier::get()->render();
|
Notifier::get()->render();
|
||||||
}
|
}
|
||||||
@@ -212,15 +212,17 @@ void Screen::adjustWindowSize() {
|
|||||||
window_height_ = Options::game.height + (Options::video.border.enabled ? Options::video.border.height * 2 : 0);
|
window_height_ = Options::game.height + (Options::video.border.enabled ? Options::video.border.height * 2 : 0);
|
||||||
|
|
||||||
// Establece el nuevo tamaño
|
// Establece el nuevo tamaño
|
||||||
if (Options::video.fullscreen == 0) {
|
if (static_cast<int>(Options::video.fullscreen) == 0) {
|
||||||
int old_width, old_height;
|
int old_width;
|
||||||
|
int old_height;
|
||||||
SDL_GetWindowSize(window_, &old_width, &old_height);
|
SDL_GetWindowSize(window_, &old_width, &old_height);
|
||||||
|
|
||||||
int old_pos_x, old_pos_y;
|
int old_pos_x;
|
||||||
|
int old_pos_y;
|
||||||
SDL_GetWindowPosition(window_, &old_pos_x, &old_pos_y);
|
SDL_GetWindowPosition(window_, &old_pos_x, &old_pos_y);
|
||||||
|
|
||||||
const int NEW_POS_X = old_pos_x + (old_width - (window_width_ * Options::window.zoom)) / 2;
|
const int NEW_POS_X = old_pos_x + ((old_width - (window_width_ * Options::window.zoom)) / 2);
|
||||||
const int NEW_POS_Y = old_pos_y + (old_height - (window_height_ * Options::window.zoom)) / 2;
|
const int NEW_POS_Y = old_pos_y + ((old_height - (window_height_ * Options::window.zoom)) / 2);
|
||||||
|
|
||||||
SDL_SetWindowSize(window_, window_width_ * Options::window.zoom, window_height_ * Options::window.zoom);
|
SDL_SetWindowSize(window_, window_width_ * Options::window.zoom, window_height_ * Options::window.zoom);
|
||||||
SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS), std::max(NEW_POS_Y, 0));
|
SDL_SetWindowPosition(window_, std::max(NEW_POS_X, WINDOWS_DECORATIONS), std::max(NEW_POS_Y, 0));
|
||||||
@@ -327,7 +329,7 @@ size_t Screen::findPalette(const std::string& name) {
|
|||||||
|
|
||||||
// Muestra información por pantalla
|
// Muestra información por pantalla
|
||||||
void Screen::renderInfo() {
|
void Screen::renderInfo() {
|
||||||
if (show_debug_info_ && Resource::get()) {
|
if (show_debug_info_ && (Resource::get() != nullptr)) {
|
||||||
auto text = Resource::get()->getText("smb2");
|
auto text = Resource::get()->getText("smb2");
|
||||||
auto color = static_cast<Uint8>(PaletteColor::YELLOW);
|
auto color = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||||
|
|
||||||
@@ -382,11 +384,11 @@ std::vector<uint8_t> loadData(const std::string& filepath) {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize fileSize = file.tellg();
|
std::streamsize file_size = file.tellg();
|
||||||
file.seekg(0, std::ios::beg);
|
file.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
std::vector<uint8_t> data(fileSize);
|
std::vector<uint8_t> data(file_size);
|
||||||
if (!file.read(reinterpret_cast<char*>(data.data()), fileSize)) {
|
if (!file.read(reinterpret_cast<char*>(data.data()), file_size)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,13 +400,13 @@ void Screen::loadShaders() {
|
|||||||
if (vertex_shader_source_.empty()) {
|
if (vertex_shader_source_.empty()) {
|
||||||
// Detectar si necesitamos OpenGL ES (Raspberry Pi)
|
// Detectar si necesitamos OpenGL ES (Raspberry Pi)
|
||||||
// Intentar cargar versión ES primero si existe
|
// Intentar cargar versión ES primero si existe
|
||||||
std::string VERTEX_FILE = "crtpi_vertex_es.glsl";
|
std::string vertex_file = "crtpi_vertex_es.glsl";
|
||||||
auto data = loadData(Asset::get()->get(VERTEX_FILE));
|
auto data = loadData(Asset::get()->get(vertex_file));
|
||||||
|
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
// Si no existe versión ES, usar versión Desktop
|
// Si no existe versión ES, usar versión Desktop
|
||||||
VERTEX_FILE = "crtpi_vertex.glsl";
|
vertex_file = "crtpi_vertex.glsl";
|
||||||
data = loadData(Asset::get()->get(VERTEX_FILE));
|
data = loadData(Asset::get()->get(vertex_file));
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Usando shaders OpenGL Desktop 3.3");
|
"Usando shaders OpenGL Desktop 3.3");
|
||||||
} else {
|
} else {
|
||||||
@@ -418,13 +420,13 @@ void Screen::loadShaders() {
|
|||||||
}
|
}
|
||||||
if (fragment_shader_source_.empty()) {
|
if (fragment_shader_source_.empty()) {
|
||||||
// Intentar cargar versión ES primero si existe
|
// Intentar cargar versión ES primero si existe
|
||||||
std::string FRAGMENT_FILE = "crtpi_fragment_es.glsl";
|
std::string fragment_file = "crtpi_fragment_es.glsl";
|
||||||
auto data = loadData(Asset::get()->get(FRAGMENT_FILE));
|
auto data = loadData(Asset::get()->get(fragment_file));
|
||||||
|
|
||||||
if (data.empty()) {
|
if (data.empty()) {
|
||||||
// Si no existe versión ES, usar versión Desktop
|
// Si no existe versión ES, usar versión Desktop
|
||||||
FRAGMENT_FILE = "crtpi_fragment.glsl";
|
fragment_file = "crtpi_fragment.glsl";
|
||||||
data = loadData(Asset::get()->get(FRAGMENT_FILE));
|
data = loadData(Asset::get()->get(fragment_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!data.empty()) {
|
if (!data.empty()) {
|
||||||
@@ -536,8 +538,8 @@ auto Screen::initSDLVideo() -> bool {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Crear ventana
|
// Crear ventana
|
||||||
const auto WINDOW_WIDTH = Options::video.border.enabled ? Options::game.width + Options::video.border.width * 2 : Options::game.width;
|
const auto WINDOW_WIDTH = Options::video.border.enabled ? Options::game.width + (Options::video.border.width * 2) : Options::game.width;
|
||||||
const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + Options::video.border.height * 2 : Options::game.height;
|
const auto WINDOW_HEIGHT = Options::video.border.enabled ? Options::game.height + (Options::video.border.height * 2) : Options::game.height;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
SDL_WindowFlags window_flags = SDL_WINDOW_METAL;
|
SDL_WindowFlags window_flags = SDL_WINDOW_METAL;
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class Screen {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Dibuja las notificaciones
|
// Dibuja las notificaciones
|
||||||
void renderNotifications();
|
void renderNotifications() const;
|
||||||
|
|
||||||
// Calcula el tamaño de la ventana
|
// Calcula el tamaño de la ventana
|
||||||
void adjustWindowSize();
|
void adjustWindowSize();
|
||||||
@@ -172,13 +172,13 @@ class Screen {
|
|||||||
void setBorderColor(Uint8 color);
|
void setBorderColor(Uint8 color);
|
||||||
|
|
||||||
// Establece el tamaño del borde
|
// Establece el tamaño del borde
|
||||||
void setBorderWidth(int width);
|
static void setBorderWidth(int width);
|
||||||
|
|
||||||
// Establece el tamaño del borde
|
// Establece el tamaño del borde
|
||||||
void setBorderHeight(int height);
|
static void setBorderHeight(int height);
|
||||||
|
|
||||||
// Establece si se ha de ver el borde en el modo ventana
|
// Establece si se ha de ver el borde en el modo ventana
|
||||||
void setBorderEnabled(bool value);
|
static void setBorderEnabled(bool value);
|
||||||
|
|
||||||
// Cambia entre borde visible y no visible
|
// Cambia entre borde visible y no visible
|
||||||
void toggleBorder();
|
void toggleBorder();
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ Palette loadPalette(const std::string& file_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cargar la paleta usando los datos del buffer
|
// Cargar la paleta usando los datos del buffer
|
||||||
GIF::Gif gif;
|
std::vector<uint32_t> pal = GIF::Gif::loadPalette(buffer.data());
|
||||||
std::vector<uint32_t> pal = gif.loadPalette(buffer.data());
|
|
||||||
if (pal.empty()) {
|
if (pal.empty()) {
|
||||||
throw std::runtime_error("No palette found in GIF file: " + file_path);
|
throw std::runtime_error("No palette found in GIF file: " + file_path);
|
||||||
}
|
}
|
||||||
@@ -435,7 +434,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture) {
|
|||||||
throw std::runtime_error("Renderer or texture is null.");
|
throw std::runtime_error("Renderer or texture is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data.get() == nullptr)) {
|
if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data == nullptr)) {
|
||||||
throw std::runtime_error("Invalid surface dimensions or data.");
|
throw std::runtime_error("Invalid surface dimensions or data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,7 +473,7 @@ void Surface::copyToTexture(SDL_Renderer* renderer, SDL_Texture* texture, SDL_FR
|
|||||||
throw std::runtime_error("Renderer or texture is null.");
|
throw std::runtime_error("Renderer or texture is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data.get() == nullptr)) {
|
if (surface_data_->width <= 0 || surface_data_->height <= 0 || (surface_data_->data == nullptr)) {
|
||||||
throw std::runtime_error("Invalid surface dimensions or data.");
|
throw std::runtime_error("Invalid surface dimensions or data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,16 +18,16 @@ struct JA_Music_t; // lines 17-17
|
|||||||
struct JA_Sound_t; // lines 18-18
|
struct JA_Sound_t; // lines 18-18
|
||||||
|
|
||||||
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
// [SINGLETON] Hay que definir las variables estáticas, desde el .h sólo la hemos declarado
|
||||||
Resource* Resource::resource_ = nullptr;
|
Resource* Resource::resource = nullptr;
|
||||||
|
|
||||||
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
// [SINGLETON] Crearemos el objeto screen con esta función estática
|
||||||
void Resource::init() { Resource::resource_ = new Resource(); }
|
void Resource::init() { Resource::resource = new Resource(); }
|
||||||
|
|
||||||
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
// [SINGLETON] Destruiremos el objeto screen con esta función estática
|
||||||
void Resource::destroy() { delete Resource::resource_; }
|
void Resource::destroy() { delete Resource::resource; }
|
||||||
|
|
||||||
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
|
// [SINGLETON] Con este método obtenemos el objeto screen y podemos trabajar con él
|
||||||
Resource* Resource::get() { return Resource::resource_; }
|
Resource* Resource::get() { return Resource::resource; }
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
Resource::Resource() { load(); }
|
Resource::Resource() { load(); }
|
||||||
@@ -155,7 +155,7 @@ std::vector<int>& Resource::getTileMap(const std::string& name) {
|
|||||||
auto it = std::find_if(tile_maps_.begin(), tile_maps_.end(), [&name](const auto& t) { return t.name == name; });
|
auto it = std::find_if(tile_maps_.begin(), tile_maps_.end(), [&name](const auto& t) { return t.name == name; });
|
||||||
|
|
||||||
if (it != tile_maps_.end()) {
|
if (it != tile_maps_.end()) {
|
||||||
return it->tileMap;
|
return it->tile_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cerr << "Error: Mapa de tiles no encontrado " << name << std::endl;
|
std::cerr << "Error: Mapa de tiles no encontrado " << name << std::endl;
|
||||||
@@ -300,14 +300,14 @@ void Resource::loadRooms() {
|
|||||||
void Resource::createText() {
|
void Resource::createText() {
|
||||||
struct ResourceInfo {
|
struct ResourceInfo {
|
||||||
std::string key; // Identificador del recurso
|
std::string key; // Identificador del recurso
|
||||||
std::string textureFile; // Nombre del archivo de textura
|
std::string texture_file; // Nombre del archivo de textura
|
||||||
std::string textFile; // Nombre del archivo de texto
|
std::string text_file; // Nombre del archivo de texto
|
||||||
|
|
||||||
// Constructor para facilitar la creación de objetos ResourceInfo
|
// Constructor para facilitar la creación de objetos ResourceInfo
|
||||||
ResourceInfo(const std::string& k, const std::string& tFile, const std::string& txtFile)
|
ResourceInfo(const std::string& k, const std::string& t_file, const std::string& txt_file)
|
||||||
: key(k),
|
: key(k),
|
||||||
textureFile(tFile),
|
texture_file(t_file),
|
||||||
textFile(txtFile) {}
|
text_file(txt_file) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::cout << "\n>> CREATING TEXT_OBJECTS" << std::endl;
|
std::cout << "\n>> CREATING TEXT_OBJECTS" << std::endl;
|
||||||
@@ -320,7 +320,7 @@ void Resource::createText() {
|
|||||||
{"8bithud", "8bithud.gif", "8bithud.txt"}};
|
{"8bithud", "8bithud.gif", "8bithud.txt"}};
|
||||||
|
|
||||||
for (const auto& resource : resources) {
|
for (const auto& resource : resources) {
|
||||||
texts_.emplace_back(ResourceText(resource.key, std::make_shared<Text>(getSurface(resource.textureFile), getTextFile(resource.textFile))));
|
texts_.emplace_back(ResourceText(resource.key, std::make_shared<Text>(getSurface(resource.texture_file), getTextFile(resource.text_file))));
|
||||||
printWithDots("Text : ", resource.key, "[ DONE ]");
|
printWithDots("Text : ", resource.key, "[ DONE ]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +329,7 @@ void Resource::createText() {
|
|||||||
void Resource::clearSounds() {
|
void Resource::clearSounds() {
|
||||||
// Itera sobre el vector y libera los recursos asociados a cada JA_Sound_t
|
// Itera sobre el vector y libera los recursos asociados a cada JA_Sound_t
|
||||||
for (auto& sound : sounds_) {
|
for (auto& sound : sounds_) {
|
||||||
if (sound.sound) {
|
if (sound.sound != nullptr) {
|
||||||
JA_DeleteSound(sound.sound);
|
JA_DeleteSound(sound.sound);
|
||||||
sound.sound = nullptr;
|
sound.sound = nullptr;
|
||||||
}
|
}
|
||||||
@@ -341,7 +341,7 @@ void Resource::clearSounds() {
|
|||||||
void Resource::clearMusics() {
|
void Resource::clearMusics() {
|
||||||
// Itera sobre el vector y libera los recursos asociados a cada JA_Music_t
|
// Itera sobre el vector y libera los recursos asociados a cada JA_Music_t
|
||||||
for (auto& music : musics_) {
|
for (auto& music : musics_) {
|
||||||
if (music.music) {
|
if (music.music != nullptr) {
|
||||||
JA_DeleteMusic(music.music);
|
JA_DeleteMusic(music.music);
|
||||||
music.music = nullptr;
|
music.music = nullptr;
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ void Resource::clearMusics() {
|
|||||||
|
|
||||||
// Calcula el numero de recursos para cargar
|
// Calcula el numero de recursos para cargar
|
||||||
void Resource::calculateTotal() {
|
void Resource::calculateTotal() {
|
||||||
std::vector<AssetType> assetTypes = {
|
std::vector<AssetType> asset_types = {
|
||||||
AssetType::SOUND,
|
AssetType::SOUND,
|
||||||
AssetType::MUSIC,
|
AssetType::MUSIC,
|
||||||
AssetType::BITMAP,
|
AssetType::BITMAP,
|
||||||
@@ -362,8 +362,8 @@ void Resource::calculateTotal() {
|
|||||||
AssetType::ROOM};
|
AssetType::ROOM};
|
||||||
|
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
for (const auto& assetType : assetTypes) {
|
for (const auto& asset_type : asset_types) {
|
||||||
auto list = Asset::get()->getListByType(assetType);
|
auto list = Asset::get()->getListByType(asset_type);
|
||||||
total += list.size();
|
total += list.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,17 +375,17 @@ void Resource::renderProgress() {
|
|||||||
constexpr float X_PADDING = 10;
|
constexpr float X_PADDING = 10;
|
||||||
constexpr float Y_PADDING = 10;
|
constexpr float Y_PADDING = 10;
|
||||||
constexpr float BAR_HEIGHT = 10;
|
constexpr float BAR_HEIGHT = 10;
|
||||||
const float bar_position = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
const float BAR_POSITION = Options::game.height - BAR_HEIGHT - Y_PADDING;
|
||||||
Screen::get()->start();
|
Screen::get()->start();
|
||||||
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
Screen::get()->clearSurface(static_cast<Uint8>(PaletteColor::BLACK));
|
||||||
|
|
||||||
auto surface = Screen::get()->getRendererSurface();
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
const float WIRED_BAR_WIDTH = Options::game.width - (X_PADDING * 2);
|
const float WIRED_BAR_WIDTH = Options::game.width - (X_PADDING * 2);
|
||||||
SDL_FRect rect_wired = {X_PADDING, bar_position, WIRED_BAR_WIDTH, X_PADDING};
|
SDL_FRect rect_wired = {X_PADDING, BAR_POSITION, WIRED_BAR_WIDTH, X_PADDING};
|
||||||
surface->drawRectBorder(&rect_wired, static_cast<Uint8>(PaletteColor::WHITE));
|
surface->drawRectBorder(&rect_wired, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
|
|
||||||
const float FULL_BAR_WIDTH = WIRED_BAR_WIDTH * count_.getPercentage();
|
const float FULL_BAR_WIDTH = WIRED_BAR_WIDTH * count_.getPercentage();
|
||||||
SDL_FRect rect_full = {X_PADDING, bar_position, FULL_BAR_WIDTH, X_PADDING};
|
SDL_FRect rect_full = {X_PADDING, BAR_POSITION, FULL_BAR_WIDTH, X_PADDING};
|
||||||
surface->fillRect(&rect_full, static_cast<Uint8>(PaletteColor::WHITE));
|
surface->fillRect(&rect_full, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
|
|
||||||
Screen::get()->render();
|
Screen::get()->render();
|
||||||
|
|||||||
@@ -91,12 +91,12 @@ struct ResourceAnimation {
|
|||||||
// Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre
|
// Estructura para almacenar ficheros con el mapa de tiles de una habitación y su nombre
|
||||||
struct ResourceTileMap {
|
struct ResourceTileMap {
|
||||||
std::string name; // Nombre del mapa de tiles
|
std::string name; // Nombre del mapa de tiles
|
||||||
std::vector<int> tileMap; // Vector con los indices del mapa de tiles
|
std::vector<int> tile_map; // Vector con los indices del mapa de tiles
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
ResourceTileMap(const std::string& name, const std::vector<int>& tileMap)
|
ResourceTileMap(const std::string& name, const std::vector<int>& tile_map)
|
||||||
: name(name),
|
: name(name),
|
||||||
tileMap(tileMap) {}
|
tile_map(tile_map) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Estructura para almacenar habitaciones y su nombre
|
// Estructura para almacenar habitaciones y su nombre
|
||||||
@@ -131,7 +131,7 @@ struct ResourceCount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Obtiene el porcentaje de recursos cargados
|
// Obtiene el porcentaje de recursos cargados
|
||||||
float getPercentage() {
|
float getPercentage() const {
|
||||||
return static_cast<float>(loaded) / static_cast<float>(total);
|
return static_cast<float>(loaded) / static_cast<float>(total);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -139,7 +139,7 @@ struct ResourceCount {
|
|||||||
class Resource {
|
class Resource {
|
||||||
private:
|
private:
|
||||||
// [SINGLETON] Objeto resource privado para Don Melitón
|
// [SINGLETON] Objeto resource privado para Don Melitón
|
||||||
static Resource* resource_;
|
static Resource* resource;
|
||||||
|
|
||||||
std::vector<ResourceSound> sounds_; // Vector con los sonidos
|
std::vector<ResourceSound> sounds_; // Vector con los sonidos
|
||||||
std::vector<ResourceMusic> musics_; // Vector con las musicas
|
std::vector<ResourceMusic> musics_; // Vector con las musicas
|
||||||
@@ -198,8 +198,8 @@ class Resource {
|
|||||||
// Muestra el progreso de carga
|
// Muestra el progreso de carga
|
||||||
void renderProgress();
|
void renderProgress();
|
||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventosstatic
|
||||||
void checkEvents();
|
static void checkEvents();
|
||||||
|
|
||||||
// Actualiza el progreso de carga
|
// Actualiza el progreso de carga
|
||||||
void updateLoadingProgress(int steps = 5);
|
void updateLoadingProgress(int steps = 5);
|
||||||
|
|||||||
@@ -243,45 +243,45 @@ bool Director::setFileList() {
|
|||||||
#ifdef MACOS_BUNDLE
|
#ifdef MACOS_BUNDLE
|
||||||
const std::string prefix = "/../Resources";
|
const std::string prefix = "/../Resources";
|
||||||
#else
|
#else
|
||||||
const std::string prefix = "";
|
const std::string PREFIX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Texto
|
// Texto
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/smb2.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/smb2.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/smb2.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/debug.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/debug.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/debug.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/debug.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/gauntlet.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/gauntlet.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/gauntlet.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/gauntlet.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/subatomic.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/subatomic.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/subatomic.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/subatomic.txt", AssetType::FONT);
|
||||||
Asset::get()->add(prefix + "/data/font/8bithud.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/font/8bithud.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/font/8bithud.txt", AssetType::FONT);
|
Asset::get()->add(PREFIX + "/data/font/8bithud.txt", AssetType::FONT);
|
||||||
|
|
||||||
// Paletas
|
// Paletas
|
||||||
Asset::get()->add(prefix + "/data/palette/zx-spectrum.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/zx-spectrum.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/zx-spectrum-adjusted.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/zx-spectrum-adjusted.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/zxarne-5-2.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/zxarne-5-2.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/black-and-white.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/black-and-white.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/green-phosphor.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/green-phosphor.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/orange-screen.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/orange-screen.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/ruzx-spectrum.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/ruzx-spectrum-revision-2.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/ruzx-spectrum-revision-2.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/pico-8.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/pico-8.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/sweetie-16.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/sweetie-16.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/island-joy-16.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/island-joy-16.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/lost-century.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/lost-century.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/na16.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/na16.pal", AssetType::PALETTE);
|
||||||
Asset::get()->add(prefix + "/data/palette/steam-lords.pal", AssetType::PALETTE);
|
Asset::get()->add(PREFIX + "/data/palette/steam-lords.pal", AssetType::PALETTE);
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_vertex.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_vertex.glsl", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_fragment.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_fragment.glsl", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_vertex_es.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_vertex_es.glsl", AssetType::DATA);
|
||||||
Asset::get()->add(prefix + "/data/shaders/crtpi_fragment_es.glsl", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/shaders/crtpi_fragment_es.glsl", AssetType::DATA);
|
||||||
|
|
||||||
// Datos
|
// Datos
|
||||||
Asset::get()->add(prefix + "/data/input/gamecontrollerdb.txt", AssetType::DATA);
|
Asset::get()->add(PREFIX + "/data/input/gamecontrollerdb.txt", AssetType::DATA);
|
||||||
|
|
||||||
// Ficheros de sistema
|
// Ficheros de sistema
|
||||||
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
Asset::get()->add(system_folder_ + "/config.txt", AssetType::DATA, false, true);
|
||||||
@@ -292,182 +292,182 @@ bool Director::setFileList() {
|
|||||||
// Tilemaps y Rooms
|
// Tilemaps y Rooms
|
||||||
for (int i = 1; i <= 60; ++i) {
|
for (int i = 1; i <= 60; ++i) {
|
||||||
std::string index = (i < 10 ? "0" : "") + std::to_string(i);
|
std::string index = (i < 10 ? "0" : "") + std::to_string(i);
|
||||||
Asset::get()->add(prefix + "/data/room/" + index + ".tmx", AssetType::TILEMAP);
|
Asset::get()->add(PREFIX + "/data/room/" + index + ".tmx", AssetType::TILEMAP);
|
||||||
Asset::get()->add(prefix + "/data/room/" + index + ".room", AssetType::ROOM);
|
Asset::get()->add(PREFIX + "/data/room/" + index + ".room", AssetType::ROOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tilesets
|
// Tilesets
|
||||||
Asset::get()->add(prefix + "/data/tilesets/standard.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/tilesets/standard.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Enemigos
|
// Enemigos
|
||||||
Asset::get()->add(prefix + "/data/enemies/abad_bell.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/abad_bell.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/abad_bell.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/abad_bell.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/abad.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/abad.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/abad.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/abad.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/amstrad_cs.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/amstrad_cs.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/amstrad_cs.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/amstrad_cs.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/flying_arounder.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/flying_arounder.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/flying_arounder.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/flying_arounder.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/stopped_arounder.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/stopped_arounder.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/stopped_arounder.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/stopped_arounder.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/walking_arounder.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/walking_arounder.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/walking_arounder.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/walking_arounder.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/arounders_door.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/arounders_door.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/arounders_door.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/arounders_door.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/arounders_machine.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/arounders_machine.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/arounders_machine.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/arounders_machine.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bat.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/bat.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bat.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/bat.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman_bell.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/batman_bell.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman_bell.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/batman_bell.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman_fire.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/batman_fire.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman_fire.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/batman_fire.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/batman.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/batman.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/batman.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bell.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/bell.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bell.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/bell.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bin.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/bin.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bin.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/bin.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bird.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/bird.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bird.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/bird.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/breakout.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/breakout.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/breakout.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/breakout.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bry.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/bry.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/bry.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/bry.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/chip.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/chip.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/chip.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/chip.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/code.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/code.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/code.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/code.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/congo.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/congo.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/congo.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/congo.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/crosshair.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/crosshair.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/crosshair.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/crosshair.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/demon.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/demon.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/demon.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/demon.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/dimallas.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/dimallas.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/dimallas.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/dimallas.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/floppy.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/floppy.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/floppy.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/floppy.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/dong.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/dong.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/dong.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/dong.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/guitar.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/guitar.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/guitar.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/guitar.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/heavy.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/heavy.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/heavy.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/heavy.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#1.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#1.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#1.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#1.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#2.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#2.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#2.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#3.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#3.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailer_#3.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jailer_#3.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jailbattle_alien.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailbattle_alien.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jailbattle_alien.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailbattle_human.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jailbattle_human.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jailbattle_human.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jailbattle_human.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jeannine.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/jeannine.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/jeannine.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/jeannine.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/lamp.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/lamp.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/lamp.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/lamp.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/lord_abad.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/lord_abad.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/lord_abad.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/lord_abad.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/matatunos.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/matatunos.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/matatunos.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/matatunos.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/mummy.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/mummy.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/mummy.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/mummy.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/paco.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/paco.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/paco.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/paco.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/elsa.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/elsa.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/elsa.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/elsa.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/qvoid.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/qvoid.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/qvoid.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/qvoid.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/robot.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/robot.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/robot.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/robot.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/sam.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/sam.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/sam.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/sam.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/shock.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/shock.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/shock.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/shock.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/sigmasua.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/sigmasua.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/sigmasua.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/sigmasua.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/spark.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/spark.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/spark.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/spark.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/aerojailer.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/special/aerojailer.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/aerojailer.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/special/aerojailer.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/arounder.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/special/arounder.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/arounder.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/special/arounder.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/special/pepe_rosita_job.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/pepe_rosita_job.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/special/pepe_rosita_job.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/shooting_star.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/special/shooting_star.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/special/shooting_star.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/special/shooting_star.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/spider.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/spider.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/spider.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/spider.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tree_thing.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/tree_thing.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tree_thing.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/tree_thing.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tuno.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/tuno.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tuno.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/tuno.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tv_panel.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/tv_panel.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tv_panel.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/tv_panel.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tv.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/tv.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/tv.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/tv.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/upv_student.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/upv_student.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/upv_student.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/upv_student.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/wave.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/wave.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/wave.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/wave.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/enemies/z80.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/enemies/z80.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/enemies/z80.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/enemies/z80.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Jugador
|
// Jugador
|
||||||
Asset::get()->add(prefix + "/data/player/player.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/player/player.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/player/player.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/player/player.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/player/player2.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/player/player2.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/player/player2.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/player/player2.ani", AssetType::ANIMATION);
|
||||||
Asset::get()->add(prefix + "/data/player/player_game_over.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/player/player_game_over.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/player/player_game_over.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/player/player_game_over.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
// Items
|
// Items
|
||||||
Asset::get()->add(prefix + "/data/items/items.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/items/items.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Musicas
|
// Musicas
|
||||||
Asset::get()->add(prefix + "/data/music/title.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/title.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/game.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/game.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/loading_sound1.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/loading_sound1.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/loading_sound2.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/loading_sound2.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/loading_sound3.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/loading_sound3.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/ending1.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/ending1.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/ending2.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/ending2.ogg", AssetType::MUSIC);
|
||||||
Asset::get()->add(prefix + "/data/music/game_over.ogg", AssetType::MUSIC);
|
Asset::get()->add(PREFIX + "/data/music/game_over.ogg", AssetType::MUSIC);
|
||||||
|
|
||||||
// Efectos de sonido
|
// Efectos de sonido
|
||||||
Asset::get()->add(prefix + "/data/sound/item.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/item.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/death.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/death.wav", AssetType::SOUND);
|
||||||
Asset::get()->add(prefix + "/data/sound/notify.wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/notify.wav", AssetType::SOUND);
|
||||||
|
|
||||||
// Efectos de sonido para el salto
|
// Efectos de sonido para el salto
|
||||||
for (int i = 1; i <= 24; ++i) {
|
for (int i = 1; i <= 24; ++i) {
|
||||||
std::string jump_index = std::to_string(i);
|
std::string jump_index = std::to_string(i);
|
||||||
Asset::get()->add(prefix + "/data/sound/jump" + jump_index + ".wav", AssetType::SOUND);
|
Asset::get()->add(PREFIX + "/data/sound/jump" + jump_index + ".wav", AssetType::SOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logo
|
// Logo
|
||||||
Asset::get()->add(prefix + "/data/logo/jailgames.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/logo/jailgames.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/logo/since_1998.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/logo/since_1998.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Loading
|
// Loading
|
||||||
Asset::get()->add(prefix + "/data/loading/loading_screen_bn.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/loading/loading_screen_bn.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/loading/loading_screen_color.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/loading/loading_screen_color.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
Asset::get()->add(prefix + "/data/title/title_logo.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/title/title_logo.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Ending
|
// Ending
|
||||||
Asset::get()->add(prefix + "/data/ending/ending1.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/ending/ending1.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/ending/ending2.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/ending/ending2.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/ending/ending3.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/ending/ending3.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/ending/ending4.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/ending/ending4.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/ending/ending5.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/ending/ending5.gif", AssetType::BITMAP);
|
||||||
|
|
||||||
// Credits
|
// Credits
|
||||||
Asset::get()->add(prefix + "/data/credits/shine.gif", AssetType::BITMAP);
|
Asset::get()->add(PREFIX + "/data/credits/shine.gif", AssetType::BITMAP);
|
||||||
Asset::get()->add(prefix + "/data/credits/shine.ani", AssetType::ANIMATION);
|
Asset::get()->add(PREFIX + "/data/credits/shine.ani", AssetType::ANIMATION);
|
||||||
|
|
||||||
return Asset::get()->check();
|
return Asset::get()->check();
|
||||||
}
|
}
|
||||||
@@ -480,8 +480,8 @@ void Director::runLogo() {
|
|||||||
|
|
||||||
// Ejecuta la seccion de juego de la pantalla de carga
|
// Ejecuta la seccion de juego de la pantalla de carga
|
||||||
void Director::runLoadingScreen() {
|
void Director::runLoadingScreen() {
|
||||||
auto loadingScreen = std::make_unique<LoadingScreen>();
|
auto loading_screen = std::make_unique<LoadingScreen>();
|
||||||
loadingScreen->run();
|
loading_screen->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego con el titulo y los menus
|
// Ejecuta la seccion de juego con el titulo y los menus
|
||||||
@@ -516,8 +516,8 @@ void Director::runEnding2() {
|
|||||||
|
|
||||||
// Ejecuta la seccion del final de la partida
|
// Ejecuta la seccion del final de la partida
|
||||||
void Director::runGameOver() {
|
void Director::runGameOver() {
|
||||||
auto gameOver = std::make_unique<GameOver>();
|
auto game_over = std::make_unique<GameOver>();
|
||||||
gameOver->run();
|
game_over->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ejecuta la seccion de juego donde se juega
|
// Ejecuta la seccion de juego donde se juega
|
||||||
|
|||||||
@@ -8,25 +8,25 @@ class Director {
|
|||||||
public:
|
public:
|
||||||
Director(int argc, const char* argv[]); // Constructor
|
Director(int argc, const char* argv[]); // Constructor
|
||||||
~Director(); // Destructor
|
~Director(); // Destructor
|
||||||
int run(); // Bucle principal
|
static int run(); // Bucle principal
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Variables ---
|
// --- Variables ---
|
||||||
std::string executable_path_; // Path del ejecutable
|
std::string executable_path_; // Path del ejecutable
|
||||||
std::string system_folder_; // Carpeta del sistema donde guardar datos
|
std::string system_folder_; // Carpeta del sistema donde guardar datos
|
||||||
std::string checkProgramArguments(int argc, const char* argv[]); // Comprueba los parametros del programa
|
static std::string checkProgramArguments(int argc, const char* argv[]); // Comprueba los parametros del programa
|
||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
void createSystemFolder(const std::string& folder); // Crea la carpeta del sistema donde guardar datos
|
void createSystemFolder(const std::string& folder); // Crea la carpeta del sistema donde guardar datos
|
||||||
void initInput(); // Inicializa el objeto Input
|
static void initInput(); // Inicializa el objeto Input
|
||||||
bool setFileList(); // Crea el indice de ficheros
|
bool setFileList(); // Crea el indice de ficheros
|
||||||
void runLogo(); // Ejecuta la seccion de juego con el logo
|
static void runLogo(); // Ejecuta la seccion de juego con el logo
|
||||||
void runLoadingScreen(); // Ejecuta la seccion de juego de la pantalla de carga
|
static void runLoadingScreen(); // Ejecuta la seccion de juego de la pantalla de carga
|
||||||
void runTitle(); // Ejecuta la seccion de juego con el titulo y los menus
|
static void runTitle(); // Ejecuta la seccion de juego con el titulo y los menus
|
||||||
void runCredits(); // Ejecuta la seccion de los creditos del juego
|
static void runCredits(); // Ejecuta la seccion de los creditos del juego
|
||||||
void runDemo(); // Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
static void runDemo(); // Ejecuta la seccion de la demo, donde se ven pantallas del juego
|
||||||
void runEnding(); // Ejecuta la seccion del final del juego
|
static void runEnding(); // Ejecuta la seccion del final del juego
|
||||||
void runEnding2(); // Ejecuta la seccion del final del juego
|
static void runEnding2(); // Ejecuta la seccion del final del juego
|
||||||
void runGameOver(); // Ejecuta la seccion del final de la partida
|
static void runGameOver(); // Ejecuta la seccion del final de la partida
|
||||||
void runGame(); // Ejecuta la seccion de juego donde se juega
|
static void runGame(); // Ejecuta la seccion de juego donde se juega
|
||||||
};
|
};
|
||||||
@@ -28,8 +28,8 @@ void Item::render() {
|
|||||||
|
|
||||||
// Obtiene su ubicación
|
// Obtiene su ubicación
|
||||||
SDL_FPoint Item::getPos() {
|
SDL_FPoint Item::getPos() {
|
||||||
const SDL_FPoint p = {sprite_->getX(), sprite_->getY()};
|
const SDL_FPoint P = {sprite_->getX(), sprite_->getY()};
|
||||||
return p;
|
return P;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asigna los colores del objeto
|
// Asigna los colores del objeto
|
||||||
|
|||||||
@@ -69,27 +69,27 @@ 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::get()->checkInput(InputAction::LEFT)) {
|
if (Input::get()->checkInput(InputAction::LEFT)) {
|
||||||
vx_ = -0.6f;
|
vx_ = -0.6F;
|
||||||
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (Input::get()->checkInput(InputAction::RIGHT)) {
|
else if (Input::get()->checkInput(InputAction::RIGHT)) {
|
||||||
vx_ = 0.6f;
|
vx_ = 0.6F;
|
||||||
sprite_->setFlip(SDL_FLIP_NONE);
|
sprite_->setFlip(SDL_FLIP_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
// No se pulsa ninguna dirección
|
// No se pulsa ninguna dirección
|
||||||
vx_ = 0.0f;
|
vx_ = 0.0F;
|
||||||
if (isOnAutoSurface()) {
|
if (isOnAutoSurface()) {
|
||||||
// Si deja de moverse sobre una superficie se engancha
|
// Si deja de moverse sobre una superficie se engancha
|
||||||
auto_movement_ = true;
|
auto_movement_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // El movimiento lo proporciona la superficie
|
} else { // El movimiento lo proporciona la superficie
|
||||||
vx_ = 0.6f * room_->getAutoSurfaceDirection();
|
vx_ = 0.6F * room_->getAutoSurfaceDirection();
|
||||||
|
|
||||||
if (vx_ > 0.0f) {
|
if (vx_ > 0.0F) {
|
||||||
sprite_->setFlip(SDL_FLIP_NONE);
|
sprite_->setFlip(SDL_FLIP_NONE);
|
||||||
} else {
|
} else {
|
||||||
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
||||||
@@ -104,7 +104,7 @@ void Player::checkInput() {
|
|||||||
|
|
||||||
if (isOnFloor() || isOnAutoSurface()) {
|
if (isOnFloor() || isOnAutoSurface()) {
|
||||||
setState(PlayerState::JUMPING);
|
setState(PlayerState::JUMPING);
|
||||||
vy_ = -MAX_VY_;
|
vy_ = -MAX_VY;
|
||||||
jump_init_pos_ = y_;
|
jump_init_pos_ = y_;
|
||||||
jumping_counter_ = 0;
|
jumping_counter_ = 0;
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ void Player::checkBorders() {
|
|||||||
is_on_border_ = true;
|
is_on_border_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (x_ + WIDTH_ > PLAY_AREA_RIGHT) {
|
else if (x_ + WIDTH > PLAY_AREA_RIGHT) {
|
||||||
border_ = RoomBorder::RIGHT;
|
border_ = RoomBorder::RIGHT;
|
||||||
is_on_border_ = true;
|
is_on_border_ = true;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ void Player::checkBorders() {
|
|||||||
is_on_border_ = true;
|
is_on_border_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (y_ + HEIGHT_ > PLAY_AREA_BOTTOM) {
|
else if (y_ + HEIGHT > PLAY_AREA_BOTTOM) {
|
||||||
border_ = RoomBorder::BOTTOM;
|
border_ = RoomBorder::BOTTOM;
|
||||||
is_on_border_ = true;
|
is_on_border_ = true;
|
||||||
}
|
}
|
||||||
@@ -142,23 +142,23 @@ void Player::checkBorders() {
|
|||||||
void Player::checkState() {
|
void Player::checkState() {
|
||||||
// Actualiza las variables en función del estado
|
// Actualiza las variables en función del estado
|
||||||
if (state_ == PlayerState::FALLING) {
|
if (state_ == PlayerState::FALLING) {
|
||||||
vx_ = 0.0f;
|
vx_ = 0.0F;
|
||||||
vy_ = MAX_VY_;
|
vy_ = MAX_VY;
|
||||||
falling_counter_++;
|
falling_counter_++;
|
||||||
playFallSound();
|
playFallSound();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (state_ == PlayerState::STANDING) {
|
else if (state_ == PlayerState::STANDING) {
|
||||||
if (previous_state_ == PlayerState::FALLING && falling_counter_ > MAX_FALLING_HEIGHT_) { // Si cae de muy alto, el jugador muere
|
if (previous_state_ == PlayerState::FALLING && falling_counter_ > MAX_FALLING_HEIGHT) { // Si cae de muy alto, el jugador muere
|
||||||
is_alive_ = false;
|
is_alive_ = false;
|
||||||
}
|
}
|
||||||
vy_ = 0.0f;
|
vy_ = 0.0F;
|
||||||
jumping_counter_ = 0;
|
jumping_counter_ = 0;
|
||||||
falling_counter_ = 0;
|
falling_counter_ = 0;
|
||||||
if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope()) {
|
if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope()) {
|
||||||
setState(PlayerState::FALLING);
|
setState(PlayerState::FALLING);
|
||||||
vx_ = 0.0f;
|
vx_ = 0.0F;
|
||||||
vy_ = MAX_VY_;
|
vy_ = MAX_VY;
|
||||||
falling_counter_++;
|
falling_counter_++;
|
||||||
playFallSound();
|
playFallSound();
|
||||||
}
|
}
|
||||||
@@ -175,7 +175,7 @@ void Player::checkState() {
|
|||||||
void Player::switchBorders() {
|
void Player::switchBorders() {
|
||||||
switch (border_) {
|
switch (border_) {
|
||||||
case RoomBorder::TOP:
|
case RoomBorder::TOP:
|
||||||
y_ = PLAY_AREA_BOTTOM - HEIGHT_ - BLOCK;
|
y_ = PLAY_AREA_BOTTOM - HEIGHT - BLOCK;
|
||||||
setState(PlayerState::STANDING);
|
setState(PlayerState::STANDING);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -189,7 +189,7 @@ void Player::switchBorders() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RoomBorder::LEFT:
|
case RoomBorder::LEFT:
|
||||||
x_ = PLAY_AREA_RIGHT - WIDTH_;
|
x_ = PLAY_AREA_RIGHT - WIDTH;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -203,15 +203,13 @@ void Player::switchBorders() {
|
|||||||
|
|
||||||
// Aplica gravedad al jugador
|
// Aplica gravedad al jugador
|
||||||
void Player::applyGravity() {
|
void Player::applyGravity() {
|
||||||
constexpr float GRAVITY_FORCE = 0.035f;
|
constexpr float GRAVITY_FORCE = 0.035F;
|
||||||
|
|
||||||
// La gravedad solo se aplica cuando el jugador esta saltando
|
// La gravedad solo se aplica cuando el jugador esta saltando
|
||||||
// Nunca mientras cae o esta de pie
|
// Nunca mientras cae o esta de pie
|
||||||
if (state_ == PlayerState::JUMPING) {
|
if (state_ == PlayerState::JUMPING) {
|
||||||
vy_ += GRAVITY_FORCE;
|
vy_ += GRAVITY_FORCE;
|
||||||
if (vy_ > MAX_VY_) {
|
vy_ = std::min(vy_, MAX_VY);
|
||||||
vy_ = MAX_VY_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,12 +224,12 @@ void Player::move() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Se mueve hacia la izquierda
|
// Se mueve hacia la izquierda
|
||||||
if (vx_ < 0.0f) {
|
if (vx_ < 0.0F) {
|
||||||
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
||||||
SDL_FRect proj;
|
SDL_FRect proj;
|
||||||
proj.x = static_cast<int>(x_ + vx_);
|
proj.x = static_cast<int>(x_ + vx_);
|
||||||
proj.y = static_cast<int>(y_);
|
proj.y = static_cast<int>(y_);
|
||||||
proj.h = HEIGHT_;
|
proj.h = HEIGHT;
|
||||||
proj.w = static_cast<int>(std::ceil(std::fabs(vx_))); // Para evitar que tenga un ancho de 0 pixels
|
proj.w = static_cast<int>(std::ceil(std::fabs(vx_))); // Para evitar que tenga un ancho de 0 pixels
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -252,10 +250,10 @@ void Player::move() {
|
|||||||
|
|
||||||
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
||||||
if (state_ != PlayerState::JUMPING) {
|
if (state_ != PlayerState::JUMPING) {
|
||||||
const LineVertical LEFT_SIDE = {static_cast<int>(x_), static_cast<int>(y_) + static_cast<int>(HEIGHT_) - 2, static_cast<int>(y_) + static_cast<int>(HEIGHT_) - 1}; // Comprueba solo los dos pixels de abajo
|
const LineVertical LEFT_SIDE = {static_cast<int>(x_), static_cast<int>(y_) + static_cast<int>(HEIGHT) - 2, static_cast<int>(y_) + static_cast<int>(HEIGHT) - 1}; // Comprueba solo los dos pixels de abajo
|
||||||
const int LY = room_->checkLeftSlopes(&LEFT_SIDE);
|
const int LY = room_->checkLeftSlopes(&LEFT_SIDE);
|
||||||
if (LY > -1) {
|
if (LY > -1) {
|
||||||
y_ = LY - HEIGHT_;
|
y_ = LY - HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,12 +264,12 @@ void Player::move() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Se mueve hacia la derecha
|
// Se mueve hacia la derecha
|
||||||
else if (vx_ > 0.0f) {
|
else if (vx_ > 0.0F) {
|
||||||
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
||||||
SDL_FRect proj;
|
SDL_FRect proj;
|
||||||
proj.x = x_ + WIDTH_;
|
proj.x = x_ + WIDTH;
|
||||||
proj.y = y_;
|
proj.y = y_;
|
||||||
proj.h = HEIGHT_;
|
proj.h = HEIGHT;
|
||||||
proj.w = ceil(vx_); // Para evitar que tenga un ancho de 0 pixels
|
proj.w = ceil(vx_); // Para evitar que tenga un ancho de 0 pixels
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -287,15 +285,15 @@ void Player::move() {
|
|||||||
x_ += vx_;
|
x_ += vx_;
|
||||||
} else {
|
} else {
|
||||||
// Si hay colisión lo mueve hasta donde no colisiona
|
// Si hay colisión lo mueve hasta donde no colisiona
|
||||||
x_ = POS - WIDTH_;
|
x_ = POS - WIDTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
// Si ha tocado alguna rampa mientras camina (sin saltar), asciende
|
||||||
if (state_ != PlayerState::JUMPING) {
|
if (state_ != PlayerState::JUMPING) {
|
||||||
const LineVertical RIGHT_SIDE = {static_cast<int>(x_) + static_cast<int>(WIDTH_) - 1, static_cast<int>(y_) + static_cast<int>(HEIGHT_) - 2, static_cast<int>(y_) + static_cast<int>(HEIGHT_) - 1}; // Comprueba solo los dos pixels de abajo
|
const LineVertical RIGHT_SIDE = {static_cast<int>(x_) + static_cast<int>(WIDTH) - 1, static_cast<int>(y_) + static_cast<int>(HEIGHT) - 2, static_cast<int>(y_) + static_cast<int>(HEIGHT) - 1}; // Comprueba solo los dos pixels de abajo
|
||||||
const int RY = room_->checkRightSlopes(&RIGHT_SIDE);
|
const int RY = room_->checkRightSlopes(&RIGHT_SIDE);
|
||||||
if (RY > -1) {
|
if (RY > -1) {
|
||||||
y_ = RY - HEIGHT_;
|
y_ = RY - HEIGHT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,13 +318,13 @@ void Player::move() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Se mueve hacia arriba
|
// Se mueve hacia arriba
|
||||||
if (vy_ < 0.0f) {
|
if (vy_ < 0.0F) {
|
||||||
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
||||||
SDL_FRect proj;
|
SDL_FRect proj;
|
||||||
proj.x = static_cast<int>(x_);
|
proj.x = static_cast<int>(x_);
|
||||||
proj.y = static_cast<int>(y_ + vy_);
|
proj.y = static_cast<int>(y_ + vy_);
|
||||||
proj.h = static_cast<int>(std::ceil(std::fabs(vy_))); // Para evitar que tenga una altura de 0 pixels
|
proj.h = static_cast<int>(std::ceil(std::fabs(vy_))); // Para evitar que tenga una altura de 0 pixels
|
||||||
proj.w = WIDTH_;
|
proj.w = WIDTH;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
debug_rect_y_ = proj;
|
debug_rect_y_ = proj;
|
||||||
@@ -347,13 +345,13 @@ void Player::move() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Se mueve hacia abajo
|
// Se mueve hacia abajo
|
||||||
else if (vy_ > 0.0f) {
|
else if (vy_ > 0.0F) {
|
||||||
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
||||||
SDL_FRect proj;
|
SDL_FRect proj;
|
||||||
proj.x = x_;
|
proj.x = x_;
|
||||||
proj.y = y_ + HEIGHT_;
|
proj.y = y_ + HEIGHT;
|
||||||
proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels
|
proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels
|
||||||
proj.w = WIDTH_;
|
proj.w = WIDTH;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
debug_rect_y_ = proj;
|
debug_rect_y_ = proj;
|
||||||
@@ -363,7 +361,7 @@ void Player::move() {
|
|||||||
const float POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj));
|
const float POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj));
|
||||||
if (POS > -1) {
|
if (POS > -1) {
|
||||||
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
|
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
|
||||||
y_ = POS - HEIGHT_;
|
y_ = POS - HEIGHT;
|
||||||
setState(PlayerState::STANDING);
|
setState(PlayerState::STANDING);
|
||||||
|
|
||||||
// Deja de estar enganchado a la superficie automatica
|
// Deja de estar enganchado a la superficie automatica
|
||||||
@@ -378,11 +376,11 @@ void Player::move() {
|
|||||||
if (POINT > -1) {
|
if (POINT > -1) {
|
||||||
// No está saltando y hay colisión con una rampa
|
// No está saltando y hay colisión con una rampa
|
||||||
// Calcula la nueva posición
|
// Calcula la nueva posición
|
||||||
y_ = POINT - HEIGHT_;
|
y_ = POINT - HEIGHT;
|
||||||
setState(PlayerState::STANDING);
|
setState(PlayerState::STANDING);
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
|
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||||
debug_point_ = {x_ + (WIDTH_ / 2), POINT};
|
debug_point_ = {x_ + (WIDTH / 2), POINT};
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
// No está saltando y no hay colisón con una rampa
|
// No está saltando y no hay colisón con una rampa
|
||||||
@@ -423,7 +421,7 @@ void Player::checkJumpEnd() {
|
|||||||
if (y_ >= jump_init_pos_) {
|
if (y_ >= jump_init_pos_) {
|
||||||
// Si alcanza la altura de salto inicial, pasa al estado de caída
|
// Si alcanza la altura de salto inicial, pasa al estado de caída
|
||||||
setState(PlayerState::FALLING);
|
setState(PlayerState::FALLING);
|
||||||
vy_ = MAX_VY_;
|
vy_ = MAX_VY;
|
||||||
jumping_counter_ = 0;
|
jumping_counter_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -467,7 +465,7 @@ bool Player::isOnFloor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba las rampas
|
// Comprueba las rampas
|
||||||
on_slope_l = room_->checkLeftSlopes(&under_feet_[0]);
|
on_slope_l = room_->checkLeftSlopes(under_feet_.data());
|
||||||
on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
|
on_slope_r = room_->checkRightSlopes(&under_feet_[1]);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -519,7 +517,7 @@ bool Player::isOnDownSlope() {
|
|||||||
under_feet_[1].y += 1;
|
under_feet_[1].y += 1;
|
||||||
|
|
||||||
// Comprueba las rampas
|
// Comprueba las rampas
|
||||||
on_slope |= room_->checkLeftSlopes(&under_feet_[0]);
|
on_slope |= room_->checkLeftSlopes(under_feet_.data());
|
||||||
on_slope |= room_->checkRightSlopes(&under_feet_[1]);
|
on_slope |= room_->checkRightSlopes(&under_feet_[1]);
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@@ -560,26 +558,26 @@ void Player::setColor() {
|
|||||||
|
|
||||||
// Actualiza los puntos de colisión
|
// Actualiza los puntos de colisión
|
||||||
void Player::updateColliderPoints() {
|
void Player::updateColliderPoints() {
|
||||||
const SDL_FRect rect = getRect();
|
const SDL_FRect RECT = getRect();
|
||||||
collider_points_[0] = {rect.x, rect.y};
|
collider_points_[0] = {RECT.x, RECT.y};
|
||||||
collider_points_[1] = {rect.x + 7, rect.y};
|
collider_points_[1] = {RECT.x + 7, RECT.y};
|
||||||
collider_points_[2] = {rect.x + 7, rect.y + 7};
|
collider_points_[2] = {RECT.x + 7, RECT.y + 7};
|
||||||
collider_points_[3] = {rect.x, rect.y + 7};
|
collider_points_[3] = {RECT.x, RECT.y + 7};
|
||||||
collider_points_[4] = {rect.x, rect.y + 8};
|
collider_points_[4] = {RECT.x, RECT.y + 8};
|
||||||
collider_points_[5] = {rect.x + 7, rect.y + 8};
|
collider_points_[5] = {RECT.x + 7, RECT.y + 8};
|
||||||
collider_points_[6] = {rect.x + 7, rect.y + 15};
|
collider_points_[6] = {RECT.x + 7, RECT.y + 15};
|
||||||
collider_points_[7] = {rect.x, rect.y + 15};
|
collider_points_[7] = {RECT.x, RECT.y + 15};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los puntos de los pies
|
// Actualiza los puntos de los pies
|
||||||
void Player::updateFeet() {
|
void Player::updateFeet() {
|
||||||
const SDL_FPoint p = {x_, y_};
|
const SDL_FPoint P = {x_, y_};
|
||||||
|
|
||||||
under_feet_[0] = {p.x, p.y + HEIGHT_};
|
under_feet_[0] = {P.x, P.y + HEIGHT};
|
||||||
under_feet_[1] = {p.x + 7, p.y + HEIGHT_};
|
under_feet_[1] = {P.x + 7, P.y + HEIGHT};
|
||||||
|
|
||||||
feet_[0] = {p.x, p.y + HEIGHT_ - 1};
|
feet_[0] = {P.x, P.y + HEIGHT - 1};
|
||||||
feet_[1] = {p.x + 7, p.y + HEIGHT_ - 1};
|
feet_[1] = {P.x + 7, P.y + HEIGHT - 1};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cambia el estado del jugador
|
// Cambia el estado del jugador
|
||||||
@@ -596,11 +594,11 @@ void Player::initSounds() {
|
|||||||
falling_sound_.clear();
|
falling_sound_.clear();
|
||||||
|
|
||||||
for (int i = 1; i <= 24; ++i) {
|
for (int i = 1; i <= 24; ++i) {
|
||||||
std::string soundFile = "jump" + std::to_string(i) + ".wav";
|
std::string sound_file = "jump" + std::to_string(i) + ".wav";
|
||||||
jumping_sound_.push_back(Resource::get()->getSound(soundFile));
|
jumping_sound_.push_back(Resource::get()->getSound(sound_file));
|
||||||
|
|
||||||
if (i >= 11) {
|
if (i >= 11) {
|
||||||
falling_sound_.push_back(Resource::get()->getSound(soundFile));
|
falling_sound_.push_back(Resource::get()->getSound(sound_file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -622,8 +620,8 @@ void Player::initSprite(const std::string& surface_path, const std::string& anim
|
|||||||
auto animations = Resource::get()->getAnimations(animations_path);
|
auto animations = Resource::get()->getAnimations(animations_path);
|
||||||
|
|
||||||
sprite_ = std::make_shared<SurfaceAnimatedSprite>(surface, animations);
|
sprite_ = std::make_shared<SurfaceAnimatedSprite>(surface, animations);
|
||||||
sprite_->setWidth(WIDTH_);
|
sprite_->setWidth(WIDTH);
|
||||||
sprite_->setHeight(HEIGHT_);
|
sprite_->setHeight(HEIGHT);
|
||||||
sprite_->setCurrentAnimation("walk");
|
sprite_->setCurrentAnimation("walk");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,10 +640,10 @@ void Player::renderDebugInfo() {
|
|||||||
surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::BRIGHT_CYAN));
|
surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::BRIGHT_CYAN));
|
||||||
|
|
||||||
// Pinta el rectangulo de movimiento
|
// Pinta el rectangulo de movimiento
|
||||||
if (vx_ != 0.0f) {
|
if (vx_ != 0.0F) {
|
||||||
surface->fillRect(&debug_rect_x_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
surface->fillRect(&debug_rect_x_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
||||||
}
|
}
|
||||||
if (vy_ != 0.0f) {
|
if (vy_ != 0.0F) {
|
||||||
surface->fillRect(&debug_rect_y_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
surface->fillRect(&debug_rect_y_, static_cast<Uint8>(PaletteColor::BRIGHT_RED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,12 +63,12 @@ struct PlayerData {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Player {
|
class Player {
|
||||||
public:
|
private:
|
||||||
// Constantes
|
// Constantes
|
||||||
static constexpr int WIDTH_ = 8; // Ancho del jugador
|
static constexpr int WIDTH = 8; // Ancho del jugador
|
||||||
static constexpr int HEIGHT_ = 16; // ALto del jugador
|
static constexpr int HEIGHT = 16; // ALto del jugador
|
||||||
static constexpr int MAX_FALLING_HEIGHT_ = BLOCK * 4; // Altura maxima permitida de caída.
|
static constexpr int MAX_FALLING_HEIGHT = BLOCK * 4; // Altura maxima permitida de caída.
|
||||||
static constexpr float MAX_VY_ = 1.2f; // Velocidad máxima que puede alcanzar al desplazarse en vertical
|
static constexpr float MAX_VY = 1.2F; // Velocidad máxima que puede alcanzar al desplazarse en vertical
|
||||||
|
|
||||||
// Objetos y punteros
|
// Objetos y punteros
|
||||||
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
std::shared_ptr<Room> room_; // Objeto encargado de gestionar cada habitación del juego
|
||||||
@@ -184,16 +184,16 @@ class Player {
|
|||||||
void update();
|
void update();
|
||||||
|
|
||||||
// Indica si el jugador esta en uno de los cuatro bordes de la pantalla
|
// Indica si el jugador esta en uno de los cuatro bordes de la pantalla
|
||||||
bool getOnBorder() { return is_on_border_; }
|
bool getOnBorder() const { return is_on_border_; }
|
||||||
|
|
||||||
// Indica en cual de los cuatro bordes se encuentra
|
// Indica en cual de los cuatro bordes se encuentra
|
||||||
RoomBorder getBorder() { return border_; }
|
RoomBorder getBorder() const { return border_; }
|
||||||
|
|
||||||
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
// Cambia al jugador de un borde al opuesto. Util para el cambio de pantalla
|
||||||
void switchBorders();
|
void switchBorders();
|
||||||
|
|
||||||
// Obtiene el rectangulo que delimita al jugador
|
// Obtiene el rectangulo que delimita al jugador
|
||||||
SDL_FRect getRect() { return {x_, y_, WIDTH_, HEIGHT_}; }
|
SDL_FRect getRect() { return {x_, y_, WIDTH, HEIGHT}; }
|
||||||
|
|
||||||
// Obtiene el rectangulo de colision del jugador
|
// Obtiene el rectangulo de colision del jugador
|
||||||
SDL_FRect& getCollider() { return collider_box_; }
|
SDL_FRect& getCollider() { return collider_box_; }
|
||||||
@@ -208,7 +208,7 @@ class Player {
|
|||||||
void setRoom(std::shared_ptr<Room> room) { room_ = room; }
|
void setRoom(std::shared_ptr<Room> room) { room_ = room; }
|
||||||
|
|
||||||
// Comprueba si el jugador esta vivo
|
// Comprueba si el jugador esta vivo
|
||||||
bool isAlive() { return is_alive_; }
|
bool isAlive() const { return is_alive_; }
|
||||||
|
|
||||||
// Pone el jugador en modo pausa
|
// Pone el jugador en modo pausa
|
||||||
void setPaused(bool value) { is_paused_ = value; }
|
void setPaused(bool value) { is_paused_ = value; }
|
||||||
|
|||||||
@@ -385,49 +385,49 @@ void Room::fillMapTexture() {
|
|||||||
auto surface = Screen::get()->getRendererSurface();
|
auto surface = Screen::get()->getRendererSurface();
|
||||||
|
|
||||||
// BottomSurfaces
|
// BottomSurfaces
|
||||||
if (true) {
|
{
|
||||||
for (auto l : bottom_floors_) {
|
for (auto l : bottom_floors_) {
|
||||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::BLUE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TopSurfaces
|
// TopSurfaces
|
||||||
if (true) {
|
{
|
||||||
for (auto l : top_floors_) {
|
for (auto l : top_floors_) {
|
||||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::RED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeftSurfaces
|
// LeftSurfaces
|
||||||
if (true) {
|
{
|
||||||
for (auto l : left_walls_) {
|
for (auto l : left_walls_) {
|
||||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
|
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::GREEN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RightSurfaces
|
// RightSurfaces
|
||||||
if (true) {
|
{
|
||||||
for (auto l : right_walls_) {
|
for (auto l : right_walls_) {
|
||||||
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
|
surface->drawLine(l.x, l.y1, l.x, l.y2, static_cast<Uint8>(PaletteColor::MAGENTA));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LeftSlopes
|
// LeftSlopes
|
||||||
if (true) {
|
{
|
||||||
for (auto l : left_slopes_) {
|
for (auto l : left_slopes_) {
|
||||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
|
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::CYAN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RightSlopes
|
// RightSlopes
|
||||||
if (true) {
|
{
|
||||||
for (auto l : right_slopes_) {
|
for (auto l : right_slopes_) {
|
||||||
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
|
surface->drawLine(l.x1, l.y1, l.x2, l.y2, static_cast<Uint8>(PaletteColor::YELLOW));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutoSurfaces
|
// AutoSurfaces
|
||||||
if (true) {
|
{
|
||||||
for (auto l : conveyor_belt_floors_) {
|
for (auto l : conveyor_belt_floors_) {
|
||||||
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
|
surface->drawLine(l.x1, l.y, l.x2, l.y, static_cast<Uint8>(PaletteColor::WHITE));
|
||||||
}
|
}
|
||||||
@@ -540,17 +540,17 @@ TileType Room::getTile(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Las filas 18-20 es de tiles t_animated
|
// Las filas 18-20 es de tiles t_animated
|
||||||
else if ((tile_map_[index] >= 18 * tile_set_width_) && (tile_map_[index] < 21 * tile_set_width_)) {
|
if ((tile_map_[index] >= 18 * tile_set_width_) && (tile_map_[index] < 21 * tile_set_width_)) {
|
||||||
return TileType::ANIMATED;
|
return TileType::ANIMATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 21 es de tiles t_slope_r
|
// La fila 21 es de tiles t_slope_r
|
||||||
else if ((tile_map_[index] >= 21 * tile_set_width_) && (tile_map_[index] < 22 * tile_set_width_)) {
|
if ((tile_map_[index] >= 21 * tile_set_width_) && (tile_map_[index] < 22 * tile_set_width_)) {
|
||||||
return TileType::SLOPE_R;
|
return TileType::SLOPE_R;
|
||||||
}
|
}
|
||||||
|
|
||||||
// La fila 22 es de tiles t_slope_l
|
// La fila 22 es de tiles t_slope_l
|
||||||
else if ((tile_map_[index] >= 22 * tile_set_width_) && (tile_map_[index] < 23 * tile_set_width_)) {
|
if ((tile_map_[index] >= 22 * tile_set_width_) && (tile_map_[index] < 23 * tile_set_width_)) {
|
||||||
return TileType::SLOPE_L;
|
return TileType::SLOPE_L;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ void Stats::addVisit(const std::string& name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Busca una entrada en la lista por nombre
|
// Busca una entrada en la lista por nombre
|
||||||
int Stats::findByName(const std::string& name, const std::vector<StatsData>& list_) {
|
int Stats::findByName(const std::string& name, const std::vector<StatsData>& list) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (const auto& l : list_) {
|
for (const auto& l : list) {
|
||||||
if (l.name == name) {
|
if (l.name == name) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@@ -89,8 +89,8 @@ int Stats::findByName(const std::string& name, const std::vector<StatsData>& lis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Carga las estadisticas desde un fichero
|
// Carga las estadisticas desde un fichero
|
||||||
bool Stats::loadFromFile(const std::string& file_path, std::vector<StatsData>& list_) {
|
bool Stats::loadFromFile(const std::string& file_path, std::vector<StatsData>& list) {
|
||||||
list_.clear();
|
list.clear();
|
||||||
|
|
||||||
// Indicador de éxito en la carga
|
// Indicador de éxito en la carga
|
||||||
bool success = true;
|
bool success = true;
|
||||||
@@ -121,7 +121,7 @@ bool Stats::loadFromFile(const std::string& file_path, std::vector<StatsData>& l
|
|||||||
getline(ss, tmp, ';');
|
getline(ss, tmp, ';');
|
||||||
stat.died = std::stoi(tmp);
|
stat.died = std::stoi(tmp);
|
||||||
|
|
||||||
list_.push_back(stat);
|
list.push_back(stat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,20 +132,20 @@ bool Stats::loadFromFile(const std::string& file_path, std::vector<StatsData>& l
|
|||||||
// El fichero no existe
|
// El fichero no existe
|
||||||
else {
|
else {
|
||||||
// Crea el fichero con los valores por defecto
|
// Crea el fichero con los valores por defecto
|
||||||
saveToFile(file_path, list_);
|
saveToFile(file_path, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Guarda las estadisticas en un fichero
|
// Guarda las estadisticas en un fichero
|
||||||
void Stats::saveToFile(const std::string& file_path, const std::vector<StatsData>& list_) {
|
void Stats::saveToFile(const std::string& file_path, const std::vector<StatsData>& list) {
|
||||||
// Crea y abre el fichero de texto
|
// Crea y abre el fichero de texto
|
||||||
std::ofstream file(file_path);
|
std::ofstream file(file_path);
|
||||||
|
|
||||||
// Escribe en el fichero
|
// Escribe en el fichero
|
||||||
file << "# ROOM NAME;VISITS;DEATHS" << std::endl;
|
file << "# ROOM NAME;VISITS;DEATHS" << std::endl;
|
||||||
for (const auto& item : list_) {
|
for (const auto& item : list) {
|
||||||
file << item.name << ";" << item.visited << ";" << item.died << std::endl;
|
file << item.name << ";" << item.visited << ";" << item.died << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Stats {
|
|||||||
static int findByName(const std::string& name, const std::vector<StatsData>& list);
|
static int findByName(const std::string& name, const std::vector<StatsData>& list);
|
||||||
|
|
||||||
// Carga las estadisticas desde un fichero
|
// Carga las estadisticas desde un fichero
|
||||||
bool loadFromFile(const std::string& file_path, std::vector<StatsData>& list);
|
static bool loadFromFile(const std::string& file_path, std::vector<StatsData>& list);
|
||||||
|
|
||||||
// Guarda las estadisticas en un fichero
|
// Guarda las estadisticas en un fichero
|
||||||
static void saveToFile(const std::string& file_path, const std::vector<StatsData>& list);
|
static void saveToFile(const std::string& file_path, const std::vector<StatsData>& list);
|
||||||
|
|||||||
@@ -304,28 +304,28 @@ void Ending2::updateTexts() {
|
|||||||
|
|
||||||
// Dibuja los sprites
|
// Dibuja los sprites
|
||||||
void Ending2::renderSprites() {
|
void Ending2::renderSprites() {
|
||||||
const Uint8 colorA = static_cast<Uint8>(PaletteColor::RED);
|
const Uint8 COLOR_A = static_cast<Uint8>(PaletteColor::RED);
|
||||||
for (auto sprite : sprites_) {
|
for (auto sprite : sprites_) {
|
||||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||||
const bool B = sprite->getRect().y < Options::game.height;
|
const bool B = sprite->getRect().y < Options::game.height;
|
||||||
if (A && B) {
|
if (A && B) {
|
||||||
sprite->render(1, colorA);
|
sprite->render(1, COLOR_A);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pinta el ultimo elemento de otro color
|
// Pinta el ultimo elemento de otro color
|
||||||
const Uint8 colorB = static_cast<Uint8>(PaletteColor::WHITE);
|
const Uint8 COLOR_B = static_cast<Uint8>(PaletteColor::WHITE);
|
||||||
sprites_.back()->render(1, colorB);
|
sprites_.back()->render(1, COLOR_B);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja los sprites con el texto
|
// Dibuja los sprites con el texto
|
||||||
void Ending2::renderSpriteTexts() {
|
void Ending2::renderSpriteTexts() {
|
||||||
const Uint8 color = static_cast<Uint8>(PaletteColor::WHITE);
|
const Uint8 COLOR = static_cast<Uint8>(PaletteColor::WHITE);
|
||||||
for (auto sprite : sprite_texts_) {
|
for (auto sprite : sprite_texts_) {
|
||||||
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
const bool A = sprite->getRect().y + sprite->getRect().h > 0;
|
||||||
const bool B = sprite->getRect().y < Options::game.height;
|
const bool B = sprite->getRect().y < Options::game.height;
|
||||||
if (A && B) {
|
if (A && B) {
|
||||||
sprite->render(1, color);
|
sprite->render(1, COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ void Ending2::renderTexts() {
|
|||||||
void Ending2::placeSprites() {
|
void Ending2::placeSprites() {
|
||||||
for (int i = 0; i < static_cast<int>(sprites_.size()); ++i) {
|
for (int i = 0; i < static_cast<int>(sprites_.size()); ++i) {
|
||||||
const float X = i % 2 == 0 ? FIRST_COL : SECOND_COL;
|
const float X = i % 2 == 0 ? FIRST_COL : SECOND_COL;
|
||||||
const float Y = (i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE) + Options::game.height + 40;
|
const float Y = ((i / 1) * (sprite_max_height_ + DIST_SPRITE_TEXT + Resource::get()->getText("smb2")->getCharacterSize() + DIST_SPRITE_SPRITE)) + Options::game.height + 40;
|
||||||
const float W = sprites_.at(i)->getWidth();
|
const float W = sprites_.at(i)->getWidth();
|
||||||
const float H = sprites_.at(i)->getHeight();
|
const float H = sprites_.at(i)->getHeight();
|
||||||
const float DX = -(W / 2);
|
const float DX = -(W / 2);
|
||||||
@@ -357,7 +357,7 @@ void Ending2::placeSprites() {
|
|||||||
|
|
||||||
// Recoloca el sprite del jugador, que es el último de la lista
|
// Recoloca el sprite del jugador, que es el último de la lista
|
||||||
const float X = (Options::game.width - sprites_.back()->getWidth()) / 2;
|
const float X = (Options::game.width - sprites_.back()->getWidth()) / 2;
|
||||||
const float Y = sprites_.back()->getPosY() + sprite_max_height_ * 2;
|
const float Y = sprites_.back()->getPosY() + (sprite_max_height_ * 2);
|
||||||
sprites_.back()->setPos(X, Y);
|
sprites_.back()->setPos(X, Y);
|
||||||
sprites_.back()->setCurrentAnimation("walk");
|
sprites_.back()->setCurrentAnimation("walk");
|
||||||
}
|
}
|
||||||
@@ -433,7 +433,7 @@ void Ending2::createTexts() {
|
|||||||
|
|
||||||
// Crea los últimos textos
|
// Crea los últimos textos
|
||||||
// El primer texto va a continuación del ultimo spriteText
|
// El primer texto va a continuación del ultimo spriteText
|
||||||
const int START = sprite_texts_.back()->getPosY() + text->getCharacterSize() * 15;
|
const int START = sprite_texts_.back()->getPosY() + (text->getCharacterSize() * 15);
|
||||||
list.clear();
|
list.clear();
|
||||||
list.push_back("THANK YOU");
|
list.push_back("THANK YOU");
|
||||||
list.push_back("FOR PLAYING!");
|
list.push_back("FOR PLAYING!");
|
||||||
@@ -469,7 +469,7 @@ void Ending2::updateFinalFade() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el volumen de la musica
|
// Actualiza el volumen de la musica
|
||||||
void Ending2::updateMusicVolume() {
|
void Ending2::updateMusicVolume() const {
|
||||||
// Constante para la duración en milisegundos
|
// Constante para la duración en milisegundos
|
||||||
constexpr Uint32 VOLUME_FADE_DURATION = 3000;
|
constexpr Uint32 VOLUME_FADE_DURATION = 3000;
|
||||||
|
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ class Ending2 {
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Comprueba el manejador de eventos
|
// Comprueba el manejador de eventos
|
||||||
void checkEvents();
|
static void checkEvents();
|
||||||
|
|
||||||
// Comprueba las entradas
|
// Comprueba las entradas
|
||||||
void checkInput();
|
static void checkInput();
|
||||||
|
|
||||||
// Actualiza el estado
|
// Actualiza el estado
|
||||||
void updateState();
|
void updateState();
|
||||||
@@ -126,7 +126,7 @@ class Ending2 {
|
|||||||
void updateFinalFade();
|
void updateFinalFade();
|
||||||
|
|
||||||
// Actualiza el volumen de la musica
|
// Actualiza el volumen de la musica
|
||||||
void updateMusicVolume();
|
void updateMusicVolume() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|||||||
@@ -180,9 +180,9 @@ void Game::render() {
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
// Pasa la información de debug
|
// Pasa la información de debug
|
||||||
void Game::updateDebugInfo() {
|
void Game::updateDebugInfo() {
|
||||||
Debug::get()->add("X = " + std::to_string(static_cast<int>(player_->x_)) + ", Y = " + std::to_string(static_cast<int>(player_->y_)));
|
//Debug::get()->add("X = " + std::to_string(static_cast<int>(player_->x_)) + ", Y = " + std::to_string(static_cast<int>(player_->y_)));
|
||||||
Debug::get()->add("VX = " + std::to_string(player_->vx_).substr(0, 4) + ", VY = " + std::to_string(player_->vy_).substr(0, 4));
|
//Debug::get()->add("VX = " + std::to_string(player_->vx_).substr(0, 4) + ", VY = " + std::to_string(player_->vy_).substr(0, 4));
|
||||||
Debug::get()->add("STATE = " + std::to_string(static_cast<int>(player_->state_)));
|
//Debug::get()->add("STATE = " + std::to_string(static_cast<int>(player_->state_)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
@@ -216,7 +216,7 @@ void Game::renderDebugInfo() {
|
|||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
void Game::checkDebugEvents(const SDL_Event& event) {
|
void Game::checkDebugEvents(const SDL_Event& event) {
|
||||||
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 0) {
|
if (event.type == SDL_EVENT_KEY_DOWN && static_cast<int>(event.key.repeat) == 0) {
|
||||||
switch (event.key.key) {
|
switch (event.key.key) {
|
||||||
case SDL_SCANCODE_G:
|
case SDL_SCANCODE_G:
|
||||||
Debug::get()->toggleEnabled();
|
Debug::get()->toggleEnabled();
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Game {
|
|||||||
void updateDebugInfo();
|
void updateDebugInfo();
|
||||||
|
|
||||||
// Pone la información de debug en pantalla
|
// Pone la información de debug en pantalla
|
||||||
void renderDebugInfo();
|
static void renderDebugInfo();
|
||||||
|
|
||||||
// Comprueba los eventos
|
// Comprueba los eventos
|
||||||
void checkDebugEvents(const SDL_Event& event);
|
void checkDebugEvents(const SDL_Event& event);
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ void Notifier::update() {
|
|||||||
for (auto& notification : notifications_) {
|
for (auto& notification : notifications_) {
|
||||||
// Si la notificación anterior está "saliendo", no hagas nada
|
// Si la notificación anterior está "saliendo", no hagas nada
|
||||||
if (!notifications_.empty() && ¬ification != ¬ifications_.front()) {
|
if (!notifications_.empty() && ¬ification != ¬ifications_.front()) {
|
||||||
const auto& PREVIOUS_NOTIFICATION = *(std::prev(¬ification));
|
const auto& previous_notification = *(std::prev(¬ification));
|
||||||
if (PREVIOUS_NOTIFICATION.state == NotificationStatus::RISING) {
|
if (previous_notification.state == NotificationStatus::RISING) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,13 +135,13 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const int text_size = 6;
|
const int TEXT_SIZE = 6;
|
||||||
const auto PADDING_IN_H = text_size;
|
const auto PADDING_IN_H = TEXT_SIZE;
|
||||||
const auto PADDING_IN_V = text_size / 2;
|
const auto PADDING_IN_V = TEXT_SIZE / 2;
|
||||||
const int ICON_SPACE = icon >= 0 ? ICON_SIZE + PADDING_IN_H : 0;
|
const int ICON_SPACE = icon >= 0 ? ICON_SIZE + PADDING_IN_H : 0;
|
||||||
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
|
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
|
||||||
const float WIDTH = Options::game.width - (PADDING_OUT * 2);
|
const float WIDTH = Options::game.width - (PADDING_OUT * 2);
|
||||||
const float HEIGHT = (text_size * texts.size()) + (PADDING_IN_V * 2);
|
const float HEIGHT = (TEXT_SIZE * texts.size()) + (PADDING_IN_V * 2);
|
||||||
const auto SHAPE = NotificationShape::SQUARED;
|
const auto SHAPE = NotificationShape::SQUARED;
|
||||||
|
|
||||||
// Posición horizontal
|
// Posición horizontal
|
||||||
@@ -170,7 +170,7 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
|||||||
// Offset
|
// Offset
|
||||||
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
|
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT;
|
||||||
const int TRAVEL_MOD = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
|
const int TRAVEL_MOD = (Options::notifications.getVerticalPosition() == Options::NotificationPosition::TOP) ? 1 : -1;
|
||||||
const int OFFSET = !notifications_.empty() ? notifications_.back().y + TRAVEL_MOD * notifications_.back().travel_dist : DESP_V;
|
const int OFFSET = !notifications_.empty() ? notifications_.back().y + (TRAVEL_MOD * notifications_.back().travel_dist) : DESP_V;
|
||||||
|
|
||||||
// Crea la notificacion
|
// Crea la notificacion
|
||||||
Notification n;
|
Notification n;
|
||||||
@@ -229,10 +229,10 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, Ui
|
|||||||
for (const auto& text : texts) {
|
for (const auto& text : texts) {
|
||||||
switch (text_is) {
|
switch (text_is) {
|
||||||
case NotificationText::LEFT:
|
case NotificationText::LEFT:
|
||||||
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_size + 1), text, COLOR);
|
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + (iterator * (TEXT_SIZE + 1)), text, COLOR);
|
||||||
break;
|
break;
|
||||||
case NotificationText::CENTER:
|
case NotificationText::CENTER:
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + iterator * (text_size + 1), text, 1, COLOR);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + (iterator * (TEXT_SIZE + 1)), text, 1, COLOR);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -42,29 +42,29 @@ bool checkCollision(const Circle& a, const Circle& b) {
|
|||||||
bool checkCollision(const Circle& a, const SDL_FRect& rect) {
|
bool checkCollision(const Circle& a, const SDL_FRect& rect) {
|
||||||
SDL_Rect b = toSDLRect(rect);
|
SDL_Rect b = toSDLRect(rect);
|
||||||
// Closest point on collision box
|
// Closest point on collision box
|
||||||
int cX;
|
int c_x;
|
||||||
int cY;
|
int c_y;
|
||||||
|
|
||||||
// Find closest x offset
|
// Find closest x offset
|
||||||
if (a.x < b.x) {
|
if (a.x < b.x) {
|
||||||
cX = b.x;
|
c_x = b.x;
|
||||||
} else if (a.x > b.x + b.w) {
|
} else if (a.x > b.x + b.w) {
|
||||||
cX = b.x + b.w;
|
c_x = b.x + b.w;
|
||||||
} else {
|
} else {
|
||||||
cX = a.x;
|
c_x = a.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find closest y offset
|
// Find closest y offset
|
||||||
if (a.y < b.y) {
|
if (a.y < b.y) {
|
||||||
cY = b.y;
|
c_y = b.y;
|
||||||
} else if (a.y > b.y + b.h) {
|
} else if (a.y > b.y + b.h) {
|
||||||
cY = b.y + b.h;
|
c_y = b.y + b.h;
|
||||||
} else {
|
} else {
|
||||||
cY = a.y;
|
c_y = a.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the closest point is inside the circle_t
|
// If the closest point is inside the circle_t
|
||||||
if (distanceSquared(a.x, a.y, cX, cY) < a.r * a.r) {
|
if (distanceSquared(a.x, a.y, c_x, c_y) < a.r * a.r) {
|
||||||
// This box and the circle_t have collided
|
// This box and the circle_t have collided
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user