Community

AGI Programming => Mega Tokyo AGI Archive => Topic started by: Patrick on April 21, 2002, 04:47:12 PM

Title: Random Objects
Post by: Patrick on April 21, 2002, 04:47:12 PM
 I was playing KQ3 and I noticed the squirrels and stuff that randomly appeared on the screen and I thought WOW :o ! I wish I could put that in my game!

Does anyone know how to do this?   :D ;) :)
Title: Re:Random Objects
Post by: Chris Cromer on April 21, 2002, 04:57:34 PM
Easy, use the random command and make it so that if it generates a certain number then draw the things that need to be drawn on the screen.

If you would like a more in depth explanation of this just ask.
Title: Re:Random Objects
Post by: Nick Sonneveld on April 21, 2002, 10:16:24 PM
random(n,m,k)

where variable k is assigned a number between the range of n to m.

So if you want to display monkeys on the screen 30% of the time.. you could do something like this:

if (newroom) {
 random(0, 100, v100);
 if (v100 < 30)
 {
   //load, draw, display, animate monkeys
 }
}

- Nick
Title: Re:Random Objects
Post by: Patrick on April 22, 2002, 03:19:09 PM
So is v100 just like saying it is this much percent or is v100 a variable  ???
Title: Re:Random Objects
Post by: Chris Cromer on April 22, 2002, 04:29:30 PM
useing the code above v100 will be set to a number from 0 to 100. and if v100 is less than 30 then it will animate monkeys.... I thought this was funny. :)
Title: Re:Random Objects
Post by: Joel on April 22, 2002, 05:57:00 PM
yeah, to clear that up...it doesn't have to be v100...if you put v145 instead of v100 in the code above, then v145 will be set to a value between 0 and 100
Title: Re:Random Objects
Post by: Nick Sonneveld on April 22, 2002, 06:59:05 PM
sorry.. bad example
Title: Re:Random Objects
Post by: Chris Cromer on April 22, 2002, 07:06:37 PM
No, it was a good example, but you didn't really show him what each part did, that is why he got confused.
Title: Re:Random Objects
Post by: Nick Sonneveld on April 22, 2002, 07:09:35 PM
I meant having 100 and v100 together..  i mentioned the syntax for random at the start i thought.

thanks though.

- Nick