Hello! i'm still semi-new to Construct 2 and i know that this has been questioned so many times, but i'm very interested in learning Construct 2's advanced stuff like Arrays or Functions. How exactly do i achieve Procedural Generation with Arrays and Tilemaps? I'm still confused on what an Array is and what it does and how i can use it properly, i have read alot of forums with the same topic as mine and i might even get the same answer! i don't expect a simple answer to this question. I have read this tutorial (https://www.construct.net/en/tutorials/smarter-procedural-roguelike-715) and i hope i will achieve the same effect with the knowledge i can gain from this forum.
If i can't get an explanation on how Procedural Generation is achieved on Construct 2 can i at least get an explanation for arrays and how i can use them for different things like weapon switching and such. Thank you in advance for whatever answer i can recieve.
Develop games in your browser. Powerful, performant & highly capable.
To generate something procedural you don't always need array. Array is kind of hash table which is collection of variables that defined by index or another analogy is cells in Excel spreadsheet that can be read and write values (number, string).
Arrays are basically just a way to store a lot of values.
If if just want a list of values you can use it as a 1 dimensional array with size (count, 1, 1).
Another common use, like in that tutorial, is to do a 2d array to have a value for every tile on a grid, or one value for every pixel of an image. So size (width,height,1).
Also in that tutorial it uses an array to store a list of the x,y,width and height of multiple rooms. So the size is (roomCount,4,1). 4 because there are four values: x,y,width,height.
You just need to keep in mind what those values mean. So for example you wanted to get the width of the 10th box in that list it would be:
It’s 10-1 instead of 10 because things count from 0 instead of one. And the 2 is for width. 0:x, 1:y, 2:width, 3:heights.
However, don’t tell me that’s easy to read. It’s rather obscure what it means at a glance.
All that tutorial is doing is:
1: place multiple different sized rectangles on the layout.
2: make paths that go horizontal then vertical between them.
3: draw it to the tilemap. Basically amounts to looping over the tiles under the rooms and paths.
4: once on the tilemap you can check the surrounding tiles to mark the ones on the edge as walls.
4b: in a similar fashion it colors the floor differently depending on what surrounds it.
Using an array instead of a tilemap directly is merely a preference.
R0J0hound Thank you for the response, this is really helpful, i'll try to learn how i can perfect arrays with your comment and my current knowledge about them. Have a good day!
alextro Thanks for your response, i actually read what arrays are on the C2 Documentation and only finished halfway, thanks for simplifying it to me! Good day.