Question about random numbers.

Game Editor comments and discussion.

Question about random numbers.

Postby HillBilly » Tue Nov 21, 2006 1:43 am

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.
HillBilly
 
Posts: 68
Joined: Thu Jun 08, 2006 4:31 am
Location: OHIO, USA
Score: 4 Give a positive score

Re: Question about random numbers.

Postby makslane » Wed Nov 22, 2006 12:10 am

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.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest