by skydereign » Tue May 26, 2009 11:16 pm
Well, when it comes to this, you could use a 2d array, as it would be an exact representation. One problem is making a single actor type to recognize the two dimensions of the array. Well, if you have a 3x3 grid, then in array subs, it looks like this
([0][0]) ([1][0]) ([2][0])
([0][1]) ([1][1]) ([2][1])
([0][2]) ([1][2]) ([2][2])
-sorry this diagram might be confusing
This is fine, as when you clone them, it follows cloneindex for the first three. So the clone needs to know which array sub it is, you will need cloneindex and use the xy gird size to find which. The 4th tile would need to be linked to [0][1]. Since the x dimension is 3, we can use its cloneindex of 3 to determine its x and y.
x would be cindex%SizeY // 3%3 ==0
y would be cindex/SizeY // 3/3 ==1
You could also use a normal array and the referencing would be done different. I use a one dimensional struct array which holds the xy, since only the clone needs to know those coordinates, for the most part, and that each clone can find its own xy as shown above. But it would be easier to use the method suggested above.
Now that you have an array that can hold values for the grid, you can use your clones xy values to access that grid, which can hold what animpos. I tried not to give away to much so you can still make it yourself, but if anything doesn't make sense or you would like further explanation, feel free to ask.