How do I Create a complex grid with Arrays

0 favourites
  • 2 posts
From the Asset Store
Snap to visible grid - perfect solution for any game genre
  • Hey all,

    So i went about trying to create a grid with the help of arrays, and i pretty much was able to do it with the help of 'For loops' and loopindexes. But it's only simple square or rectangle grids that i can create by manipulating the start/end indexes of the For loops. What i want to achieve is complex grids. For example a grid that looks like a circle, or where every even/odd row/column is shorter than the next row/column, or a grid with a hole in the center. Basically the ability to manipulate the grid with variables. I've grinded to a halt trying to get my head around it.

    If anyone can lead me to a possible solution, i'd really appreciate it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Without diagrams, .capx or more concrete requirements we can only guess, for example, how you expect a grid to be like a circle.

    Using arrays for grids is not mandatory, but is common given that a 2d array does logically map to a 2d grid.

    So assuming arrays are the go, you can contain a lot of information in an array element to describe each grid space. The simplest would be a single value to denote what the grid space 'is'. For example a zero could be an empty space, which is one way to get your 'grid with hole' you mentioned.

    You could also have a string/text in each element with each character meaning something. For example "0100450899" could mean 'a space with color w, texture x , height y and width z, or whatever.

    Basically it's up to your code to interpret the array contents and draw the grid appropriately. If that's what you mean by 'manipulate the grid with variables'.

    You could also have separate arrays to hold different information about the same grid. The possibilities are endless.

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