Skip to content

Commit

Permalink
Refactor: check out_of_bounds before calc map_draw_xy
Browse files Browse the repository at this point in the history
  • Loading branch information
lychees committed Aug 11, 2024
1 parent 4d45f8e commit 371b85d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/tilemap_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ void TilemapLayer::Draw(Bitmap& dst, uint8_t z_order, int render_ox, int render_
if (loop_h) map_x = mod(map_x, width);
if (loop_v) map_y = mod(map_y, height);

int map_draw_x = x * TILE_SIZE - mod_ox;
int map_draw_y = y * TILE_SIZE - mod_oy;

bool out_of_bounds =
map_x < 0 || map_x >= width ||
map_y < 0 || map_y >= height;
Expand All @@ -270,6 +267,9 @@ void TilemapLayer::Draw(Bitmap& dst, uint8_t z_order, int render_ox, int render_
continue;
}

int map_draw_x = x * TILE_SIZE - mod_ox;
int map_draw_y = y * TILE_SIZE - mod_oy;

// Get the tile data
TileData &tile = GetDataCache(map_x, map_y);

Expand Down

0 comments on commit 371b85d

Please sign in to comment.