How do I Create a complex grid with Arrays

Get help using Construct 2

Post » Sat Aug 02, 2014 6:34 am

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.
Posts: 155
Reputation: 1,663

Post » Sun Aug 03, 2014 3:05 am

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.
Posts: 1,646
Reputation: 6,596

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests