if(distance(x, y, player.x, player.y)<200)
{
// move to player
}
else
{
// move randomly
}
int previous_dir=dir;
do
{
dir=rand(4);
}while(dir==(previous_dir+2)%4);
if(distance(x,y,player.x,player.y)<200)
{
// code that determines direction to move in
}
else
{
// code that is already in the collision event (random choice)
}
Users browsing this forum: No registered users and 1 guest