diff options
Diffstat (limited to 'ncursor.c')
-rw-r--r-- | ncursor.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ncursor.c b/ncursor.c new file mode 100644 index 0000000..93c3f07 --- /dev/null +++ b/ncursor.c @@ -0,0 +1,30 @@ +#include <stdlib.h> +#include <ncurses.h> +#include <stdbool.h> + +int main(int argc, char **argv) +{ + initscr(); + raw(); + noecho(); + + int row, col; + getmaxyx(stdscr, row, col); + + int x = 0, y = 0; + + bool run = true; + while (run) { + char c = getch(); + switch (c) { + case 'w': if (x > 0) x--; break; + case 's': if (x < (row - 1)) x++; break; + case 'a': if (y > 0) y--; break; + case 'd': if (y < (col - 1)) y++; break; + case 'x': run = false; break; + } + move(x, y); + } + + endwin(); +} |