Initial commit: basic cursor movements
[dungeon1] / main.c
1 /*
2 ** dungeon1
3 **
4 ** 2021-12, markus schnalke <meillo@marmaro.de>
5 */
6
7 #include "main.h"
8
9 int
10 main(void)
11 {
12         int x, y;
13         WINDOW *win;
14         int c;
15         enum {
16                 W = 80,
17                 H = 24,
18         };
19         char c2;
20
21         win = initscr();
22         noecho();
23         cbreak();
24         keypad(stdscr, TRUE);
25 /*
26         nonl();
27         intrflush(stdscr, FALSE);
28 */
29
30         mvprintw(0, 20, "%d:%d", W, H);
31         move(H/2, W/2);
32         refresh();
33
34         while ((c = getch()) != ERR) {
35                 if (c == 'q') {
36                         break;
37                 }
38                 getyx(win, y, x);
39                 addch('.');
40                 switch (c) {
41                 case KEY_LEFT:
42                 case 'h':
43                         if (x > 0) {
44                                 x--;
45                         }
46                         break;
47                 case KEY_RIGHT:
48                 case 'l':
49                         if (x < W) {
50                                 x++;
51                         }
52                         break;
53                 case KEY_UP:
54                 case 'k':
55                         if (y > 1) {
56                                 y--;
57                         }
58                         break;
59                 case KEY_DOWN:
60                 case 'j':
61                         if (y < H) {
62                                 y++;
63                         }
64                         break;
65                 }
66                 c2 = mvinch(y, x) & 255;
67                 switch (c2) {
68                 }
69                 mvprintw(0, 40, "<%c>", c2);
70                 mvprintw(0, 0, "%d:%d", x, y);
71                 move(y, x);
72
73                 refresh();
74                 napms(10);
75         }
76
77         endwin();
78         return 0;
79 }
80