fix: bug en el editor al crear habitacions noves
This commit is contained in:
@@ -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:
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 583 B After Width: | Height: | Size: 672 B |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
43
data/room/04.yaml
Normal file
43
data/room/04.yaml
Normal file
@@ -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]
|
||||
@@ -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) {
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <unordered_map> // Para unordered_map
|
||||
#include <vector> // 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> surface; // 32x16 pixels
|
||||
std::shared_ptr<Surface> 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);
|
||||
|
||||
@@ -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.
|
||||
if (state_ == State::ON_AIR) {
|
||||
// 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) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user