summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-25 15:08:04 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-25 15:08:04 (EDT)
commit14716f2830387ff70017735b784e9904bd065055 (patch)
tree5732c11d81ca0cfaaf426d78f9f4a1b3772c1ab5
parent514790f9d67e6dfffb7f6ed338a53be3eb84faeb (diff)
downloaddodge-balls-14716f2830387ff70017735b784e9904bd065055.zip
dodge-balls-14716f2830387ff70017735b784e9904bd065055.tar.gz
dodge-balls-14716f2830387ff70017735b784e9904bd065055.tar.bz2
map: Set layer rect in outer loop
-rw-r--r--src/map.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/map.c b/src/map.c
index 84b6194..2ac3ebd 100644
--- a/src/map.c
+++ b/src/map.c
@@ -525,6 +525,12 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
continue;
}
tile_found = SDL_FALSE;
+ layer_rect.x = i % map->w;
+ layer_rect.y = i / map->w;
+ layer_rect.w = map->tw;
+ layer_rect.h = map->th;
+ layer_rect.x *= layer_rect.w;
+ layer_rect.y *= layer_rect.h;
for (tileset = map->tileset_head; tileset != NULL;
tileset = db_tileset_next(tileset)) {
firstgid = db_tileset_firstgid(tileset);
@@ -532,18 +538,12 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
if (gid >= firstgid && gid < lastgid) {
columns = db_tileset_columns(tileset);
gid -= firstgid;
- tile_rect.x = gid % columns;
- tile_rect.y = gid / columns;
- tile_rect.w = map->tw;
- tile_rect.h = map->th;
- tile_rect.x *= tile_rect.w;
- tile_rect.y *= tile_rect.h;
- layer_rect.x = i % map->w;
- layer_rect.y = i / map->w;
- layer_rect.w = map->tw;
- layer_rect.h = map->th;
- layer_rect.x *= layer_rect.w;
- layer_rect.y *= layer_rect.h;
+ tile_rect.x = gid % columns;
+ tile_rect.y = gid / columns;
+ tile_rect.w = map->tw;
+ tile_rect.h = map->th;
+ tile_rect.x *= tile_rect.w;
+ tile_rect.y *= tile_rect.h;
db_dbg("Blitting %dx%d tile at (%d,%d) "
"onto %dx%d area of layer at "
"(%d,%d)...",