Randomising for dummies.
Author: | David Evans
|
Submitted: | 23rd October, 2002
|
Views: | 4988
| Rated: |
|
|
Need any help with randomising?
Want to run a random event?
Want to play a random sound?
Want to jump to a random level?
This artical is for you!
Ok - Basic randomising:
In the expresion editor type:
RANDOM
where n is the range between the numbers. This will return a number from 0 to n-1.
or type:
RANDOM+z+1
where n is the range between the numbers and z is the minimum number. This will return a number from z to (z+n).
To run a random event:
In the level editor insert an object and call it VALUES. In the event editor in the event where it trigers the random event put:
VALUES value A = random
(Where n is the number of events)
Then for the events write:
If VALUES value A = 0 (event)
If VALUES value A = 1 (event 2)
etc.
For random sounds...
Repeat the above code but put sounds in the (event) bit.
For jumping to random levels:
Ah... This is harder than the above randomising... You'll proberbly want it to go to a level that it hasn't been to before. So...
In the level editor insert a fastloop object and an active object called VALUES.
In the event editor write:
Start of level: Change global value (level) to 1.
Event that calls the code: VALUES value A = random
(where n is the number of levels.)
if VALUES value A = 1 AND global value 1 = 0: jump to level 1
if VALUES value A = 2 AND global value 2 = 0: jump to level 2
etc.
if VALUES value A = 1 AND global value 1 = 1: VALUES value A = random
etc.
If you want to, put this in a fastloop to speed it up.
Bye!
|
|
|