projects
/
dungeon1
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add map readings and movements based on map stuff
[dungeon1]
/
main.c
diff --git
a/main.c
b/main.c
index
e9c5604
..
af24677
100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-9,14
+9,12
@@
int
main(void)
{
int
main(void)
{
- int x, y;
+ int x, y, x2, y2;
WINDOW *win;
int c;
WINDOW *win;
int c;
- enum {
- W = 80,
- H = 24,
- };
char c2;
char c2;
+ struct map *map;
+ int gold=0;
win = initscr();
noecho();
win = initscr();
noecho();
@@
-27,6
+25,9
@@
main(void)
intrflush(stdscr, FALSE);
*/
intrflush(stdscr, FALSE);
*/
+ map = readmap("map1");
+ showmap(map);
+
mvprintw(0, 20, "%d:%d", W, H);
move(H/2, W/2);
refresh();
mvprintw(0, 20, "%d:%d", W, H);
move(H/2, W/2);
refresh();
@@
-36,44
+37,53
@@
main(void)
break;
}
getyx(win, y, x);
break;
}
getyx(win, y, x);
- addch('.');
+ x2 = x;
+ y2 = y;
switch (c) {
case KEY_LEFT:
case 'h':
switch (c) {
case KEY_LEFT:
case 'h':
- if (x > 0) {
- x--;
- }
+ x2 = x - 1;
break;
case KEY_RIGHT:
case 'l':
break;
case KEY_RIGHT:
case 'l':
- if (x < W) {
- x++;
- }
+ x2 = x + 1;
break;
case KEY_UP:
case 'k':
break;
case KEY_UP:
case 'k':
- if (y > 1) {
- y--;
- }
+ y2 = y - 1;
break;
case KEY_DOWN:
case 'j':
break;
case KEY_DOWN:
case 'j':
- if (y < H) {
- y++;
- }
+ y2 = y + 1;
break;
}
break;
}
- c2 = mvinch(y, x) & 255;
- switch (c2) {
+ if (y2 < 0 || y2 > H || x2 < 0 || x2 > W) {
+ continue;
}
}
- mvprintw(0, 40, "<%c>", c2);
- mvprintw(0, 0, "%d:%d", x, y);
+ c2 = mvinch(y2, x2) & 255;
+ mvprintw(0, 40, "<%c> gold:%d", c2, gold);
move(y, x);
move(y, x);
+ switch (c2) {
+ case '$':
+ gold++;
+ mvaddch(y2, x2, ' ');
+ /* FALL */
+ case ' ':
+ mvprintw(0, 0, "%d:%d", x2, y2);
+ move(y2, x2);
+ break;
+ case '>':
+ mvprintw(H/2, 10, "AUSGANG gefunden!");
+ goto exit;
+ }
+
refresh();
napms(10);
}
refresh();
napms(10);
}
+exit:
+ getch();
endwin();
return 0;
}
endwin();
return 0;
}