The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsActually, I just figured out a really simple way of doing this.
function moveInsect(nameOfIns, origX, origY, speedIns)
{
if (nameOfIns._x<origX-100) {
nameOfIns._rotation = random(180);
speedIns += -10+random(25);
} else if (nameOfIns._x>origX+100) {
speedIns += -10+random(25);
nameOfIns._rotation = random(180)*-1;
} else if (nameOfIns._y<origY-100) {
nameOfIns._rotation = 90+random(180);
speedIns += -10+random(25);
} else if (nameOfIns._y>origY+100) {
nameOfIns._rotation = (270+random(180));
speedIns += -10+random(25);
}
if (speedIns>40) {
speedIns = 15;
}
nameOfIns._x += speedIns*Math.sin(nameOfIns._rotation*Ma th.PI/180);
nameOfIns._y += -speedIns*Math.cos(nameOfIns._rotation*M ath.PI/180);
}
this way, all you I do is make the speed rotation random and it does the rest. The link you gave me was packed with too much code for something I just wanted to be in the background. But Thanks :)
At 2/21/09 05:04 PM, The-Mercenary wrote: The link you gave me was packed with too much code for something I just wanted to be in the background
That's an older version of the enemy ai script i wrote. Here is the newer, optimized version: http://www.freeactionscript.com/2009/01/
random-movement-random-direction-change/
-PR