diff --git a/w/w.c b/w/w.c index 3686f08..b002bc7 100644 --- a/w/w.c +++ b/w/w.c @@ -33,11 +33,22 @@ Gamestate gamestate; void drawmap() { for (int i = 0; i < MAP_SIZE; i++) { + int y = MAP_SIZE - i - 1; + printf("%d", y); for (int j = 0; j < MAP_SIZE; j++) { - printf("%c", map[i][j]); + char toprint = map[i][j]; + if (y == gamestate.location.y && j == gamestate.location.x) + { + if (gamestate.location.orientation == 'n') toprint = '^'; + if (gamestate.location.orientation == 's') toprint = 'v'; + if (gamestate.location.orientation == 'e') toprint = '>'; + if (gamestate.location.orientation == 'w') toprint = '<'; + } + printf("%c", toprint); } printf("\n"); } + printf("0123456789\n"); } void loadstate() @@ -243,7 +254,7 @@ void updatepov() pov[2 - frontoffset][1 + rtoloffset] = charatpos(newX, newY); } } - + update3dpov(); } @@ -307,22 +318,6 @@ void left() } } -void move(char movement) -{ - switch (movement) - { - case 'f': - forward(); - break; - case 'r': - right(); - break; - case 'l': - left(); - break; - } -} - void dumpstate() { printf("Name:%s\nx:%d\ny:%d\norientation:%c\n", @@ -353,19 +348,19 @@ void update(char command) { switch (command) { - case 'f': - case 'r': - case 'l': - move(command); - updatepov(); + case 's': + forward(); break; - case 'm': + case 'x': + right(); break; - case 'd': + case 'w': + left(); break; default: break; } + updatepov(); } void draw() @@ -379,10 +374,10 @@ void draw() int shift = 10; for (int i = 0; i < shift; i++) printf("\n"); - + for (int i = 0; i < shift; i++) printf(" "); printf("o----------o\n"); - + for (int i = 0; i < 10; i++) { for (int s = 0; s < shift; s++) printf(" "); @@ -395,13 +390,14 @@ void draw() } for (int i = 0; i < shift; i++) printf(" "); printf("o----------o\n"); +} - /*printf("\n\n\n"); - printf(" o=======o\n"); + +void drawtopdownpov() +{ for (int y = 0; y < 3; y++) { - printf(" | "); for (int x = 0; x < 3; x++) { if (y == 0 && pov[1][1] != ' ') @@ -417,17 +413,10 @@ void draw() printf("%c", pov[y][x]); } } - printf(" |\n"); + printf("\n"); } - printf(" o=======o\n"); - printf(" | %s |\n", gamestate.name); - printf(" o=======o\n"); - printf("\n\n");*/ } - - - int main() { init(); @@ -436,8 +425,10 @@ int main() { update(command); draw(); + dumpstate(); + drawmap(); + drawtopdownpov(); command = getchar(); - getchar(); } savestate(); return 0;