diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/all.c | 50 | ||||
-rw-r--r-- | src/types.c | 5 |
2 files changed, 46 insertions, 9 deletions
@@ -134,15 +134,47 @@ static DrawList *render(State *state, UI *ui, Arena *a) { for (int x = 0; x < GRIDWIDTH; x++) { for (int y = 0; y < GRIDHEIGHT; y++) { - for (int subx = 0; subx < 2; subx++) { - for (int suby = 0; suby < 2; suby++) { - drawList->els[drawList->len++] = (DrawElement) { - .x = cellWidth * x + GRID_OFFSET_X + subx * cellWidth / 2, - .y = cellHeight * y + suby * cellHeight / 2, - .w = cellWidth / 2 + (1 - subx), - .h = cellHeight / 2 + (1 - suby), - .fill = colors[state->grid[x + GRIDWIDTH * y]][subx + 2 * suby], - }; + int image; + switch (state->grid[x + GRIDWIDTH * y]) { + case RED: + image = IMAGE_NELSON; + break; + case RED_LEFT: + image = IMAGE_NELSON_LEFT; + break; + case RED_UP: + image = IMAGE_NELSON_UP; + break; + case RED_RIGHT: + image = IMAGE_NELSON_RIGHT; + break; + case RED_DOWN: + image = IMAGE_NELSON_DOWN; + break; + default: + image = 0; + break; + } + + if (image) { + drawList->els[drawList->len++] = (DrawElement) { + .x = cellWidth * x + GRID_OFFSET_X, + .y = cellHeight * y, + .w = cellWidth, + .h = cellHeight, + .image = image, + }; + } else { + for (int subx = 0; subx < 2; subx++) { + for (int suby = 0; suby < 2; suby++) { + drawList->els[drawList->len++] = (DrawElement) { + .x = cellWidth * x + GRID_OFFSET_X + subx * cellWidth / 2, + .y = cellHeight * y + suby * cellHeight / 2, + .w = cellWidth / 2 + (1 - subx), + .h = cellHeight / 2 + (1 - suby), + .fill = colors[state->grid[x + GRIDWIDTH * y]][subx + 2 * suby], + }; + } } } } diff --git a/src/types.c b/src/types.c index bee6b05..d2a7575 100644 --- a/src/types.c +++ b/src/types.c @@ -55,6 +55,11 @@ enum { IMAGE_PAUSE, IMAGE_PLAY, IMAGE_RETRY, + IMAGE_NELSON, + IMAGE_NELSON_LEFT, + IMAGE_NELSON_UP, + IMAGE_NELSON_RIGHT, + IMAGE_NELSON_DOWN, N_IMAGES, }; |