Author Topic: Random Objects  (Read 2072 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrick

Random Objects
« 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 ;) :)




Offline Chris Cromer

Re:Random Objects
« Reply #1 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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Nick Sonneveld

Re:Random Objects
« Reply #2 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
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Patrick

Re:Random Objects
« Reply #3 on: April 22, 2002, 03:19:09 PM »
So is v100 just like saying it is this much percent or is v100 a variable  ???


Offline Chris Cromer

Re:Random Objects
« Reply #4 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. :)
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Joel

Re:Random Objects
« Reply #5 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

Offline Nick Sonneveld

Re:Random Objects
« Reply #6 on: April 22, 2002, 06:59:05 PM »
sorry.. bad example
Nick Sonneveld  |  AGI Dev  |  NAGI

Offline Chris Cromer

Re:Random Objects
« Reply #7 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.
Chris Cromer

It's all fun and games until someone get's hurt then it's just fun. ;)

Offline Nick Sonneveld

Re:Random Objects
« Reply #8 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
Nick Sonneveld  |  AGI Dev  |  NAGI


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.063 seconds with 21 queries.