To randomly spawn sprites in different places do I........

Get help using Construct 2

Post » Thu Dec 01, 2016 1:43 pm

What i am trying to do is randomly make a layout on a side scrolling game.
I am going to spawn sprites like trees, hills and bushes onto a layout but to make it look different to the last layout i am going to randomly spawn these sprites in boxes in areas on the layout.

I dont know how to write code so can anybody confirm if i have this code right?

Box: Spawn another object: Tree Image Point: Random(10)

Will the Random(10) pick 1 of 10 image points in the box at random?
B
8
S
1
Posts: 51
Reputation: 577

Post » Thu Dec 01, 2016 2:29 pm

random(x)
Generate a random float from 0 to x, not including x. E.g. random(4) can generate 0, 2.5, 3.29293, but not 4. Use floor(random(4)) to generate just the whole numbers 0, 1, 2, 3.

random(a, b)
Generate a random float between a and b, including a but not including b.
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Thu Dec 01, 2016 2:41 pm

you can also use choose(1,2,3) or choose(a,b,c), it'll randomly pick one of the variables written inside the ()
Image
B
107
S
24
G
18
Posts: 1,361
Reputation: 22,770


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi, unicornspitfire and 19 guests