diff options
Diffstat (limited to 'src/all.c')
-rw-r--r-- | src/all.c | 40 |
1 files changed, 26 insertions, 14 deletions
@@ -104,34 +104,47 @@ static DrawList *render(State *state, UI *ui, Arena *a) { DrawList *drawList = new(a, 1, DrawList); - int cellWidth = (ui->width - GRID_OFFSET_X) / GRIDWIDTH; - int cellHeight = ui->height / GRIDHEIGHT; + float cellWidth = (float) (ui->width - GRID_OFFSET_X) / GRIDWIDTH; + float cellHeight = (float) ui->height / GRIDHEIGHT; for (int x = 0; x < GRIDWIDTH; x++) { for (int y = 0; y < GRIDHEIGHT; y++) { - drawList->els[drawList->len++] = (DrawElement) { - .x = cellWidth * x + GRID_OFFSET_X, - .y = cellHeight * y, - .w = cellWidth, - .h = cellHeight, - .fill = {0, 0, 0, 0}, - .border = {0, 0, 0, 255}, - }; 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, - .h = cellHeight / 2, + .w = cellWidth / 2 + (1 - subx), + .h = cellHeight / 2 + (1 - suby), .fill = colors[state->grid[x + GRIDWIDTH * y]][subx + 2 * suby], - .border = {0, 0, 0, 0}, }; } } } } + // Vertical grid lines + for (int x = 1; x < GRIDWIDTH; x++) { + drawList->els[drawList->len++] = (DrawElement) { + .x = cellWidth * x + GRID_OFFSET_X, + .y = 0, + .w = 1, + .h = ui->height, + .fill = {0, 0, 0, 255}, + }; + } + + // Horizontal grid lines + for (int y = 1; y < GRIDHEIGHT; y++) { + drawList->els[drawList->len++] = (DrawElement) { + .x = GRID_OFFSET_X, + .y = y * cellHeight, + .w = ui->width - GRID_OFFSET_X, + .h = 1, + .fill = {0, 0, 0, 255}, + }; + } + drawList->els[drawList->len++] = (DrawElement) { .x = cellWidth * state->goalx + GRID_OFFSET_X, .y = cellHeight * state->goaly, @@ -139,7 +152,6 @@ static DrawList *render(State *state, UI *ui, Arena *a) { .h = cellHeight, .fill = {255, 0, 0, 63}, .border = {255, 0, 0, 255}, - .image = 1, }; drawList->els[drawList->len++] = (DrawElement) { |