How do I randomly go through all elements of a tilemap/array

Get help using Construct 2

Post » Mon Aug 04, 2014 6:27 am

How do I randomly go through all elements of a tilemap/array ? I'm trying to make a level's intro like this one, so I will need to do the following:

- select a random element
- modify/change it
- wait 0.2 seconds
- go to next random element
- repeat the above until i've gone through all the elements

How can I do this using C2's events ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Mon Aug 04, 2014 11:32 am

Populate a list in non repeating numbers in an array using random.
After that, go to each element in the array in order.

While array.width<your level
>-set variable to random
>-array contains variable- do nothing
>-else- push variable to top

array.width> level
>-every 0.2 seconds
>--go to element.arrayAt(someothervariable)
>-- add 1 to someothervariable
Image ImageImage
B
169
S
50
G
174
Posts: 8,325
Reputation: 110,794

Post » Mon Aug 04, 2014 12:03 pm

I think you could do it like this....
Not sure wether this is the best way.

https://dl.dropboxusercontent.com/u/108480585/randomexample.capx

By clicking the Button you pick a random rectangle and make it dissapear

In the array "1" means is dissapeared and "0" means is still visible.
B
6
S
1
Posts: 30
Reputation: 1,059

Post » Mon Aug 04, 2014 12:48 pm

Last edited by mrcgkh on Mon Aug 04, 2014 4:53 pm, edited 1 time in total.
B
21
S
8
G
6
Posts: 177
Reputation: 8,134

Post » Mon Aug 04, 2014 3:09 pm

Here's an exemple with a Tilemap.
You do not have the required permissions to view the files attached to this post.
B
71
S
30
G
25
Posts: 984
Reputation: 19,503

Post » Mon Aug 04, 2014 5:28 pm

@newt @Naxos84 @mrcgkh @Magistross

Thank you for your examples :D
B
49
S
15
G
6
Posts: 534
Reputation: 7,195


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 44 guests