commit 99be9763ef9e544dfc64cabe7b3daf8ef56cc1a3 Author: KikooDX Date: Tue Apr 13 17:26:54 2021 +0200 much commit yes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3eb12e --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Build files +/build-fx +/build-cg +/*.g1a +/*.g3a + +# Python bytecode + __pycache__/ + +# Common IDE files +*.sublime-project +*.sublime-workspace +.vscode + +# Krita backups +*.png~ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c61db4f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2021 KikooDX +# SPDX-License-Identifier: MIT + +############################# +# Dumb Clicker Goto Edition # +############################# +# Configure with [fxsdk build-cg], which provide the +# toolchain file and module path of the fxSDK + +cmake_minimum_required(VERSION 3.18) +project(DCGE) + +include(GenerateG1A) +include(GenerateG3A) +include(Fxconv) +find_package(Gint 2.1 REQUIRED) + +set(SOURCES + src/main.c) + +set(ASSETS + assets/font.png) + +set(FLAGS + -std=c89 -pedantic -Wall -Wextra -Werror -Os) + +fxconv_declare_assets(${ASSETS} WITH_METADATA) + +add_executable(${PROJECT_NAME} ${SOURCES} ${ASSETS}) +target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS}) +target_link_libraries(${PROJECT_NAME} Gint::Gint) + +generate_g3a(TARGET ${PROJECT_NAME} + OUTPUT "${PROJECT_NAME}.g3a" + NAME "${PROJECT_NAME}" + ICONS assets/icon-uns.png assets/icon-sel.png) diff --git a/README b/README new file mode 100644 index 0000000..d684463 --- /dev/null +++ b/README @@ -0,0 +1,16 @@ +dumb clicker goto edition +========================= +yes + +build +----- +require sh-elf toolchain, fxsdk, gint and mkg3a +$ fxsdk build-cg + +play +==== +press shift +yes + +press optn in menu +yes diff --git a/assets/dcge.png b/assets/dcge.png new file mode 100644 index 0000000..d86ad3e Binary files /dev/null and b/assets/dcge.png differ diff --git a/assets/font.png b/assets/font.png new file mode 100644 index 0000000..5ce9ab1 Binary files /dev/null and b/assets/font.png differ diff --git a/assets/fxconv-metadata.txt b/assets/fxconv-metadata.txt new file mode 100644 index 0000000..ff013b6 --- /dev/null +++ b/assets/fxconv-metadata.txt @@ -0,0 +1,7 @@ +font.png: + type: font + charset: print + grid.width: 10 + grid.height: 13 + proportional: true + name: font_tm diff --git a/assets/icon-sel.png b/assets/icon-sel.png new file mode 100644 index 0000000..91dd6c0 Binary files /dev/null and b/assets/icon-sel.png differ diff --git a/assets/icon-uns.png b/assets/icon-uns.png new file mode 100644 index 0000000..1518df4 Binary files /dev/null and b/assets/icon-uns.png differ diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..40cec75 --- /dev/null +++ b/src/main.c @@ -0,0 +1,217 @@ +/* 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 +#include + +#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 + i * 16, + 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 + i * 16, + 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 + 16, + foreground_color, background_color, + DTEXT_CENTER, DTEXT_MIDDLE, "many nice"); + lame: + if (counter != 6969) + goto superlame; + dtext_opt(DWIDTH / 2, DHEIGHT / 2 + 16, + foreground_color, background_color, + DTEXT_CENTER, DTEXT_MIDDLE, "very nice"); + superlame: + if (counter != 69) + goto megalame; + dtext_opt(DWIDTH / 2, DHEIGHT / 2 + 16, + 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; +}