Array Scaling- How do you do it?

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi there,

    I'm currently working on an asteroid exploration game, and I'm using cellular automata with arrays to create procedural cave systems.

    I'm having difficulty though scaling an array. What I would like to do is a low resolution pass with my algorithm, then copy that data to a larger array in which the algorithm would then be applied to smooth things out a little, but my solution doesn't seem to be working.

    So, basically, I want to take this data in one array

    XOO

    OOO

    OOX

    and turn it in to this data in another array

    XXXXOOOOOOO

    XXXXOOOOOOO

    XXXXOOOOOOO

    XXXXOOOOOOO

    OOOOOOOOOOO

    OOOOOOOOOOO

    OOOOOOOOOOO

    OOOOOOOOOOO

    OOOOOOOXXXX

    OOOOOOOXXXX

    OOOOOOOXXXX

    OOOOOOOXXXX

    You can find the .cap file here

    Is this another time when Construct can't decide whether 0 or 1 is the first number?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You could calculate the ratio of X to O's in a single line, then expand accordingly. Then do this for every line.

    eg: 4:1 then divide the new line size by 5. 4* that are X, 1* that are O.

  • I suppose I could do it that way...I was just wondering why a simpler way I had created which looped over the smaller array and for each of its cells, populating 16 cells in the larger array with the value in the small array cell wasn't working.

    <img src="http://dl.dropbox.com/u/15091348/code.png" border="0" />

    Was hoping for less lines of code, and hopefully less values needing to be stored.

  • Right, I've changed it all to for loops, and its still not iterating over the array properly... I have changed the preview image and the .cap file.

  • That's alot of nested for loops you use there. I'm not sure but I think they'd work better as actual sub-events for each loop rather than all being in the same one.

    Edit: Also, that Repeat 2 times event is triggered every tick. This means in 2 ticks it will perform those actions 4 times. Maybe add a trigger once to the top of the conditions for that, or have it as a function called once (and then on called > repeat 2 times).

  • Augh, I am such a fool!

    Sorry guys, just worked out the problem. The tileset was performing the if action on the wrong array, and the scaling was very easy to fix, it needed to be Array1.Value(loop1x*4 - loop2x, loop1y*4- loop2y).

  • Here's another way to scale the array by setting the large array by sampling from the small array.

    + System: Trigger once

    + LargeArray: For Each element

    -> LargeArray: Set index (LargeArray.CurrentX, LargeArray.CurrentY) to AsteroidArray (int((LargeArray.CurrentX-1)/4)+1, int((LargeArray.CurrentY-1)/4)+1)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)