feat(grid): sub-graella amb 5 subdivisions i ajust de brillos

This commit is contained in:
2026-05-21 20:21:46 +02:00
parent f30b195778
commit dc389037f8
2 changed files with 26 additions and 4 deletions
+4 -1
View File
@@ -7,6 +7,9 @@ namespace Defaults::Grid {
constexpr int COLUMNS = 16; // cel·les omplen tota la PLAYAREA: cell_w = w/16 constexpr int COLUMNS = 16; // cel·les omplen tota la PLAYAREA: cell_w = w/16
constexpr int ROWS = 8; // cel·les omplen tota la PLAYAREA: cell_h = h/8 (≈2% més altes que amples) constexpr int ROWS = 8; // cel·les omplen tota la PLAYAREA: cell_h = h/8 (≈2% més altes que amples)
constexpr float BRIGHTNESS = 0.20F; // intensitat respecte al color global (border = 1.0) constexpr float BRIGHTNESS = 0.15F; // intensitat respecte al color global (border = 1.0)
constexpr int SUBDIVISIONS = 5; // cada cel·la principal es divideix en N subcel·les
constexpr float SUBGRID_BRIGHTNESS = 0.05F; // intensitat de la sub-graella
} // namespace Defaults::Grid } // namespace Defaults::Grid
+22 -3
View File
@@ -15,19 +15,38 @@ namespace Graphics {
const SDL_FRect& zona = Defaults::Zones::PLAYAREA; const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
const float CELL_W = zona.w / static_cast<float>(Defaults::Grid::COLUMNS); const float CELL_W = zona.w / static_cast<float>(Defaults::Grid::COLUMNS);
const float CELL_H = zona.h / static_cast<float>(Defaults::Grid::ROWS); const float CELL_H = zona.h / static_cast<float>(Defaults::Grid::ROWS);
const float SUB_W = CELL_W / static_cast<float>(Defaults::Grid::SUBDIVISIONS);
const float SUB_H = CELL_H / static_cast<float>(Defaults::Grid::SUBDIVISIONS);
const int SUB_VERTS = Defaults::Grid::COLUMNS * Defaults::Grid::SUBDIVISIONS;
const int SUB_HORIZ = Defaults::Grid::ROWS * Defaults::Grid::SUBDIVISIONS;
const int X1 = static_cast<int>(zona.x); const int X1 = static_cast<int>(zona.x);
const int Y1 = static_cast<int>(zona.y); const int Y1 = static_cast<int>(zona.y);
const int X2 = static_cast<int>(zona.x + zona.w); const int X2 = static_cast<int>(zona.x + zona.w);
const int Y2 = static_cast<int>(zona.y + zona.h); const int Y2 = static_cast<int>(zona.y + zona.h);
// Línies verticals interiors (i=1..COLUMNS-1: no repetim el border) // PRIMER: sub-graella (queda per dessota — pintem primer).
// Saltem les posicions que coincideixen amb la graella principal (i % SUBDIVISIONS == 0).
for (int i = 1; i < SUB_VERTS; i++) {
if (i % Defaults::Grid::SUBDIVISIONS == 0) {
continue;
}
const int X = static_cast<int>(zona.x + (static_cast<float>(i) * SUB_W));
Rendering::linea(renderer_, X, Y1, X, Y2, Defaults::Grid::SUBGRID_BRIGHTNESS);
}
for (int j = 1; j < SUB_HORIZ; j++) {
if (j % Defaults::Grid::SUBDIVISIONS == 0) {
continue;
}
const int Y = static_cast<int>(zona.y + (static_cast<float>(j) * SUB_H));
Rendering::linea(renderer_, X1, Y, X2, Y, Defaults::Grid::SUBGRID_BRIGHTNESS);
}
// SEGON: graella principal (línies interiors, no repetim el border).
for (int i = 1; i < Defaults::Grid::COLUMNS; i++) { for (int i = 1; i < Defaults::Grid::COLUMNS; i++) {
const int X = static_cast<int>(zona.x + (static_cast<float>(i) * CELL_W)); const int X = static_cast<int>(zona.x + (static_cast<float>(i) * CELL_W));
Rendering::linea(renderer_, X, Y1, X, Y2, Defaults::Grid::BRIGHTNESS); Rendering::linea(renderer_, X, Y1, X, Y2, Defaults::Grid::BRIGHTNESS);
} }
// Línies horitzontals interiors (j=1..ROWS-1: no repetim el border)
for (int j = 1; j < Defaults::Grid::ROWS; j++) { for (int j = 1; j < Defaults::Grid::ROWS; j++) {
const int Y = static_cast<int>(zona.y + (static_cast<float>(j) * CELL_H)); const int Y = static_cast<int>(zona.y + (static_cast<float>(j) * CELL_H));
Rendering::linea(renderer_, X1, Y, X2, Y, Defaults::Grid::BRIGHTNESS); Rendering::linea(renderer_, X1, Y, X2, Y, Defaults::Grid::BRIGHTNESS);