summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-04-14 15:57:35 +0200
committerkdx <kikoodx@paranoici.org>2023-04-14 15:57:35 +0200
commit4ed29d517fa3555472dd3369f816b20b55b536c5 (patch)
tree05db370f41c239d99a1b246fb41b4694dcd9f3fc
parent42a222e998e3693bb59c90b2c4b446c8e8694a5b (diff)
download006-4ed29d517fa3555472dd3369f816b20b55b536c5.tar.gz
goated gridHEADmain
-rw-r--r--map/game.tmj17
-rw-r--r--src/grid.c15
2 files changed, 24 insertions, 8 deletions
diff --git a/map/game.tmj b/map/game.tmj
index 4832f9f..3806d21 100644
--- a/map/game.tmj
+++ b/map/game.tmj
@@ -30,15 +30,26 @@
"y":112
},
{
- "height":8,
+ "height":224,
"id":3,
"name":"grid",
"rotation":0,
"type":"",
"visible":true,
- "width":8,
+ "width":176,
"x":0,
"y":0
+ },
+ {
+ "height":224,
+ "id":4,
+ "name":"grid",
+ "rotation":0,
+ "type":"",
+ "visible":true,
+ "width":176,
+ "x":224,
+ "y":0
}],
"opacity":1,
"type":"objectgroup",
@@ -47,7 +58,7 @@
"y":0
}],
"nextlayerid":3,
- "nextobjectid":4,
+ "nextobjectid":5,
"orientation":"orthogonal",
"renderorder":"right-down",
"tiledversion":"1.10.1",
diff --git a/src/grid.c b/src/grid.c
index f39ebcf..b02d318 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -2,14 +2,19 @@
#include "entity.h"
#include "entityimpl.h"
-IMPL_INIT(grid, 0) {}
+IMPL_INIT(grid, 0) {
+ this->pos[0] -= this->width / 2 + 1;
+ this->pos[1] -= this->height / 2 + 1;
+}
IMPL(draw) {
if (TZR_GetTick() % 2)
return;
TZR_DrawSetColor(1, 1, 1, 1);
- for (int i = 0; i < DHEIGHT; i += TSIZE)
- TZR_DrawLine(-1, i - 1, DWIDTH, i - 1);
- for (int i = 0; i < DWIDTH; i += TSIZE)
- TZR_DrawLine(i - 1, -1, i - 1, DHEIGHT);
+ for (int i = 0; i < this->height; i += TSIZE)
+ TZR_DrawLine(this->pos[0], this->pos[1] + i,
+ this->pos[0] + this->width, this->pos[1] + i);
+ for (int i = 0; i <= this->width; i += TSIZE)
+ TZR_DrawLine(this->pos[0] + i, this->pos[1],
+ this->pos[0] + i, this->pos[1] + this->height);
}