Rendering fix in apps

This commit is contained in:
boreddevnl
2026-02-26 21:56:50 +01:00
parent fcc290f3f9
commit 34ceff4290
57 changed files with 112 additions and 136 deletions

View File

@@ -141,19 +141,19 @@ static void flag_cell(int x, int y) {
static void minesweeper_paint(ui_window_t win) {
int win_w = 240, win_h = 340;
ui_draw_rect(win, 4, 0, win_w - 8, win_h - 34, COLOR_DARK_BG);
ui_draw_rect(win, 4, 0, win_w - 8, win_h, COLOR_DARK_BG);
if (game_over) {
ui_draw_string(win, 10, 6, "Game Over!", COLOR_TRAFFIC_RED);
ui_draw_string(win, 10, 4, "Game Over!", COLOR_TRAFFIC_RED);
} else if (game_won) {
ui_draw_string(win, 10, 6, "You Won!", 0xFF00FF00); // Bright green
ui_draw_string(win, 10, 4, "You Won!", 0xFF00FF00); // Bright green
} else {
ui_draw_string(win, 10, 6, "", COLOR_DARK_TEXT);
ui_draw_string(win, 10, 4, "", COLOR_DARK_TEXT);
}
// Draw grid
int grid_start_x = 10;
int grid_start_y = 26;
int grid_start_y = 22;
for (int y = 0; y < GRID_HEIGHT; y++) {
for (int x = 0; x < GRID_WIDTH; x++) {
@@ -191,7 +191,7 @@ static void minesweeper_paint(ui_window_t win) {
static void minesweeper_handle_click(ui_window_t win, int x, int y, int button) {
int grid_start_x = 10;
int grid_start_y = 26;
int grid_start_y = 22;
int btn_y = grid_start_y + GRID_HEIGHT * CELL_SIZE + 10;
// Check "New Game" button
@@ -211,10 +211,8 @@ static void minesweeper_handle_click(ui_window_t win, int x, int y, int button)
int cell_y = (y - grid_start_y) / CELL_SIZE;
if (button == GUI_EVENT_RIGHT_CLICK) {
debug_print("[MINESWEEPER] Flagging cell");
flag_cell(cell_x, cell_y);
} else {
debug_print("[MINESWEEPER] Revealing cell");
reveal_cell(cell_x, cell_y);
}
}
@@ -236,12 +234,10 @@ int main(int argc, char **argv) {
minesweeper_paint(win);
ui_mark_dirty(win, 0, 0, 240, 320);
} else if (ev.type == GUI_EVENT_CLICK) {
debug_print("[MINESWEEPER] LEFT CLICK");
minesweeper_handle_click(win, ev.arg1, ev.arg2, ev.type);
minesweeper_paint(win);
ui_mark_dirty(win, 0, 0, 240, 320);
} else if (ev.type == GUI_EVENT_RIGHT_CLICK) {
debug_print("[MINESWEEPER] RIGHT CLICK DETECTED");
minesweeper_handle_click(win, ev.arg1, ev.arg2, ev.type);
minesweeper_paint(win);
ui_mark_dirty(win, 0, 0, 240, 320);