Makefile refactoring and introducing the 'test' rule.
* Moved the main source file to the lib directory * ttysolitaire rather than tty-solitaire
This commit is contained in:
40
lib/ttysolitaire.c
Normal file
40
lib/ttysolitaire.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <stdlib.h>
|
||||
#include <curses.h>
|
||||
#include "util.h"
|
||||
#include "game.h"
|
||||
#include "keyboard.h"
|
||||
|
||||
const char *program_name;
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
program_name = *argv;
|
||||
int key;
|
||||
|
||||
initialize_curses();
|
||||
greet_player();
|
||||
|
||||
while (key != KEY_SPACEBAR) {
|
||||
switch (key = getch()) {
|
||||
case KEY_SPACEBAR:
|
||||
initialize_game();
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
end_game();
|
||||
end_curses();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if ((key = getch()) == 'q' || key == 'Q') {
|
||||
end_game();
|
||||
end_curses();
|
||||
exit(0);
|
||||
} else {
|
||||
handle_keyboard_event(key);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
Reference in New Issue
Block a user