Is it possible to get info from one array to another?

0 favourites
  • 2 posts
From the Asset Store
Array Editor
$0.25 USD
95% off
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hello,

    Actually it quite hard for me to describe my problem in title. So i will try here.

    I have three arrays ( all XY)

    array 1: X coordinates array ( has coords for X position of the object for creation)

    array 2: Y coordinates array ( has coords for Y position of the object for creation)

    array 3: and Position array ( has information like 0 and 1 in which positions to generate object)

    I have field 6 x 6. Where random 4 cells have 1 and others 0.

    I want to check which cells have 1 in it, then take this cell coordinates - and generate object by using coordinates of X and Y positions from first two arrays.

    Too bad it looks like that i can't use simple For each XY element of array 3 and put inside System create object X Array2name.CurX Y Array2name.CurY since i'm doing it in another array.

    I also can't store these Cell coordinates in values and then use create object X Array1name.ValueName Y Array1name.Valuename cause it only wants CurX or CurY.

    Any hints how to solve it.. if anyone understood what i want from these arrays.

    Or maybe there are more simply way... My goal is :

    i have grid of 6x6 elements. In each "cell" of this grid i want to spawn an object. Those are enemies..

    But i also want to generate a "free passage" tunnel from left to right by removing some of the objects in this grid that will make path for player. I want it to be randomly generated (example: it starts on second row..then follows 3 cells, then goes one down and then goes to end right..) each time it can be generated randomly on which row it starts, where this twist will be.

    Right now i'm stuck :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you should only need one array to do what you are describing, each row in the array can hold multiple values

    first entry:

    array(0,0) = x value, array(0,1) = y value, array(0,2) = Position

    second entry:

    array(1,0) = x value, array(1,1) = y value, array(1,2) = Position

    you would define the array size as (#entries,3,1)

    however, if you know you have a 6 x 6 grid, it should be pretty easy to calculate the x and y values when the position number is 1, unless I don't understand what you have in mind.

    it would help if you made a mock up of what the final screen would look like, the 6 x 6 grid, and safe path for the player to follow.

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