diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2023-07-30 17:16:36 +0100 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2023-07-30 17:16:36 +0100 |
| commit | 29eaa8f55c7b9cc960afa4327a7ce977e6637e9c (patch) | |
| tree | 9dbb6231c92850efb3d4d998b3945cd80cef6b97 | |
| parent | 58511aa009c672cc2ade783d537a5830806fd02c (diff) | |
| download | puzzles-29eaa8f55c7b9cc960afa4327a7ce977e6637e9c.zip puzzles-29eaa8f55c7b9cc960afa4327a7ce977e6637e9c.tar.gz puzzles-29eaa8f55c7b9cc960afa4327a7ce977e6637e9c.tar.bz2 puzzles-29eaa8f55c7b9cc960afa4327a7ce977e6637e9c.tar.xz | |
Flood: don't draw zero-width tile separators
Flood's draw_tile() extravagantly uses up to eight rectangles to draw
separators around each tile. This could be substantially improved,
but a particularly low-hanging optimisation is not do draw them when
the separator width is zero.
This at least means that Flood completes its initial drawing on my
test KaiOS device.
| -rw-r--r-- | flood.c | 52 |
1 files changed, 27 insertions, 25 deletions
@@ -1101,31 +1101,33 @@ static void draw_tile(drawing *dr, game_drawstate *ds, colour += COL_1; draw_rect(dr, tx, ty, TILESIZE, TILESIZE, colour); - if (tile & BORDER_L) - draw_rect(dr, tx, ty, - SEP_WIDTH, TILESIZE, COL_SEPARATOR); - if (tile & BORDER_R) - draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty, - SEP_WIDTH, TILESIZE, COL_SEPARATOR); - if (tile & BORDER_U) - draw_rect(dr, tx, ty, - TILESIZE, SEP_WIDTH, COL_SEPARATOR); - if (tile & BORDER_D) - draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH, - TILESIZE, SEP_WIDTH, COL_SEPARATOR); - - if (tile & CORNER_UL) - draw_rect(dr, tx, ty, - SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); - if (tile & CORNER_UR) - draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty, - SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); - if (tile & CORNER_DL) - draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH, - SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); - if (tile & CORNER_DR) - draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty + TILESIZE - SEP_WIDTH, - SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); + if (SEP_WIDTH > 0) { + if (tile & BORDER_L) + draw_rect(dr, tx, ty, + SEP_WIDTH, TILESIZE, COL_SEPARATOR); + if (tile & BORDER_R) + draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty, + SEP_WIDTH, TILESIZE, COL_SEPARATOR); + if (tile & BORDER_U) + draw_rect(dr, tx, ty, + TILESIZE, SEP_WIDTH, COL_SEPARATOR); + if (tile & BORDER_D) + draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH, + TILESIZE, SEP_WIDTH, COL_SEPARATOR); + + if (tile & CORNER_UL) + draw_rect(dr, tx, ty, + SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); + if (tile & CORNER_UR) + draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty, + SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); + if (tile & CORNER_DL) + draw_rect(dr, tx, ty + TILESIZE - SEP_WIDTH, + SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); + if (tile & CORNER_DR) + draw_rect(dr, tx + TILESIZE - SEP_WIDTH, ty + TILESIZE - SEP_WIDTH, + SEP_WIDTH, SEP_WIDTH, COL_SEPARATOR); + } if (tile & CURSOR) draw_rect_outline(dr, tx + CURSOR_INSET, ty + CURSOR_INSET, |