From 25c4c8427f6c4ff1ad99141c6321b1395a8fb3fb Mon Sep 17 00:00:00 2001 From: Ivan Davydov Date: Sat, 5 Apr 2025 20:39:44 +0300 Subject: Minor improvements --- clicker-ncurses.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'clicker-ncurses.c') diff --git a/clicker-ncurses.c b/clicker-ncurses.c index 37dc0b9..8decf8f 100644 --- a/clicker-ncurses.c +++ b/clicker-ncurses.c @@ -1,6 +1,7 @@ #include -#include #include +#include +#include #include @@ -45,28 +46,28 @@ main (void) int ch = 0; while (ch = getch()) { - if (ch == ' ') - { - set_score(cur_game, get_score(cur_game) + get_click(cur_game)); - } - - if (ch == 'q') + switch (ch) { - break; - } - - if (ch == 'u') - { - if (get_score(cur_game) >= 2 * get_multiplifier(cur_game)) - { - set_score(cur_game, get_score(cur_game) - get_click(cur_game) * 2); - set_click(cur_game, get_click(cur_game) * get_multiplifier(cur_game)); - } + case ' ': + set_score(cur_game, get_score(cur_game) + get_click(cur_game)); + break; + case 'q': + goto endwin; + case 'u': + if (get_score(cur_game) >= 2 * get_multiplifier(cur_game)) + { + set_score(cur_game, get_score(cur_game) - get_click(cur_game) * 2); + set_click(cur_game, get_click(cur_game) * get_multiplifier(cur_game)); + } + break; } } /* Remove the main window and exit */ - endwin(); + endwin: endwin(); + + printf("You have got %d points.\n", cur_game->score); + exit(EXIT_SUCCESS); } int -- cgit v1.2.3