2d array question

Get help using Construct 2

Post » Tue Apr 08, 2014 6:06 pm

I have an array of 2 dimensions to represent a tiled map.

In the array there's one value named "Player". How do I find its position in the array? (the x and y coordinates)

IndexOf seem to be only for one dimensional array?

Thank you.
B
58
S
18
G
13
Posts: 447
Reputation: 10,735

Post » Tue Apr 08, 2014 6:23 pm

Well, there is probably an easier way, but you can just do 2 Repeat loops using array.width and array.height as the number of iterations. Use some local variables to keep track of the coordinates (i.e. x, y) In the inner loop, test if Array.At(x,y) = Player. If so, stop loop and there you go.
B
33
S
7
G
8
Posts: 312
Reputation: 8,528


Return to How do I....?

Who is online

Users browsing this forum: beohs, brunopalermo and 10 guests