Created the cursor object, and it moves!
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
#include <stdlib.h>
|
||||
#include "../lib/util.h"
|
||||
#include "../lib/game.h"
|
||||
#include "../lib/cursor.h"
|
||||
#include "../lib/keyboard.h"
|
||||
|
||||
int main(int argc, const char *argv[]) {
|
||||
int option;
|
||||
struct cursor *cursor;
|
||||
|
||||
initialize_curses();
|
||||
|
||||
greet_player();
|
||||
|
||||
while (1) {
|
||||
while (option != KEY_SPACEBAR) {
|
||||
switch (option = getch()) {
|
||||
case KEY_SPACEBAR:
|
||||
initialize_game();
|
||||
@@ -22,8 +24,33 @@ int main(int argc, const char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
allocate_cursor(&cursor);
|
||||
initialize_cursor(cursor);
|
||||
draw_cursor(cursor);
|
||||
|
||||
while (1) {
|
||||
key_event();
|
||||
switch (option = getch()) {
|
||||
case 'h':
|
||||
case KEY_LEFT:
|
||||
move_cursor(cursor, LEFT);
|
||||
break;
|
||||
case 'j':
|
||||
case KEY_DOWN:
|
||||
move_cursor(cursor, DOWN);
|
||||
break;
|
||||
case 'k':
|
||||
case KEY_UP:
|
||||
move_cursor(cursor, UP);
|
||||
break;
|
||||
case 'l':
|
||||
case KEY_RIGHT:
|
||||
move_cursor(cursor, RIGHT);
|
||||
break;
|
||||
case 'q':
|
||||
case 'Q':
|
||||
end_curses();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
|
||||
Reference in New Issue
Block a user