summaryrefslogtreecommitdiffstats
path: root/src/map.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-25 15:05:37 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-25 15:05:37 (EDT)
commit514790f9d67e6dfffb7f6ed338a53be3eb84faeb (patch)
treec1a66e6d4ca47b6556d64f2eb8589c649434c004 /src/map.c
parent34ccab84eee6406833b3bbc556301e5f070be2e8 (diff)
downloaddodge-balls-514790f9d67e6dfffb7f6ed338a53be3eb84faeb.zip
dodge-balls-514790f9d67e6dfffb7f6ed338a53be3eb84faeb.tar.gz
dodge-balls-514790f9d67e6dfffb7f6ed338a53be3eb84faeb.tar.bz2
tileset: Ensure tile size matches map's
Diffstat (limited to 'src/map.c')
-rw-r--r--src/map.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/map.c b/src/map.c
index c2454f0..84b6194 100644
--- a/src/map.c
+++ b/src/map.c
@@ -396,7 +396,7 @@ _db_tmx_map_el_start(void *pv, const char *name, const char **attr)
db_xml_get_string_attr(p, attr, "source", &source, 1);
db_dbg(" Tileset: <%s>", source);
map->tileset_tail = db_tileset_new(map->game_id, source,
- firstgid, map->tileset_tail);
+ firstgid, map->tw, map->th, map->tileset_tail);
if (map->tileset_head == NULL) {
map->tileset_head = map->tileset_tail;
}
@@ -516,8 +516,6 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
int firstgid;
int lastgid;
int columns;
- int tilewidth;
- int tileheight;
SDL_Rect tile_rect;
SDL_Rect layer_rect;
@@ -532,20 +530,18 @@ _db_map_render_layer(struct db_map *map, struct db_map_layer *layer,
firstgid = db_tileset_firstgid(tileset);
lastgid = firstgid + db_tileset_tilecount(tileset);
if (gid >= firstgid && gid < lastgid) {
- columns = db_tileset_columns (tileset);
- tilewidth = db_tileset_tilewidth (tileset);
- tileheight = db_tileset_tileheight(tileset);
+ columns = db_tileset_columns(tileset);
gid -= firstgid;
tile_rect.x = gid % columns;
tile_rect.y = gid / columns;
- tile_rect.w = tilewidth;
- tile_rect.h = tileheight;
+ 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 = tilewidth;
- layer_rect.h = tileheight;
+ layer_rect.w = map->tw;
+ layer_rect.h = map->th;
layer_rect.x *= layer_rect.w;
layer_rect.y *= layer_rect.h;
db_dbg("Blitting %dx%d tile at (%d,%d) "