much commit yes

master 69
kdx 2 years ago
commit 99be9763ef
  1. 16
      .gitignore
  2. 36
      CMakeLists.txt
  3. 16
      README
  4. BIN
      assets/dcge.png
  5. BIN
      assets/font.png
  6. 7
      assets/fxconv-metadata.txt
  7. BIN
      assets/icon-sel.png
  8. BIN
      assets/icon-uns.png
  9. 217
      src/main.c

16
.gitignore vendored

@ -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~

@ -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)

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

@ -0,0 +1,7 @@
font.png:
type: font
charset: print
grid.width: 10
grid.height: 13
proportional: true
name: font_tm

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

@ -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 <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 + 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;
}
Loading…
Cancel
Save