feat(grid): graella verda fosca de fons al playfield (16x8)

This commit is contained in:
JailDesigner committed 2026-05-21 20:16:44 +02:00
1 parent 95ac4606d5
commit f30b195778
6 files changed
+82 -1

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
// playfield_grid.cpp - Implementació de la grilla de fons
// © 2026 JailDesigner
#include "core/graphics/playfield_grid.hpp"
#include "core/defaults.hpp"
#include "core/rendering/line_renderer.hpp"
namespace Graphics {
PlayfieldGrid::PlayfieldGrid(Rendering::Renderer* renderer)
: renderer_(renderer) {}
void PlayfieldGrid::draw() const {
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
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 int X1 = static_cast<int>(zona.x);
const int Y1 = static_cast<int>(zona.y);
const int X2 = static_cast<int>(zona.x + zona.w);
const int Y2 = static_cast<int>(zona.y + zona.h);
// Línies verticals interiors (i=1..COLUMNS-1: no repetim el border)
for (int i = 1; i < Defaults::Grid::COLUMNS; i++) {
const int X = static_cast<int>(zona.x + (static_cast<float>(i) * CELL_W));
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++) {
const int Y = static_cast<int>(zona.y + (static_cast<float>(j) * CELL_H));
Rendering::linea(renderer_, X1, Y, X2, Y, Defaults::Grid::BRIGHTNESS);
}
}
} // namespace Graphics
+23
View File
@@ -0,0 +1,23 @@
// playfield_grid.hpp - Grilla de fons del playfield (línies verdes fosques)
// © 2026 JailDesigner
#pragma once
#include "core/rendering/render_context.hpp"
namespace Graphics {
// Pinta una graella interior dins de Defaults::Zones::PLAYAREA.
// Cel·les quadrades; el nombre de columnes és fix (Defaults::Grid::COLUMNS),
// les files es deriven del que cap dins de l'altura.
// Color: oscil·lador global (mateix to que el border); brightness fixa al 25%.
class PlayfieldGrid {
public:
explicit PlayfieldGrid(Rendering::Renderer* renderer);
void draw() const;
private:
Rendering::Renderer* renderer_;
};
} // namespace Graphics