Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/src/all.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/all.c')
-rw-r--r--src/all.c50
1 files changed, 41 insertions, 9 deletions
diff --git a/src/all.c b/src/all.c
index 6e1525a..7ed292e 100644
--- a/src/all.c
+++ b/src/all.c
@@ -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],
+ };
+ }
}
}
}