Page 1 of 1

Question about random numbers.

PostPosted: Tue Nov 21, 2006 1:43 am
by HillBilly
HEY all. I am messing with Game Editor again :D :D :D

I have a quick question for you guys and gals.

Anyways I am wanting to make a random actor placement script (that part I got), but I want to make sure it does not place anything too close to my players actor.

What I have is this:

x=rand(600);
y=rand(430);
x=x+20; These just move actors away from the edge of my boarder
y=y+20;
CreateActor("BlueTriLt", "BlueTriLt", "(none)", "(none)", x, y, true);


This script makes my actors fine other than it will put it on top of my players actor.


What I need is something like this:

x=rand(600);
y=rand(430);
x=x+20;
y=y+20;
if x=290 to 350 then x=rand(600); pick a new number
else
if y=210 to 270 then y=rand(430); pick a new number
else
CreateActor("BlueTriLt", "BlueTriLt", "(none)", "(none)", x, y, true);



I hope that makes sense. :roll:

Also one other question. How can I destroy all actors, other than my players actor, at the end of level.

Re: Question about random numbers.

PostPosted: Wed Nov 22, 2006 12:10 am
by makslane
HillBilly wrote:if x=290 to 350 then x=rand(600);


Try:

Code: Select all
x = 300;
while(x >= 290 && x <= 350) x = rand(600);


How can I destroy all actors, other than my players actor, at the end of level.


If you have an actor enemy, just just use:

Code: Select all
DestroyActor("enemy");


To destroy all clones of enemy actor.