From d0be5ea2d13a0933f93fd58d595875309329b3a5 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Wed, 10 Dec 2025 08:20:43 +0100 Subject: [PATCH] millorades les definicions de zones --- source/core/defaults.hpp | 81 +++++++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/source/core/defaults.hpp b/source/core/defaults.hpp index b269042..d6ee86a 100644 --- a/source/core/defaults.hpp +++ b/source/core/defaults.hpp @@ -22,43 +22,72 @@ constexpr int WIDTH = 640; constexpr int HEIGHT = 480; } // namespace Game -// Zones del joc (SDL_FRect amb càlculs automàtics) +// Zones del joc (SDL_FRect amb càlculs automàtics basat en percentatges) namespace Zones { // --- CONFIGURACIÓ DE PORCENTATGES --- -// Basats en valors originals 640x480 -// Ajusta estos valors per canviar proporcions +// Totes les zones definides com a percentatges de Game::WIDTH (640) i Game::HEIGHT (480) -constexpr float PLAYAREA_MARGIN_HORIZONTAL_PERCENT = 10.0f / Game::WIDTH; -constexpr float PLAYAREA_MARGIN_VERTICAL_PERCENT = 10.0f / Game::HEIGHT; -constexpr float SCOREBOARD_HEIGHT_PERCENT = 48.0f / Game::HEIGHT; +// Percentatges d'alçada (divisió vertical) +constexpr float SCOREBOARD_TOP_HEIGHT_PERCENT = 0.02f; // 10% superior +constexpr float MAIN_PLAYAREA_HEIGHT_PERCENT = 0.88f; // 80% central +constexpr float SCOREBOARD_BOTTOM_HEIGHT_PERCENT = 0.10f; // 10% inferior -// --- CÀLCULS AUTOMÀTICS --- -// Estos valors es recalculen si canvien Game::WIDTH o Game::HEIGHT +// Padding horizontal per a PLAYAREA (dins de MAIN_PLAYAREA) +constexpr float PLAYAREA_PADDING_HORIZONTAL_PERCENT = 0.015f; // 5% a cada costat -constexpr float PLAYAREA_MARGIN_H = - Game::WIDTH * PLAYAREA_MARGIN_HORIZONTAL_PERCENT; -constexpr float PLAYAREA_MARGIN_V = - Game::HEIGHT * PLAYAREA_MARGIN_VERTICAL_PERCENT; -constexpr float SCOREBOARD_H = Game::HEIGHT * SCOREBOARD_HEIGHT_PERCENT; +// --- CÀLCULS AUTOMÀTICS DE PÍXELS --- +// Càlculs automàtics a partir dels percentatges + +// Alçades +constexpr float SCOREBOARD_TOP_H = Game::HEIGHT * SCOREBOARD_TOP_HEIGHT_PERCENT; +constexpr float MAIN_PLAYAREA_H = Game::HEIGHT * MAIN_PLAYAREA_HEIGHT_PERCENT; +constexpr float SCOREBOARD_BOTTOM_H = Game::HEIGHT * SCOREBOARD_BOTTOM_HEIGHT_PERCENT; + +// Posicions Y +constexpr float SCOREBOARD_TOP_Y = 0.0f; +constexpr float MAIN_PLAYAREA_Y = SCOREBOARD_TOP_H; +constexpr float SCOREBOARD_BOTTOM_Y = MAIN_PLAYAREA_Y + MAIN_PLAYAREA_H; + +// Padding horizontal de PLAYAREA +constexpr float PLAYAREA_PADDING_H = Game::WIDTH * PLAYAREA_PADDING_HORIZONTAL_PERCENT; // --- ZONES FINALS (SDL_FRect) --- -// Zona de joc principal -// Ocupa: tot menys marges (dalt, esq, dret) i scoreboard (baix) -constexpr SDL_FRect PLAYAREA = { - PLAYAREA_MARGIN_H, // x = 10.0 - PLAYAREA_MARGIN_V, // y = 10.0 - Game::WIDTH - 2.0f * PLAYAREA_MARGIN_H, // width = 620.0 - Game::HEIGHT - PLAYAREA_MARGIN_V - SCOREBOARD_H // height = 406.0 +// Marcador superior (reservat per a futur ús) +// Ocupa: 10% superior (0-48px) +constexpr SDL_FRect SCOREBOARD_TOP = { + 0.0f, // x = 0.0 + SCOREBOARD_TOP_Y, // y = 0.0 + static_cast(Game::WIDTH), // w = 640.0 + SCOREBOARD_TOP_H // h = 48.0 }; -// Zona de marcador -// Ocupa: tot l'ample, 64px d'alçada en la part inferior +// Àrea de joc principal (contenidor del 80% central, sense padding) +// Ocupa: 10-90% (48-432px), ample complet +constexpr SDL_FRect MAIN_PLAYAREA = { + 0.0f, // x = 0.0 + MAIN_PLAYAREA_Y, // y = 48.0 + static_cast(Game::WIDTH), // w = 640.0 + MAIN_PLAYAREA_H // h = 384.0 +}; + +// Zona de joc real (amb padding horizontal del 5%) +// Ocupa: dins de MAIN_PLAYAREA, amb marges laterals +// S'utilitza per a límits del joc, col·lisions, spawn +constexpr SDL_FRect PLAYAREA = { + PLAYAREA_PADDING_H, // x = 32.0 + MAIN_PLAYAREA_Y, // y = 48.0 (igual que MAIN_PLAYAREA) + Game::WIDTH - 2.0f * PLAYAREA_PADDING_H, // w = 576.0 + MAIN_PLAYAREA_H // h = 384.0 (igual que MAIN_PLAYAREA) +}; + +// Marcador inferior (marcador actual) +// Ocupa: 10% inferior (432-480px) constexpr SDL_FRect SCOREBOARD = { - 0.0f, // x = 0.0 - Game::HEIGHT - SCOREBOARD_H, // y = 416.0 - static_cast(Game::WIDTH), // width = 640.0 - SCOREBOARD_H // height = 64.0 + 0.0f, // x = 0.0 + SCOREBOARD_BOTTOM_Y, // y = 432.0 + static_cast(Game::WIDTH), // w = 640.0 + SCOREBOARD_BOTTOM_H // h = 48.0 }; } // namespace Zones