mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
agent::move_dir(): Implement
This commit is contained in:
parent
56726a6c05
commit
b305a41cfc
3 changed files with 24 additions and 0 deletions
12
agent.cc
12
agent.cc
|
@ -13,3 +13,15 @@ agent::put_at(class tile &t)
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
agent::move_dir(int dir_x, int dir_y)
|
||||
{
|
||||
class tile *t2 = &tile->tile_in_dir(dir_x, dir_y);
|
||||
if (!t2->on_agent_enter(*this))
|
||||
return false;
|
||||
|
||||
tile->on_agent_leave(*this);
|
||||
tile = t2;
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue