218 lines
5.8 KiB
C
218 lines
5.8 KiB
C
/* Dumb Clicker Goto Edition
|
|
* Copyright (C) 2021 KikooDX
|
|
* SPDX-License-Identifier: MIT */
|
|
/* This program is using label/goto for everything. There is one exception:
|
|
* `if (cond) goto label;` and ternary operators are allowed. */
|
|
|
|
#include <gint/display.h>
|
|
#include <gint/keyboard.h>
|
|
|
|
#define MAX_MENU_SELECTION 3
|
|
#define MAX_SETTINGS_SELECTION 3
|
|
#define KEYS_COUNT 2
|
|
|
|
void main(void)
|
|
{
|
|
/* variables */
|
|
/* try to overflow this one Lephe (: */
|
|
long int counter = 0;
|
|
extern const font_t font_tm;
|
|
key_event_t key_event;
|
|
const font_t *fonts[] = { &font_tm, NULL };
|
|
int current_font = 0;
|
|
/* settings */
|
|
color_t background_color = C_BLACK;
|
|
color_t foreground_color = C_WHITE;
|
|
int keys[KEYS_COUNT] = { KEY_SHIFT, KEY_OPTN };
|
|
int menu_selection = 0;
|
|
int settings_selection = 0;
|
|
const char *menu_entries[MAX_MENU_SELECTION] =
|
|
{ "%s Play :) %s", "%s Settings :o %s", "%s Exit :( %s" };
|
|
const char *settings_entries[MAX_SETTINGS_SELECTION] =
|
|
{ "%s Return to Main Menu ;) %s", "%s Change Theme 8) %s", "%s Remap Keys :>%s" };
|
|
int i;
|
|
|
|
/* init */
|
|
dfont(fonts[current_font]);
|
|
|
|
/* menu loop */
|
|
menu_loop:
|
|
/* draw */
|
|
dclear(background_color);
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 3,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"DUMB CLICKER GOTO EDITION");
|
|
i = 0;
|
|
draw_menu_entries:
|
|
dprint_opt(DWIDTH / 2, DHEIGHT / 2 + 16 + i * 24,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
menu_entries[i],
|
|
(menu_selection == i) ? ">" : "",
|
|
(menu_selection == i) ? "<" : "");
|
|
if (++i < MAX_MENU_SELECTION) goto draw_menu_entries;
|
|
dupdate();
|
|
|
|
/* update */
|
|
menu_process_key:
|
|
key_event = pollevent();
|
|
if (key_event.type != KEYEV_DOWN)
|
|
goto menu_process_key;
|
|
if (key_event.key == KEY_EXIT)
|
|
goto end;
|
|
if (key_event.key == keys[0])
|
|
goto menu_confirm;
|
|
/* key secondary (change selection) */
|
|
if (key_event.key != keys[1])
|
|
goto menu_process_key;
|
|
menu_selection += 1;
|
|
if (menu_selection < MAX_MENU_SELECTION)
|
|
/* redraw */
|
|
goto menu_loop;
|
|
menu_selection = 0;
|
|
goto menu_loop;
|
|
|
|
menu_confirm:
|
|
if (menu_selection == 0)
|
|
goto game_loop;
|
|
if (menu_selection == 1)
|
|
goto settings_loop;
|
|
if (menu_selection == 2)
|
|
goto end;
|
|
|
|
/* settings loop */
|
|
settings_loop:
|
|
/* draw */
|
|
dclear(background_color);
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 3,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"SETTINGS");
|
|
i = 0;
|
|
draw_settings_entries:
|
|
dprint_opt(DWIDTH / 2, DHEIGHT / 2 + 16 + i * 24,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
settings_entries[i],
|
|
(settings_selection == i) ? ">" : "",
|
|
(settings_selection == i) ? "<" : "");
|
|
if (++i < MAX_MENU_SELECTION) goto draw_settings_entries;
|
|
dupdate();
|
|
|
|
/* update */
|
|
settings_process_key:
|
|
key_event = pollevent();
|
|
if (key_event.type != KEYEV_DOWN)
|
|
goto settings_process_key;
|
|
if (key_event.key == KEY_EXIT)
|
|
goto menu_loop;
|
|
if (key_event.key == keys[0])
|
|
goto settings_confirm;
|
|
/* key secondary (change selection) */
|
|
if (key_event.key != keys[1])
|
|
goto settings_process_key;
|
|
settings_selection += 1;
|
|
if (settings_selection < MAX_SETTINGS_SELECTION)
|
|
/* redraw */
|
|
goto settings_loop;
|
|
settings_selection = 0;
|
|
goto settings_loop;
|
|
|
|
settings_confirm:
|
|
if (settings_selection == 0)
|
|
goto menu_loop;
|
|
if (settings_selection == 1)
|
|
goto settings_change_theme;
|
|
if (settings_selection == 2)
|
|
goto remap_keys;
|
|
|
|
settings_change_theme:
|
|
background_color = foreground_color;
|
|
foreground_color =
|
|
(foreground_color == C_BLACK) ? C_WHITE : C_BLACK;
|
|
goto settings_loop;
|
|
|
|
remap_keys:
|
|
i = 0;
|
|
remap_keys_loop:
|
|
/* draw */
|
|
dclear(background_color);
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 3,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"REMAP KEYS");
|
|
dprint_opt(DWIDTH / 2, DHEIGHT / 2,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"%s (was %d)",
|
|
(i == 0) ? "Main" : "Secondary",
|
|
keys[i]);
|
|
dupdate();
|
|
|
|
/* update */
|
|
remap_keys_process_key:
|
|
key_event = pollevent();
|
|
if (key_event.type != KEYEV_DOWN)
|
|
goto remap_keys_process_key;
|
|
if (key_event.key == KEY_EXIT)
|
|
goto settings_loop;
|
|
keys[i] = key_event.key;
|
|
|
|
if (++i < KEYS_COUNT)
|
|
goto remap_keys_loop;
|
|
settings_selection = 0;
|
|
goto settings_loop;
|
|
|
|
/* game loop */
|
|
game_loop:
|
|
/* draw */
|
|
dclear(background_color);
|
|
dprint_opt(DWIDTH / 2, DHEIGHT / 2,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"%ld", counter);
|
|
if (counter != 696969)
|
|
goto lame;
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 2 + 24,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE, "many nice");
|
|
lame:
|
|
if (counter != 6969)
|
|
goto superlame;
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 2 + 24,
|
|
foreground_color, background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE, "very nice");
|
|
superlame:
|
|
if (counter != 69)
|
|
goto megalame;
|
|
dtext_opt(DWIDTH / 2, DHEIGHT / 2 + 24,
|
|
foreground_color,
|
|
background_color,
|
|
DTEXT_CENTER, DTEXT_MIDDLE,
|
|
"nice");
|
|
megalame:
|
|
dupdate();
|
|
|
|
/* update */
|
|
game_process_key:
|
|
key_event = pollevent();
|
|
if (key_event.key == KEY_EXIT) goto menu_loop;
|
|
if (key_event.type != KEYEV_DOWN)
|
|
goto game_process_key;
|
|
if (key_event.key == keys[1])
|
|
goto trigger_thonk;
|
|
if (key_event.key != keys[0])
|
|
goto game_process_key;
|
|
counter += 1;
|
|
goto game_loop;
|
|
|
|
trigger_thonk:
|
|
counter -= 1;
|
|
goto game_loop;
|
|
|
|
/* exit */
|
|
end:
|
|
return;
|
|
}
|