diff options
-rw-r--r-- | Makefile | 15 | ||||
-rw-r--r-- | res/nelson.png | bin | 0 -> 716 bytes | |||
-rw-r--r-- | res/nelson_down.png | bin | 0 -> 605 bytes | |||
-rw-r--r-- | res/nelson_left.png | bin | 0 -> 652 bytes | |||
-rw-r--r-- | res/nelson_right.png | bin | 0 -> 645 bytes | |||
-rw-r--r-- | res/nelson_up.png | bin | 0 -> 626 bytes | |||
-rw-r--r-- | src/all.c | 50 | ||||
-rw-r--r-- | src/types.c | 5 |
8 files changed, 60 insertions, 10 deletions
@@ -42,7 +42,10 @@ build/music.c: build/music.pcm echo '};' \ ) > build/music.c -build/images.c: build/continue.qoi build/exit.qoi build/pause.qoi build/play.qoi build/restart.qoi build/img +build/images.c: \ + build/continue.qoi build/exit.qoi build/pause.qoi build/play.qoi build/restart.qoi \ + build/nelson.qoi build/nelson_up.qoi build/nelson_down.qoi build/nelson_left.qoi build/nelson_right.qoi \ + build/img mkdir -p build (\ build/img pixels build/continue.qoi 1 && \ @@ -50,12 +53,22 @@ build/images.c: build/continue.qoi build/exit.qoi build/pause.qoi build/play.qoi build/img pixels build/pause.qoi 3 && \ build/img pixels build/play.qoi 4 && \ build/img pixels build/restart.qoi 5 && \ + build/img pixels build/nelson.qoi 6 && \ + build/img pixels build/nelson_left.qoi 7 && \ + build/img pixels build/nelson_up.qoi 8 && \ + build/img pixels build/nelson_right.qoi 9 && \ + build/img pixels build/nelson_down.qoi 10 && \ echo 'Image images[] = {{0},' && \ build/img image build/continue.qoi 1 && \ build/img image build/exit.qoi 2 && \ build/img image build/pause.qoi 3 && \ build/img image build/play.qoi 4 && \ build/img image build/restart.qoi 5 && \ + build/img image build/nelson.qoi 6 && \ + build/img image build/nelson_left.qoi 7 && \ + build/img image build/nelson_up.qoi 8 && \ + build/img image build/nelson_right.qoi 9 && \ + build/img image build/nelson_down.qoi 10 && \ echo '};' \ ) > build/images.c diff --git a/res/nelson.png b/res/nelson.png Binary files differnew file mode 100644 index 0000000..2441634 --- /dev/null +++ b/res/nelson.png diff --git a/res/nelson_down.png b/res/nelson_down.png Binary files differnew file mode 100644 index 0000000..973c3f3 --- /dev/null +++ b/res/nelson_down.png diff --git a/res/nelson_left.png b/res/nelson_left.png Binary files differnew file mode 100644 index 0000000..08b7392 --- /dev/null +++ b/res/nelson_left.png diff --git a/res/nelson_right.png b/res/nelson_right.png Binary files differnew file mode 100644 index 0000000..ec5c1f5 --- /dev/null +++ b/res/nelson_right.png diff --git a/res/nelson_up.png b/res/nelson_up.png Binary files differnew file mode 100644 index 0000000..deb62a6 --- /dev/null +++ b/res/nelson_up.png @@ -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, }; |