Created for a user on the forums but never actually posted because I was ninja’d.
This example has an array of names, each time space bar is pressed, a random name is chosen and moved to a new array. That name is then removed from the original array so the names are never repeated.
Here’s a quick example of counting how many times a certain value appears in an Array. Made for a user on the forums it counts the number of times “dog” and “cat” appears in the array and can easily be expanded to check for more values or different values depending on your project.
This is an example of how you can use “Bitwise Numbers”, a tilemap and an array in Construct 2 to automatically tile a level for you.
The example is based on my old Construct Classic tutorial which can be found on my old tutorials blog HERE and is based on a wonderful post by Salt on his blog. I recommend giving the blog post a read before opening the .capx as it explains the basics really well.
You can try the HTML5 Demo.
Use left click to place a tile, right click to remove, hold shift & left mouse button and drag to tile a rectangular area.
Here’s an example of loading a level stored as a text file into an array with no external plugins. Created for a user on the forums the example is a bit “hacky” but I created it to show that this sort of thing can be done without the need of external plugins. The example also shows saving the array to JSON and then in layout 2 loading the JSON into a different array.
The level is stored as below in the text file:
Quick note that this example only works with single digits to represent level data.
A quick example of how you could create basic random terrain for a platform or artillery type game. It uses an array to store the terrain data and the tilemap object to display it. Example is commented and covers Arrays, Tilemaps & “For” loops.
An example of how you can simply create a randomly generated dungeon/cave for your games. The example uses a “digging” approach to create the dungeon. It stores the dungeon data in an Array and tiles it using the “Tilemap” object. It’s a nice start to adding a procedurally generated level to your game and can be easily expanded upon.
Another array example created for a user on the Construct 2 forums. This time it will find the last time a certain value appears in a 1D array and returns that index. In the example the numbers are “0-5″ and it looks for the last index with a value of “0″. But can be easily changed to suit your needs.