Back to shtanton's homepage
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/all.c90
-rw-r--r--src/levels.c6
2 files changed, 56 insertions, 40 deletions
diff --git a/src/all.c b/src/all.c
index 459539d..ea76f8f 100644
--- a/src/all.c
+++ b/src/all.c
@@ -210,31 +210,38 @@ static DrawList *render(State *state, UI *ui, Arena *a) {
cellHeight
);
- if (colorImages[hoverColor]) {
- drawList->els[drawList->len++] = (DrawElement) {
- .x = cellWidth * hoverx + GRID_OFFSET_X,
- .y = cellHeight * hovery,
- .w = cellWidth,
- .h = cellHeight,
- .image = {
- .index = colorImages[hoverColor],
- .opacity = 127,
- },
- };
- } else if (hoverColor != EMPTY) {
- int subCellWidth = cellWidth / 2;
- int subCellHeight = cellHeight / 2;
- for (int subx = 0; subx < 2; subx++) {
- for (int suby = 0; suby < 2; suby++) {
- Color fill = colors[hoverColor][subx + 2 * suby];
- fill.a = 127;
- drawList->els[drawList->len++] = (DrawElement) {
- .x = cellWidth * hoverx + GRID_OFFSET_X + (subx * subCellWidth),
- .y = cellHeight * hovery + (suby * subCellHeight),
- .w = subCellWidth,
- .h = subCellHeight,
- .fill = fill,
- };
+ if (hoverColor != EMPTY) {
+ for (int i = 0; i < MAX_PLACEABLE_CELLS; i++) {
+ if (state->placeableCells[i] == hoverColor) {
+ if (colorImages[hoverColor]) {
+ drawList->els[drawList->len++] = (DrawElement) {
+ .x = cellWidth * hoverx + GRID_OFFSET_X,
+ .y = cellHeight * hovery,
+ .w = cellWidth,
+ .h = cellHeight,
+ .image = {
+ .index = colorImages[hoverColor],
+ .opacity = 127,
+ },
+ };
+ } else {
+ int subCellWidth = cellWidth / 2;
+ int subCellHeight = cellHeight / 2;
+ for (int subx = 0; subx < 2; subx++) {
+ for (int suby = 0; suby < 2; suby++) {
+ Color fill = colors[hoverColor][subx + 2 * suby];
+ fill.a = 127;
+ drawList->els[drawList->len++] = (DrawElement) {
+ .x = cellWidth * hoverx + GRID_OFFSET_X + (subx * subCellWidth),
+ .y = cellHeight * hovery + (suby * subCellHeight),
+ .w = subCellWidth,
+ .h = subCellHeight,
+ .fill = fill,
+ };
+ }
+ }
+ }
+ break;
}
}
}
@@ -302,16 +309,29 @@ static DrawList *render(State *state, UI *ui, Arena *a) {
break;
}
- for (int x = 0; x < 2; x++) {
- for (int y = 0; y < 2; y++) {
- drawList->els[drawList->len++] = (DrawElement) {
- .x = BUTTON_SIZE / 2 + x * (BUTTON_SIZE / 2),
- // .y = (BUTTON_SIZE / 2 + y * (BUTTON_SIZE / 2) + BUTTON_SPACING * (cellCount % 2 + 1)) * (cellCount + 1), // TODO - padding
- .y = BUTTON_SIZE / 2 + i * (BUTTON_SIZE + BUTTON_SPACING) + y * (BUTTON_SIZE / 2),
- .w = BUTTON_SIZE / 2,
- .h = BUTTON_SIZE / 2,
- .fill = colors[(int) state->placeableCells[i]][x + 2 * y],
- };
+ if (colorImages[(int) state->placeableCells[i]]) {
+ drawList->els[drawList->len++] = (DrawElement) {
+ .x = BUTTON_SIZE / 2,
+ .y = BUTTON_SIZE / 2 + i * (BUTTON_SIZE + BUTTON_SPACING),
+ .w = BUTTON_SIZE,
+ .h = BUTTON_SIZE,
+ .image = {
+ .index = colorImages[(int) state->placeableCells[i]],
+ .opacity = 255,
+ },
+ };
+ } else {
+ for (int x = 0; x < 2; x++) {
+ for (int y = 0; y < 2; y++) {
+ drawList->els[drawList->len++] = (DrawElement) {
+ .x = BUTTON_SIZE / 2 + x * (BUTTON_SIZE / 2),
+ // .y = (BUTTON_SIZE / 2 + y * (BUTTON_SIZE / 2) + BUTTON_SPACING * (cellCount % 2 + 1)) * (cellCount + 1), // TODO - padding
+ .y = BUTTON_SIZE / 2 + i * (BUTTON_SIZE + BUTTON_SPACING) + y * (BUTTON_SIZE / 2),
+ .w = BUTTON_SIZE / 2,
+ .h = BUTTON_SIZE / 2,
+ .fill = colors[(int) state->placeableCells[i]][x + 2 * y],
+ };
+ }
}
}
}
diff --git a/src/levels.c b/src/levels.c
index e6f4d3a..21c3503 100644
--- a/src/levels.c
+++ b/src/levels.c
@@ -30,10 +30,6 @@ static Level levels[] = {
.goaly = 7,
.placeableCells = {
RED,
- BLACK,
- YELLOW,
- RED_DOWN,
- RED_LEFT,
},
},
{
@@ -59,7 +55,7 @@ static Level levels[] = {
.goaly = 10,
.placeableCells = {
BLACK,
- RED_DOWN
+ RED,
},
},
};