forked from jaildesigner-jailgames/jaildoctors_dilemma
posat orden en defaults i defines
This commit is contained in:
@@ -82,7 +82,7 @@ void Cheevos::unlock(int id) {
|
||||
cheevos_list_.at(INDEX).completed = true;
|
||||
|
||||
// Mostrar notificación en la pantalla
|
||||
Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", cheevos_list_.at(INDEX).caption}, Notifier::Style::CHEEVO /*, cheevos_list_.at(INDEX).icon*/);
|
||||
Notifier::get()->show({"ACHIEVEMENT UNLOCKED!", cheevos_list_.at(INDEX).caption}, Notifier::Style::CHEEVO, -1, false);
|
||||
|
||||
// Guardar el estado de los logros
|
||||
saveToFile();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "external/fkyaml_node.hpp" // Para fkyaml::node
|
||||
|
||||
#include "core/resources/resource_helper.hpp" // Para Resource::Helper
|
||||
#include "utils/defines.hpp" // Para TILE_SIZE
|
||||
#include "utils/defines.hpp" // Para Tile::SIZE
|
||||
#include "utils/utils.hpp" // Para stringToColor
|
||||
|
||||
// Convierte room connection de YAML a formato interno
|
||||
@@ -153,34 +153,34 @@ void RoomLoader::parseEnemyBoundaries(const fkyaml::node& bounds_node, Enemy::Da
|
||||
if (bounds_node.contains("position1")) {
|
||||
const auto& pos1 = bounds_node["position1"];
|
||||
if (pos1.contains("x")) {
|
||||
enemy.x1 = pos1["x"].get_value<int>() * TILE_SIZE;
|
||||
enemy.x1 = pos1["x"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
if (pos1.contains("y")) {
|
||||
enemy.y1 = pos1["y"].get_value<int>() * TILE_SIZE;
|
||||
enemy.y1 = pos1["y"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
}
|
||||
if (bounds_node.contains("position2")) {
|
||||
const auto& pos2 = bounds_node["position2"];
|
||||
if (pos2.contains("x")) {
|
||||
enemy.x2 = pos2["x"].get_value<int>() * TILE_SIZE;
|
||||
enemy.x2 = pos2["x"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
if (pos2.contains("y")) {
|
||||
enemy.y2 = pos2["y"].get_value<int>() * TILE_SIZE;
|
||||
enemy.y2 = pos2["y"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
// Formato antiguo: x1/y1/x2/y2 (compatibilidad)
|
||||
if (bounds_node.contains("x1")) {
|
||||
enemy.x1 = bounds_node["x1"].get_value<int>() * TILE_SIZE;
|
||||
enemy.x1 = bounds_node["x1"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
if (bounds_node.contains("y1")) {
|
||||
enemy.y1 = bounds_node["y1"].get_value<int>() * TILE_SIZE;
|
||||
enemy.y1 = bounds_node["y1"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
if (bounds_node.contains("x2")) {
|
||||
enemy.x2 = bounds_node["x2"].get_value<int>() * TILE_SIZE;
|
||||
enemy.x2 = bounds_node["x2"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
if (bounds_node.contains("y2")) {
|
||||
enemy.y2 = bounds_node["y2"].get_value<int>() * TILE_SIZE;
|
||||
enemy.y2 = bounds_node["y2"].get_value<int>() * Tile::SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,10 +197,10 @@ auto RoomLoader::parseEnemyData(const fkyaml::node& enemy_node) -> Enemy::Data {
|
||||
if (enemy_node.contains("position")) {
|
||||
const auto& pos = enemy_node["position"];
|
||||
if (pos.contains("x")) {
|
||||
enemy.x = pos["x"].get_value<float>() * TILE_SIZE;
|
||||
enemy.x = pos["x"].get_value<float>() * Tile::SIZE;
|
||||
}
|
||||
if (pos.contains("y")) {
|
||||
enemy.y = pos["y"].get_value<float>() * TILE_SIZE;
|
||||
enemy.y = pos["y"].get_value<float>() * Tile::SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,10 +276,10 @@ auto RoomLoader::parseItemData(const fkyaml::node& item_node, const Room::Data&
|
||||
if (item_node.contains("position")) {
|
||||
const auto& pos = item_node["position"];
|
||||
if (pos.contains("x")) {
|
||||
item.x = pos["x"].get_value<float>() * TILE_SIZE;
|
||||
item.x = pos["x"].get_value<float>() * Tile::SIZE;
|
||||
}
|
||||
if (pos.contains("y")) {
|
||||
item.y = pos["y"].get_value<float>() * TILE_SIZE;
|
||||
item.y = pos["y"].get_value<float>() * Tile::SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Scoreboard::Scoreboard(std::shared_ptr<Data> data)
|
||||
: item_surface_(Resource::Cache::get()->getSurface("items.gif")),
|
||||
data_(std::move(std::move(data))) {
|
||||
const float SURFACE_WIDTH = Options::game.width;
|
||||
constexpr float SURFACE_HEIGHT = 6.0F * TILE_SIZE;
|
||||
constexpr float SURFACE_HEIGHT = 6.0F * Tile::SIZE;
|
||||
|
||||
// Reserva memoria para los objetos
|
||||
const auto& player_animation_data = Resource::Cache::get()->getAnimationData(Options::cheats.alternate_skin == Options::Cheat::State::ENABLED ? "player2.yaml" : "player.yaml");
|
||||
@@ -130,8 +130,8 @@ void Scoreboard::fillTexture() {
|
||||
surface_->clear(stringToColor("black"));
|
||||
|
||||
// Anclas
|
||||
constexpr int LINE1 = TILE_SIZE;
|
||||
constexpr int LINE2 = 3 * TILE_SIZE;
|
||||
constexpr int LINE1 = Tile::SIZE;
|
||||
constexpr int LINE2 = 3 * Tile::SIZE;
|
||||
|
||||
// Dibuja las vidas
|
||||
// Calcular desplazamiento basado en tiempo
|
||||
@@ -149,21 +149,21 @@ void Scoreboard::fillTexture() {
|
||||
if (data_->music) {
|
||||
const Uint8 C = data_->color;
|
||||
SDL_FRect clip = {0, 8, 8, 8};
|
||||
item_surface_->renderWithColorReplace(20 * TILE_SIZE, LINE2, 1, C, &clip);
|
||||
item_surface_->renderWithColorReplace(20 * Tile::SIZE, LINE2, 1, C, &clip);
|
||||
}
|
||||
|
||||
// Escribe los textos
|
||||
auto text = Resource::Cache::get()->getText("smb2");
|
||||
const std::string TIME_TEXT = std::to_string((clock_.minutes % 100) / 10) + std::to_string(clock_.minutes % 10) + clock_.separator + std::to_string((clock_.seconds % 60) / 10) + std::to_string(clock_.seconds % 10);
|
||||
const std::string ITEMS_TEXT = std::to_string(data_->items / 100) + std::to_string((data_->items % 100) / 10) + std::to_string(data_->items % 10);
|
||||
text->writeColored(TILE_SIZE, LINE1, "Items collected ", data_->color);
|
||||
text->writeColored(17 * TILE_SIZE, LINE1, ITEMS_TEXT, items_color_);
|
||||
text->writeColored(20 * TILE_SIZE, LINE1, " Time ", data_->color);
|
||||
text->writeColored(26 * TILE_SIZE, LINE1, TIME_TEXT, stringToColor("white"));
|
||||
text->writeColored(Tile::SIZE, LINE1, "Items collected ", data_->color);
|
||||
text->writeColored(17 * Tile::SIZE, LINE1, ITEMS_TEXT, items_color_);
|
||||
text->writeColored(20 * Tile::SIZE, LINE1, " Time ", data_->color);
|
||||
text->writeColored(26 * Tile::SIZE, LINE1, TIME_TEXT, stringToColor("white"));
|
||||
|
||||
const std::string ROOMS_TEXT = std::to_string(data_->rooms / 100) + std::to_string((data_->rooms % 100) / 10) + std::to_string(data_->rooms % 10);
|
||||
text->writeColored(22 * TILE_SIZE, LINE2, "Rooms", stringToColor("white"));
|
||||
text->writeColored(28 * TILE_SIZE, LINE2, ROOMS_TEXT, stringToColor("white"));
|
||||
text->writeColored(22 * Tile::SIZE, LINE2, "Rooms", stringToColor("white"));
|
||||
text->writeColored(28 * Tile::SIZE, LINE2, ROOMS_TEXT, stringToColor("white"));
|
||||
|
||||
// Deja el renderizador como estaba
|
||||
Screen::get()->setRendererSurface(previuos_renderer);
|
||||
|
||||
@@ -17,7 +17,7 @@ TilemapRenderer::TilemapRenderer(std::vector<int> tile_map, int tile_set_width,
|
||||
bg_color_(std::move(bg_color)),
|
||||
conveyor_belt_direction_(conveyor_belt_direction) {
|
||||
// Crear la surface del mapa
|
||||
map_surface_ = std::make_shared<Surface>(PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT);
|
||||
map_surface_ = std::make_shared<Surface>(PlayArea::WIDTH, PlayArea::HEIGHT);
|
||||
}
|
||||
|
||||
// Inicializa el renderizador
|
||||
@@ -42,7 +42,7 @@ void TilemapRenderer::update(float delta_time) {
|
||||
// Renderiza el mapa completo en pantalla
|
||||
void TilemapRenderer::render() {
|
||||
// Dibuja la textura con el mapa en pantalla
|
||||
SDL_FRect dest = {0, 0, PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT};
|
||||
SDL_FRect dest = {0, 0, PlayArea::WIDTH, PlayArea::HEIGHT};
|
||||
map_surface_->render(nullptr, &dest);
|
||||
|
||||
// Dibuja los tiles animados
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <string> // Para string
|
||||
#include <vector> // Para vector
|
||||
|
||||
#include "utils/defines.hpp"
|
||||
|
||||
class Surface;
|
||||
class SurfaceSprite;
|
||||
class CollisionMap;
|
||||
@@ -29,8 +31,7 @@ class TilemapRenderer {
|
||||
* @param bg_color Color de fondo de la habitación (como string)
|
||||
* @param conveyor_belt_direction Dirección de las cintas transportadoras (-1, 0, +1)
|
||||
*/
|
||||
TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface,
|
||||
std::string bg_color, int conveyor_belt_direction);
|
||||
TilemapRenderer(std::vector<int> tile_map, int tile_set_width, std::shared_ptr<Surface> tileset_surface, std::string bg_color, int conveyor_belt_direction);
|
||||
~TilemapRenderer() = default;
|
||||
|
||||
// Prohibir copia y movimiento
|
||||
@@ -89,29 +90,29 @@ class TilemapRenderer {
|
||||
};
|
||||
|
||||
// === Constantes ===
|
||||
static constexpr int TILE_SIZE = 8; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = 32; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = 16; // Alto del mapa en tiles
|
||||
static constexpr int PLAY_AREA_WIDTH = 256; // Ancho del área de juego en pixels
|
||||
static constexpr int PLAY_AREA_HEIGHT = 128; // Alto del área de juego en pixels
|
||||
static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame (3 frames @ 60fps)
|
||||
static constexpr int TILE_SIZE = Tile::SIZE; // Ancho del tile en pixels
|
||||
static constexpr int MAP_WIDTH = PlayArea::WIDTH / Tile::SIZE; // Ancho del mapa en tiles
|
||||
static constexpr int MAP_HEIGHT = PlayArea::HEIGHT / Tile::SIZE; // Alto del mapa en tiles
|
||||
static constexpr int PLAY_AREA_WIDTH = PlayArea::WIDTH; // Ancho del área de juego en pixels
|
||||
static constexpr int PLAY_AREA_HEIGHT = PlayArea::HEIGHT; // Alto del área de juego en pixels
|
||||
static constexpr float CONVEYOR_FRAME_DURATION = 0.05F; // Duración de cada frame (3 frames @ 60fps)
|
||||
|
||||
// === Datos de la habitación ===
|
||||
std::vector<int> tile_map_; // Índices de tiles de la habitación
|
||||
int tile_set_width_; // Ancho del tileset en tiles
|
||||
std::shared_ptr<Surface> tileset_surface_; // Gráficos del tileset
|
||||
std::string bg_color_; // Color de fondo
|
||||
int conveyor_belt_direction_; // Dirección de conveyor belts
|
||||
std::vector<int> tile_map_; // Índices de tiles de la habitación
|
||||
int tile_set_width_; // Ancho del tileset en tiles
|
||||
std::shared_ptr<Surface> tileset_surface_; // Gráficos del tileset
|
||||
std::string bg_color_; // Color de fondo
|
||||
int conveyor_belt_direction_; // Dirección de conveyor belts
|
||||
|
||||
// === Renderizado ===
|
||||
std::shared_ptr<Surface> map_surface_; // Textura para el mapa de la habitación
|
||||
std::vector<AnimatedTile> animated_tiles_; // Tiles animados (conveyor belts)
|
||||
float time_accumulator_{0.0F}; // Acumulador de tiempo para animaciones
|
||||
bool is_paused_{false}; // Indica si está en modo pausa
|
||||
std::shared_ptr<Surface> map_surface_; // Textura para el mapa de la habitación
|
||||
std::vector<AnimatedTile> animated_tiles_; // Tiles animados (conveyor belts)
|
||||
float time_accumulator_{0.0F}; // Acumulador de tiempo para animaciones
|
||||
bool is_paused_{false}; // Indica si está en modo pausa
|
||||
|
||||
// === Métodos privados ===
|
||||
void fillMapTexture(const CollisionMap* collision_map); // Pinta el mapa estático y debug lines
|
||||
void setAnimatedTiles(const CollisionMap* collision_map); // Localiza todos los tiles animados
|
||||
void updateAnimatedTiles(); // Actualiza tiles animados
|
||||
void renderAnimatedTiles(); // Renderiza tiles animados
|
||||
void fillMapTexture(const CollisionMap* collision_map); // Pinta el mapa estático y debug lines
|
||||
void setAnimatedTiles(const CollisionMap* collision_map); // Localiza todos los tiles animados
|
||||
void updateAnimatedTiles(); // Actualiza tiles animados
|
||||
void renderAnimatedTiles(); // Renderiza tiles animados
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user