How do I create a general area array checker?

0 favourites
  • 4 posts
From the Asset Store
Enlist the menacing fleet commander of the galactic star force in your next game audio production.
  • The nitty gritty of this is that I want to check for a value within a certain section of an array to activate a specific action.

    Here's how I want my system to work-

    Should any element in a certain section of an array be more than 0, the area corresponding to that section would be lit up on the map.

    I've so far been unable to acheive this, if anyone could provide some insight that would be much appreciated !

  • How are your array and map set up? What are you using to light up your map?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The map is comprised of 16*16 tiles, each corresponding to a single elment in the array

    Each section is 10 elements long and 8 elements high and are arranged in a grid.

    "Lit up" basically just means that that section of the map is considered "on" which probably doesn't mean anything to anyone but me but that's the best way to describe it

  • First thing that comes to mind would be to use an instance variable to define and group objects (tiles) into sections, and pick them directly via that instance variable to act on them. This wouldn't require an array at all.

    If you have to use an array, you could use a 3d array with a depth of 2. The "first layer" (z=0) would be your array values with x/y indexes corresponding to their respective tiles. The "second layer" (z=1) would contain information about which section each x/y pair belongs in.

    Then when you trigger a check of your array to see if any cells contain a value greater than 0, for example at x,y,0, then you can reference x,y,1 to see what section it belongs in. Once you have the section number, you can act on or light up every tile in that section by comparing the value in x,y,1 to see if it matches.

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