главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
path: root/clicker-ncurses.c
diff options
context:
space:
mode:
Diffstat (limited to 'clicker-ncurses.c')
-rw-r--r--clicker-ncurses.c37
1 files changed, 19 insertions, 18 deletions
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 <stdio.h>
-#include <stdlib.h>
#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <ncurses.h>
@@ -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