mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
position() constructor: Take map ref, not ptr
This commit is contained in:
parent
1eaf680111
commit
a131964cc0
2 changed files with 4 additions and 4 deletions
4
map.cc
4
map.cc
|
@ -43,7 +43,7 @@ position::next_in(int dir_x, int dir_y)
|
||||||
{
|
{
|
||||||
int x2 = (map->w + x + dir_x) % map->w;
|
int x2 = (map->w + x + dir_x) % map->w;
|
||||||
int y2 = (map->h + y + dir_y) % map->h;
|
int y2 = (map->h + y + dir_y) % map->h;
|
||||||
return new position(x2, y2, map);
|
return new position(x2, y2, *map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ map::print_map(void)
|
||||||
{
|
{
|
||||||
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++) {
|
||||||
class position p = position(x, y, this);
|
class position p = position(x, y, *this);
|
||||||
std::cout << tile_at(p).symbol();
|
std::cout << tile_at(p).symbol();
|
||||||
}
|
}
|
||||||
std::cout << '\n';
|
std::cout << '\n';
|
||||||
|
|
4
map.h
4
map.h
|
@ -26,11 +26,11 @@ public:
|
||||||
int x, y;
|
int x, y;
|
||||||
class map *map;
|
class map *map;
|
||||||
|
|
||||||
position(int x_, int y_, class map *map_)
|
position(int x_, int y_, class map &map_)
|
||||||
{
|
{
|
||||||
x = x_;
|
x = x_;
|
||||||
y = y_;
|
y = y_;
|
||||||
map = map_;
|
map = &map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class position *next_in(int dir_x, int dir_y);
|
class position *next_in(int dir_x, int dir_y);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue