Fix map addressing

This commit is contained in:
Petr Baudis 2011-11-26 22:00:16 +01:00
parent 2c83064fa9
commit a72882a743
2 changed files with 3 additions and 3 deletions

View file

@ -8,7 +8,7 @@
int
main(int argc, char *argv[])
{
class map map(10, 10);
class map map(40, 20);
srandom(time(NULL));

4
map.h
View file

@ -44,14 +44,14 @@ public:
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
tiles[y * h + x] = new tile_ground(x, y, *this);
tiles[y * w + x] = new tile_ground(x, y, *this);
}
}
};
class tile &tile_at(int x, int y)
{
return *tiles[y * h + x];
return *tiles[y * w + x];
};
void print_map(void);