Created the cursor object, and it moves!

This commit is contained in:
Murilo Soares Pereira
2010-04-20 01:10:42 -03:00
parent ebe1be2d55
commit 4c9336f944
5 changed files with 154 additions and 4 deletions

View File

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