diff --git a/config/assets.yaml b/config/assets.yaml index 90622c5..6fe37a8 100644 --- a/config/assets.yaml +++ b/config/assets.yaml @@ -69,6 +69,7 @@ assets: - ${PREFIX}/data/room/01.yaml - ${PREFIX}/data/room/02.yaml - ${PREFIX}/data/room/03.yaml + - ${PREFIX}/data/room/04.yaml # TILESETS tilesets: diff --git a/data/player/player.gif b/data/player/player.gif index f9b5306..5ec8ae3 100644 Binary files a/data/player/player.gif and b/data/player/player.gif differ diff --git a/data/player/player.yaml b/data/player/player.yaml index 4a7051c..e209022 100644 --- a/data/player/player.yaml +++ b/data/player/player.yaml @@ -12,7 +12,7 @@ animations: - name: default speed: 0.07 loop: 0 - frames: [0, 1, 2, 3] + frames: [1, 2, 3, 0] - name: jump speed: 0 diff --git a/data/room/02.yaml b/data/room/02.yaml index a11f74a..7bc6c15 100644 --- a/data/room/02.yaml +++ b/data/room/02.yaml @@ -6,7 +6,7 @@ room: # Conexiones de la habitación (null = sin conexión) connections: up: null - down: 04.yaml + down: null left: 01.yaml right: 03.yaml diff --git a/data/room/03.yaml b/data/room/03.yaml index 3366bf7..2394889 100644 --- a/data/room/03.yaml +++ b/data/room/03.yaml @@ -5,7 +5,7 @@ room: # Conexiones de la habitación (null = sin conexión) connections: - up: null + up: 04.yaml down: null left: 02.yaml right: null @@ -24,7 +24,7 @@ tilemap: - [48, 50, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - - [0, 2, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, -1, -1, 504, 6, 7, 7, 7, 7, 7, 24, 26] + - [0, 2, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, -1, -1, -1, -1, 504, 6, 7, 7, 7, 7, 7, 24, 26] - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] - [24, 26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 504, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 26] @@ -49,7 +49,7 @@ enemies: velocity: {x: 24, y: 0} boundaries: position1: {x: 3, y: 2} - position2: {x: 27, y: 2} + position2: {x: 11, y: 2} color: 12 # Objetos en esta habitación diff --git a/data/room/04.yaml b/data/room/04.yaml new file mode 100644 index 0000000..ac32dcb --- /dev/null +++ b/data/room/04.yaml @@ -0,0 +1,43 @@ +room: + bgColor: 34 + border: 0 + tileSetFile: standard.gif + + # Conexiones de la habitación (null = sin conexión) + connections: + up: null + down: 03.yaml + left: null + right: null + + # Colores de los objetos + itemColor1: 0 + itemColor2: 0 + + # Dirección de la cinta transportadora: left, none, right + conveyorBelt: none + +# Tilemap: 21 filas x 32 columnas @ 8px/tile +# Índices de tiles (-1 = vacío) +tilemap: + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1] diff --git a/source/core/resources/resource_list.cpp b/source/core/resources/resource_list.cpp index 8beb464..fef3b8a 100644 --- a/source/core/resources/resource_list.cpp +++ b/source/core/resources/resource_list.cpp @@ -66,7 +66,7 @@ namespace Resource { // Construir la ruta con variable ${PREFIX} (invertir la sustitución) std::string var_path = path; - if (!prefix_.empty() && !executable_path_.empty()) { + if (!executable_path_.empty()) { std::string full_prefix = executable_path_ + prefix_; auto pos = var_path.find(full_prefix); if (pos != std::string::npos) { @@ -111,7 +111,7 @@ namespace Resource { // Construir la ruta con variable ${PREFIX} std::string var_path = file_path; - if (!prefix_.empty() && !executable_path_.empty()) { + if (!executable_path_.empty()) { std::string full_prefix = executable_path_ + prefix_; auto pos = var_path.find(full_prefix); if (pos != std::string::npos) { diff --git a/source/game/editor/map_editor.cpp b/source/game/editor/map_editor.cpp index ce524f5..ddbb5e7 100644 --- a/source/game/editor/map_editor.cpp +++ b/source/game/editor/map_editor.cpp @@ -1328,7 +1328,7 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { // new_room.left_room = "0"; new_room.right_room = "0"; new_room.conveyor_belt_direction = 0; - new_room.tile_map.resize(32 * 16, -1); + new_room.tile_map.resize(Map::WIDTH * Map::HEIGHT, -1); // Conexión recíproca: la nueva room conecta de vuelta a la actual if (direction == "UP") { @@ -1368,11 +1368,11 @@ auto MapEditor::createNewRoom(const std::string& direction) -> std::string { // file << " conveyorBelt: none\n"; file << "\n"; file << "tilemap:\n"; - for (int row = 0; row < 16; ++row) { + for (int row = 0; row < Map::HEIGHT; ++row) { file << " - ["; - for (int col = 0; col < 32; ++col) { + for (int col = 0; col < Map::WIDTH; ++col) { file << "-1"; - if (col < 31) { file << ", "; } + if (col < Map::WIDTH - 1) { file << ", "; } } file << "]\n"; } diff --git a/source/game/editor/mini_map.hpp b/source/game/editor/mini_map.hpp index 68bcfc6..ba56639 100644 --- a/source/game/editor/mini_map.hpp +++ b/source/game/editor/mini_map.hpp @@ -10,6 +10,8 @@ #include // Para unordered_map #include // Para vector +#include "utils/defines.hpp" // Para Map::WIDTH, Map::HEIGHT + class Surface; /** @@ -18,7 +20,7 @@ class Surface; * Genera una vista en miniatura de todas las habitaciones del juego, * posicionadas según sus conexiones. * Cada tile del mapa se representa como 1 pixel del color predominante de ese tile. - * Resultado: cada room = 32x16 pixels. + * Resultado: cada room = Map::WIDTH x Map::HEIGHT pixels. */ class MiniMap { public: @@ -43,7 +45,7 @@ class MiniMap { // Una room renderizada struct RoomMini { - std::shared_ptr surface; // 32x16 pixels + std::shared_ptr surface; // ROOM_W x ROOM_H pixels GridPos pos; // Posición en el grid }; @@ -84,8 +86,8 @@ class MiniMap { float view_start_y_{0.0F}; // Constantes - static constexpr int ROOM_W = 32; // Ancho de una room en pixels del minimapa - static constexpr int ROOM_H = 16; // Alto de una room en pixels del minimapa + static constexpr int ROOM_W = Map::WIDTH; // Ancho de una room en pixels del minimapa (1 pixel por tile) + static constexpr int ROOM_H = Map::HEIGHT; // Alto de una room en pixels del minimapa (1 pixel por tile) static constexpr int BORDER = 1; // Borde alrededor de cada room static constexpr int CELL_W = ROOM_W + (BORDER * 2); // Room + borde static constexpr int CELL_H = ROOM_H + (BORDER * 2); diff --git a/source/game/entities/player.cpp b/source/game/entities/player.cpp index e6307df..4ecd0b7 100644 --- a/source/game/entities/player.cpp +++ b/source/game/entities/player.cpp @@ -691,16 +691,24 @@ void Player::updateVelocity(float delta_time) { if (target > 0.0F) { sprite_->setFlip(Flip::RIGHT); } else if (target < 0.0F) { sprite_->setFlip(Flip::LEFT); } - // En el aire: inercia (interpolación gradual). En suelo/rampa: respuesta inmediata. + // Inercia: + // - En el aire: inercia completa (arranque y frenada graduales) + // - En suelo/rampa: arranque instantáneo, frenada gradual + const float STEP = HORIZONTAL_ACCEL * delta_time; if (state_ == State::ON_AIR) { - const float STEP = HORIZONTAL_ACCEL * delta_time; if (vx_ < target) { vx_ = std::min(vx_ + STEP, target); } else if (vx_ > target) { vx_ = std::max(vx_ - STEP, target); } } else { - vx_ = target; + if (target != 0.0F) { + vx_ = target; // Arranque instantáneo + } else if (vx_ > 0.0F) { + vx_ = std::max(vx_ - STEP, 0.0F); // Frenada gradual + } else if (vx_ < 0.0F) { + vx_ = std::min(vx_ + STEP, 0.0F); // Frenada gradual + } } }