mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Fix map addressing
This commit is contained in:
parent
2c83064fa9
commit
a72882a743
2 changed files with 3 additions and 3 deletions
2
main.cc
2
main.cc
|
@ -8,7 +8,7 @@
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
class map map(10, 10);
|
class map map(40, 20);
|
||||||
|
|
||||||
srandom(time(NULL));
|
srandom(time(NULL));
|
||||||
|
|
||||||
|
|
4
map.h
4
map.h
|
@ -44,14 +44,14 @@ public:
|
||||||
|
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
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)
|
class tile &tile_at(int x, int y)
|
||||||
{
|
{
|
||||||
return *tiles[y * h + x];
|
return *tiles[y * w + x];
|
||||||
};
|
};
|
||||||
|
|
||||||
void print_map(void);
|
void print_map(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue