Procedural Arrays

Get help using Construct 2

Post » Mon Jan 21, 2013 9:39 pm

Hi, I'm confused about creating a simple but procedural 2d map.

First of all I think I should use neighbor technique such as;

if (0,0) = 1 then (1,0) is more likely equals to 1

or maybe more advanced but I don't know if it's efficent we can use;

Array Map:

2 3 1
1 X 3
1 2 1

Sum = sum of neighbor tiles values. In this example its 1(there are four pieces 1, two pieces 2 and two pieces 3)
X value is more likely to neighbor sum value.

To understand basics. First I randomly created an 2d array with random(3) to their values.

Then with a button click, I wanted to activate my procedur but it works differently. I looked
for each xy element,
if current array's value is different with array.front value then
randomize50(2)
if randomize50 = 1 then set current value as array.fronts value
if randomize50 = 0 then it's still at same value.

But it seems it chooses a value, and equals all arrays to that value as I click to button.
-------------------------------
I don't know how can I reach to all neighbors ? Maybe with array.at(cur.x-1,cury) and so on.

Maybe you already recognised, when I click to button, it doesn't create tiles at final x and y lines. How Can I prevent it to count if there is no array (-1,0) or (0,-1) or (array.width+1) I think reason of that problem is about that.
-------------------------------
Finally if I can resolve these problems, I may probably solve this but anyway I want to ask, how can I prevent array to create same value in range of X. For example if there is value 3 at (5,5) then if there are more value 3 at range of 2 (6,6)(7,7)(6,7)(7,6) and so on, then randomize that array till there aren't any 2 value at range.

Here is my cap file.
https://dl.dropbox.com/u/56268958/test-procedural.capx
B
7
S
1
G
1
Posts: 76
Reputation: 904

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 33 guests