5 float offsetX = (width * tileSize) / 2.0f;
6 float offsetZ = (height * tileSize) / 2.0f;
8 for (
int x = 0; x < width; x++) {
9 for (
int z = 0; z < height; z++) {
10 float cx = x * tileSize - offsetX + tileSize / 2.0f;
11 float cz = z * tileSize - offsetZ + tileSize / 2.0f;
13 DrawCube({cx, -0.01f, cz}, tileSize, 0.001f, tileSize, c);
20 float offsetX = (width * tileSize) / 2.0f;
21 float offsetZ = (height * tileSize) / 2.0f;
24 for (
int x = 0; x <= width; x++) {
25 DrawLine3D({x * tileSize - offsetX, 0.0f, -offsetZ},
26 {x * tileSize - offsetX, 0.0f, height * tileSize - offsetZ}, color);
30 for (
int z = 0; z <= height; z++) {
31 DrawLine3D({-offsetX, 0.0f, z * tileSize - offsetZ},
32 {width * tileSize - offsetX, 0.0f, z * tileSize - offsetZ}, color);
37 float tileSize, Color color,
float lineThickness)
39 float offsetX = (worldWidth * tileSize) / 2.0f;
40 float offsetZ = (worldHeight * tileSize) / 2.0f;
46 float x0 = tileX * tileSize - offsetX;
47 float x1 = (tileX + 1) * tileSize - offsetX;
48 float z0 = tileY * tileSize - offsetZ;
49 float z1 = (tileY + 1) * tileSize - offsetZ;
51 float thickness = lineThickness * 0.01f;
54 DrawCube({(x0 + x1) / 2.0f, y, z0}, x1 - x0, 0.001f, thickness, color);
55 DrawCube({(x0 + x1) / 2.0f, y, z1}, x1 - x0, 0.001f, thickness, color);
56 DrawCube({x0, y, (z0 + z1) / 2.0f}, thickness, 0.001f, z1 - z0, color);
57 DrawCube({x1, y, (z0 + z1) / 2.0f}, thickness, 0.001f, z1 - z0, color);
static void drawGrid(int width, int height, float tileSize, Color color=GRAY)
Draws a custom grid centered at (0, 0, 0).
static void drawTileHighlight(int tileX, int tileY, int worldWidth, int worldHeight, float tileSize, Color color, float lineThickness=1.0f)
Draws a highlight outline around a specific tile.