diff --git a/w/w.c b/w/w.c index 534ae52..1e84493 100644 --- a/w/w.c +++ b/w/w.c @@ -73,7 +73,7 @@ char charatpos(int x, int y) { return ' '; } - return map[ (mapsize - y - 1) * mapsize + x]; + return map[y * mapsize + x]; } void loadmap() @@ -102,11 +102,10 @@ void loadmap() void drawmap() { - for (int i = 0; i < mapsize; i++) { - int y = mapsize - i - 1; - for (int j = 0; j < mapsize; j++) { - char toprint = map[i * mapsize + j]; - if (y == state.position.y && j == state.position.x) + for (int y = 0; y < mapsize; y++) { + for (int x = 0; x < mapsize; x++) { + char toprint = charatpos(x,y); + if (y == state.position.y && x == state.position.x) { if (state.position.orientation == NORTH) toprint = '^'; if (state.position.orientation == SOUTH) toprint = 'v'; @@ -293,19 +292,19 @@ void updatepov() { case NORTH: newX += rtoloffset; - newY += frontoffset; + newY -= frontoffset; break; case SOUTH: newX -= rtoloffset; - newY -= frontoffset; + newY += frontoffset; break; case EAST: newX += frontoffset; - newY -= rtoloffset; + newY += rtoloffset; break; case WEST: newX -= frontoffset; - newY += rtoloffset; + newY -= rtoloffset; break; } pov[2 - frontoffset][1 + rtoloffset] = charatpos(newX, newY); @@ -320,10 +319,10 @@ void forward() switch (state.position.orientation) { case NORTH: - state.position.y += 2; + state.position.y -= 2; break; case SOUTH: - state.position.y -= 2; + state.position.y += 2; break; case EAST: state.position.x += 2; @@ -484,14 +483,20 @@ void update(char command[CMD_LEN]) // hero attacks state.monster.hp--; - // monster attacks - state.hero.hp--; - if (state.monster.hp <= 0) { state.hero.gold += state.monster.gold; state.screen = SC_MAP; } + else + { + // monster attacks + state.hero.hp--; + if (state.hero.hp <= 0) + { + // game over ? + } + } } } @@ -499,7 +504,7 @@ void update(char command[CMD_LEN]) void debugoutput() { - + //drawmap(); } void draw()