aboutsummaryrefslogtreecommitdiffstats
path: root/ncursor.c
blob: 93c3f07fd9c0ba883bbc30af46366af135fec41c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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();
}