summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)...",