Which Side Is Open?
Posted: Wed May 25, 2011 11:11 am
I have this "control" actor and when a certain time limit goes by I want him to keep picking random sides until one is open. But for some reason it only seems to work some times? I have this code:
which is GOD AWFUL. I really should have done a loop, but that's only a minor problem. When the actors are created they don't really fit to the 25 X 25 grid they should... hence the +/- 2's in there at random spots (which still don't help enough)
Does anyone have any idea why this would be/how to fix it? The actor created is a square 25 X 25 and so is the control actor, and it's positioned on the grid. The created actors also use this code and the closer to the middle it is the more it seems to be messed up...? Oh well, cheers and thanks for at least reading this.
- Code: Select all
SPOT:
i = rand(5);
switch(i)
{
case 1:
if(CollisionFree("Event Actor", x+25,y))
CreateActor("virus", "virus", "(none)", "(none)", 0, 0, false);
else
goto SPOT;
break;
case 2:
if(CollisionFree("Event Actor", x+2,y+25))
CreateActor("virus", "virus", "(none)", "(none)", 0, 0, false);
else
goto SPOT;
break;
case 3:
if(CollisionFree("Event Actor", x-25,y))
CreateActor("virus", "virus", "(none)", "(none)", 0, 0, false);
else
goto SPOT;
break;
case 4:
if(CollisionFree("Event Actor", x+2,y-25))
CreateActor("virus", "virus", "(none)", "(none)", 0, 0, false);
else
goto SPOT;
break;
}
which is GOD AWFUL. I really should have done a loop, but that's only a minor problem. When the actors are created they don't really fit to the 25 X 25 grid they should... hence the +/- 2's in there at random spots (which still don't help enough)
Does anyone have any idea why this would be/how to fix it? The actor created is a square 25 X 25 and so is the control actor, and it's positioned on the grid. The created actors also use this code and the closer to the middle it is the more it seems to be messed up...? Oh well, cheers and thanks for at least reading this.