From ec29a2362bb1a2ce769f23d58a94538e5b702628 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 25 Nov 2025 22:54:57 +0100 Subject: [PATCH] provant a 320x200 --- config/assets.yaml | 2 + data/room/04.yaml | 85 ++++++++++++++++++++++++++++ source/game/defaults.hpp | 6 +- source/game/entities/player.hpp | 8 +-- source/game/gameplay/room_loader.hpp | 6 +- source/game/gameplay/scoreboard.cpp | 6 +- source/game/scenes/game.cpp | 6 +- source/utils/defines.hpp | 18 +++--- 8 files changed, 112 insertions(+), 25 deletions(-) create mode 100644 data/room/04.yaml diff --git a/config/assets.yaml b/config/assets.yaml index b858c04..78713ab 100644 --- a/config/assets.yaml +++ b/config/assets.yaml @@ -57,6 +57,8 @@ assets: rooms: - type: ROOM path: ${PREFIX}/data/room/03.yaml + - type: ROOM + path: ${PREFIX}/data/room/04.yaml # TILESETS tilesets: diff --git a/data/room/04.yaml b/data/room/04.yaml new file mode 100644 index 0000000..092fced --- /dev/null +++ b/data/room/04.yaml @@ -0,0 +1,85 @@ +# VOID MAIN +room: + name: "VOID MAIN" + bgColor: blue + border: mauve + tileSetFile: standard.gif + + # Conexiones de la habitación (null = sin conexión) + connections: + up: null + down: null + left: null + right: null + + # Colores de los objetos + itemColor1: magenta + itemColor2: pastel_magenta + + # Dirección de la cinta transportadora: left, none, right + conveyorBelt: left + +# Tilemap: 20 filas x 40 columnas (320x160 pixeles @ 8px/tile) +# Indices de tiles (-1 = vacio) +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, 33, 33, 33, -1, -1, -1, -1, -1] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 33, -1, 70, 71, -1, -1, 33] + - [33, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 259, -1, -1, -1, -1, -1, -1, 259, -1, -1, 33, -1, 94, 95, -1, -1, 33] + - [33, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, 33] + - [33, 30, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 141, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 364, 364, 364, 364, 364, 364, 364, 364, 364, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 174, 174, 174, 174, 174, -1, -1, -1, -1, -1, -1, 292, 292, 292, 292, 292, 292, 292, 292, 292, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 262, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, -1, -1, -1, -1, -1, -1, 286, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 133] + - [33, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, 294, -1, -1, -1, -1, -1, -1, 286, -1, -1, -1, -1, -1, -1, -1, 141, -1, -1, -1, -1, -1, -1, -1, -1, -1, 133] + - [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 286, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, -1, -1, -1, -1, 380, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 310, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33] + - [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33] + +# Collisionmap: 20 filas x 40 columnas +# Indices de colision (-1 = vacio, 1 = solido, 2 = plataforma) +collisionmap: + - [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, -1, -1, -1, -1, -1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, -1, -1, -1, -1, -1, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, 1] + - [1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1] + - [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] + +# Enemigos en esta habitación +enemies: + - animation: code.yaml + position: {x: 1, y: 17} + velocity: {x: 24.0, y: 0} + boundaries: + position1: {x: 1, y: 17} + position2: {x: 16, y: 17} + color: yellow + +# Objetos en esta habitación +items: + - tileSetFile: items.gif + tile: 42 + position: {x: 25, y: 7} + counter: 1 diff --git a/source/game/defaults.hpp b/source/game/defaults.hpp index e19b6bf..fdc4aad 100644 --- a/source/game/defaults.hpp +++ b/source/game/defaults.hpp @@ -17,7 +17,7 @@ namespace Defaults { // Dimensiones del canvas del juego (usa GameCanvas como fuente única) namespace Canvas { constexpr int WIDTH = GameCanvas::WIDTH; // Ancho del canvas del juego (320) -constexpr int HEIGHT = GameCanvas::HEIGHT; // Alto del canvas del juego (240) +constexpr int HEIGHT = GameCanvas::HEIGHT; // Alto del canvas del juego (200) } // namespace Canvas // --- WINDOW --- @@ -39,8 +39,8 @@ constexpr const char* PALETTE_NAME = "cpc"; // Paleta por defect // --- BORDER --- namespace Border { constexpr bool ENABLED = true; // Borde activado por defecto -constexpr int WIDTH = 32; // Ancho del borde por defecto -constexpr int HEIGHT = 24; // Alto del borde por defecto +constexpr int WIDTH = 40; // Ancho del borde por defecto (400x300 total) +constexpr int HEIGHT = 50; // Alto del borde por defecto (400x300 total) } // namespace Border // --- AUDIO --- diff --git a/source/game/entities/player.hpp b/source/game/entities/player.hpp index f7c7e27..661139d 100644 --- a/source/game/entities/player.hpp +++ b/source/game/entities/player.hpp @@ -16,6 +16,10 @@ class Player { public: + // --- Constantes de tamaño --- + static constexpr int WIDTH = 8; // Ancho del jugador en pixels + static constexpr int HEIGHT = 16; // Alto del jugador en pixels + // --- Enums y Structs --- enum class State { ON_GROUND, // En suelo plano o conveyor belt @@ -72,10 +76,6 @@ class Player { #endif private: - // --- Constantes de tamaño --- - static constexpr int WIDTH = 8; // Ancho del jugador en pixels - static constexpr int HEIGHT = 16; // Alto del jugador en pixels - // --- Constantes de movimiento horizontal --- static constexpr float WALK_VELOCITY = 50.0F; // Velocidad al caminar (inmediata) en pixels/segundo static constexpr float RUN_VELOCITY = 80.0F; // Velocidad al correr en pixels/segundo diff --git a/source/game/gameplay/room_loader.hpp b/source/game/gameplay/room_loader.hpp index ab3865c..d27c262 100644 --- a/source/game/gameplay/room_loader.hpp +++ b/source/game/gameplay/room_loader.hpp @@ -41,7 +41,7 @@ class RoomLoader { * * El formato YAML esperado incluye: * - room: configuración general - * - tilemap: array 2D de 24x40 tiles (convertido a vector 1D de 960 elementos) + * - tilemap: array 2D de 20x40 tiles (convertido a vector 1D de 800 elementos) * - enemies: lista de enemigos (opcional) * - items: lista de items (opcional) */ @@ -64,8 +64,8 @@ class RoomLoader { /** * @brief Convierte un tilemap 2D a vector 1D flat - * @param tilemap_2d Array 2D de tiles (24 rows × 40 cols) - * @return Vector 1D flat con 960 elementos + * @param tilemap_2d Array 2D de tiles (20 rows × 40 cols) + * @return Vector 1D flat con 800 elementos */ static auto flattenTilemap(const std::vector>& tilemap_2d) -> std::vector; diff --git a/source/game/gameplay/scoreboard.cpp b/source/game/gameplay/scoreboard.cpp index c6e2be7..93697cb 100644 --- a/source/game/gameplay/scoreboard.cpp +++ b/source/game/gameplay/scoreboard.cpp @@ -129,9 +129,9 @@ void Scoreboard::fillTexture() { // Limpia la textura surface_->clear(stringToColor("black")); - // Anclas - constexpr int LINE1 = Tile::SIZE; - constexpr int LINE2 = 3 * Tile::SIZE; + // Anclas (ajustadas para scoreboard de 40px) + constexpr int LINE1 = 6; // Reducido de 8 para ajuste proporcional + constexpr int LINE2 = 20; // Reducido de 24 para ajuste proporcional // Dibuja las vidas // Calcular desplazamiento basado en tiempo diff --git a/source/game/scenes/game.cpp b/source/game/scenes/game.cpp index 0d99aae..4922f9d 100644 --- a/source/game/scenes/game.cpp +++ b/source/game/scenes/game.cpp @@ -38,10 +38,10 @@ Game::Game(Mode mode) room_tracker_(std::make_shared()), mode_(mode), #ifdef _DEBUG - current_room_("03.yaml"), - spawn_data_(Player::SpawnData(25 * Tile::SIZE, 21 * Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT)) + current_room_("04.yaml"), + spawn_data_(Player::SpawnData(25 * Tile::SIZE, PlayArea::BOTTOM - Player::HEIGHT - Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT)) #else - current_room_("03.yaml"), + current_room_("04.yaml"), spawn_data_(Player::SpawnData(25 * Tile::SIZE, 21 * Tile::SIZE, 0, 0, 0, Player::State::ON_GROUND, Flip::LEFT)) #endif { diff --git a/source/utils/defines.hpp b/source/utils/defines.hpp index f73c008..dcd0213 100644 --- a/source/utils/defines.hpp +++ b/source/utils/defines.hpp @@ -10,7 +10,7 @@ constexpr int HALF_SIZE = SIZE / 2; namespace GameCanvas { constexpr int WIDTH = 320; -constexpr int HEIGHT = 240; +constexpr int HEIGHT = 200; constexpr int CENTER_X = WIDTH / 2; constexpr int FIRST_QUARTER_X = WIDTH / 4; constexpr int THIRD_QUARTER_X = (WIDTH / 4) * 3; @@ -26,22 +26,22 @@ constexpr int Y = 0; // Dimensiones en tiles constexpr int TILE_COLS = 40; // Ancho del mapa en tiles -constexpr int TILE_ROWS = 24; // Alto del mapa en tiles -constexpr int TILE_COUNT = TILE_COLS * TILE_ROWS; // 960 tiles totales +constexpr int TILE_ROWS = 20; // Alto del mapa en tiles +constexpr int TILE_COUNT = TILE_COLS * TILE_ROWS; // 800 tiles totales // Dimensiones en pixels constexpr int WIDTH = TILE_COLS * Tile::SIZE; // 320 -constexpr int HEIGHT = TILE_ROWS * Tile::SIZE; // 192 +constexpr int HEIGHT = TILE_ROWS * Tile::SIZE; // 160 // Bordes (derivados, útiles para colisiones) constexpr int LEFT = X; constexpr int TOP = Y; constexpr int RIGHT = X + WIDTH; // 320 -constexpr int BOTTOM = Y + HEIGHT; // 192 +constexpr int BOTTOM = Y + HEIGHT; // 160 // Puntos de referencia constexpr int CENTER_X = X + (WIDTH / 2); // 160 -constexpr int CENTER_Y = Y + (HEIGHT / 2); // 96 +constexpr int CENTER_Y = Y + (HEIGHT / 2); // 80 constexpr int QUARTER_X = WIDTH / 4; constexpr int QUARTER_Y = HEIGHT / 4; } // namespace PlayArea @@ -49,17 +49,17 @@ constexpr int QUARTER_Y = HEIGHT / 4; namespace ScoreboardArea { // Origen (justo debajo de PlayArea) constexpr int X = 0; -constexpr int Y = PlayArea::BOTTOM; // 192 +constexpr int Y = PlayArea::BOTTOM; // 160 // Dimensiones constexpr int WIDTH = GameCanvas::WIDTH; // 320 -constexpr int HEIGHT = (6 * Tile::SIZE); // 48 +constexpr int HEIGHT = (5 * Tile::SIZE); // 40 // Bordes constexpr int LEFT = X; constexpr int TOP = Y; constexpr int RIGHT = X + WIDTH; -constexpr int BOTTOM = Y + HEIGHT; // 240 +constexpr int BOTTOM = Y + HEIGHT; // 200 } // namespace ScoreboardArea namespace Collision {