summaryrefslogtreecommitdiff
path: root/src/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/map.c b/src/map.c
index a2227d0..f98cfe6 100644
--- a/src/map.c
+++ b/src/map.c
@@ -1,6 +1,4 @@
-Map *
-map_new(const Tiled2cMap *t2c)
-{
+Map *map_new(const Tiled2cMap *t2c) {
assert(t2c != nullptr);
Map *this = alloc(sizeof(Map));
@@ -10,9 +8,7 @@ map_new(const Tiled2cMap *t2c)
return this;
}
-bool
-map_get_px(Map *this, int x, int y, u32 type)
-{
+bool map_get_px(Map *this, int x, int y, u32 type) {
assert(this != nullptr);
if (x < 0 || y < 0)
return type == TILE_NONE;
@@ -20,7 +16,7 @@ map_get_px(Map *this, int x, int y, u32 type)
y /= cfg.tile_height;
if ((u32)x >= this->t2c->width || (u32)y >= this->t2c->height)
return type == TILE_NONE;
- rfor (i, 0u, this->t2c->numlayers) {
+ rfor(i, 0u, this->t2c->numlayers) {
assert(this->t2c->layers->type == 't');
const auto layer = &this->t2c->layers->tilelayer;
const u32 tile = layer->data[x + y * this->t2c->width];
@@ -30,27 +26,25 @@ map_get_px(Map *this, int x, int y, u32 type)
return false;
}
-static void
-_draw_layer(const Tiled2cMap *map, const Tiled2cLayer *this, vec2 off)
-{
+static void _draw_layer(const Tiled2cMap *map, const Tiled2cLayer *this,
+ vec2 off) {
assert(this != nullptr);
- TZR_DrawSetColor(.a=this->opacity);
- rfor (y, 0u, map->height) {
+ TZR_DrawSetColor(.a = this->opacity);
+ rfor(y, 0u, map->height) {
const int dy = y * cfg.tile_height + off.y;
- rfor (x, 0u, map->width) {
+ rfor(x, 0u, map->width) {
const int dx = x * cfg.tile_width + off.x;
- const auto tile = this->tilelayer.data[x + y * map->width];
+ const auto tile =
+ this->tilelayer.data[x + y * map->width];
tile_draw(tile, dx, dy);
}
}
- TZR_DrawSetColor(.a=1);
+ TZR_DrawSetColor(.a = 1);
}
-void
-map_draw(Map *this, vec2 off)
-{
+void map_draw(Map *this, vec2 off) {
assert(this != nullptr);
- rfor (i, 0u, this->t2c->numlayers) {
+ rfor(i, 0u, this->t2c->numlayers) {
const auto layer = &this->t2c->layers[i];
assert(layer->type == 't');
if (layer->visible && !map_object_layer(layer))
@@ -58,9 +52,7 @@ map_draw(Map *this, vec2 off)
}
}
-bool
-map_object_layer(const Tiled2cLayer *layer)
-{
+bool map_object_layer(const Tiled2cLayer *layer) {
assert(layer != nullptr);
return (layer->type == 't' && layer->class && layer->class[0]);
}