How Do I learn Arrays? Tips/Questions

Get help using Construct 2

Post » Sun Jun 30, 2013 9:41 pm

Whatsup peeps!! I finally learned the basics about arrays and how to place them. Thank you @California @mystazsea @brent_hamel

I have a few more questions about arrays that need to be asked.Ok here they are

1. I understand how to set individual tiles through SET VALUE AT (1,1) to 1
But what is another function for me to use to fill the layout from a certain point specified.
for instance I have a 3200x3200 size layout,In array format that is 100x100 because im using 32x32 size pixels lets say I wanted to start my tile generation at (50,1) to 1 how could I just go ahead and tile the rest of the way down.

2.how can i be more specific with how I generate tiles. For example if i want to make my ground have 5 rows of dirt then for the next 5 after that switch to stone and so on.

3.How can i make better random generation?

Basically I just need to know the functions to call on to make this alittle easier. When I say functions I could also mean Expressions im kinda confused of the 2for some reason. TheNewGuy2013-06-30 21:50:26
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sun Jun 30, 2013 9:58 pm

There are some really good tutorials on this site that will help bring you up to speed :

https://www.scirra.com/tutorials/307/arrays-for-beginners/page-1

(not read it but seems to be what you are looking for)

Once you have grasped arrays, from the looks of it, you will want to look into 'creating your own level editor' (i have seen something on the forums about this do a search and you'll find it). This will cover everything you need to know.dsarchy2013-06-30 21:59:26
B
14
S
3
G
5
Posts: 41
Reputation: 3,490

Post » Sun Jun 30, 2013 10:10 pm

@dsarchy thank you for your reply but that is something I have seen quite a bit. Not everyone learns the same way. What might be laid out in front of you as basic to some, could be hard to learn for others.

Im just looking for some tips on expressions that would benefit me in my case.
I know the basics.I just need some helpful tips on good expressions to use.
TheNewGuy2013-06-30 22:12:47
B
9
S
5
Posts: 126
Reputation: 1,295

Post » Sun Jun 30, 2013 10:51 pm

You basically have to do several things its more of a group of events rather than just a couple of expressions.

a) Create an array to hold your data
b) Fill that array with map data (this is where the level editor comes in)
c) Loop through that array (X,Y) and then place them as tiles on the layout/canvas offsetting the xpox and ypos of the tiles by the tile size * the array index

In trying to answer your questions :

1. leave the top rows blank (no data) or have your array size set to 50 tiles high and then offet before you start to draw it out on the layout.

2. You will need to either manually add them or loop through the array and then check the value of the tile, if that tile is dirt then check if the tile above is also dirt, if it is then if there are values for three tiles above rewrite them as stone, if not then 2, if not then just the one.

3. More advanced

http://www.scirra.com/forum/better-random-terrain-via-midpoint-displacement_topic46616.html


If your not getting it I would recommend trying to create a Noughts and Crosses game with arrays, that will cover most of what you need to know without having to worry about having so many blocks.
B
14
S
3
G
5
Posts: 41
Reputation: 3,490

Post » Mon Jul 01, 2013 6:31 am

1) Use the the "for" loop condition to set ranges in an array. For example with a array of size 100x100 this will set the bottom right quarter of it to one:
For "col" from 50 to 99
For "row" from 50 to 99
--- Array: set at (loopindex("col"), loopindex("row")) to 1

2)Same answer as for 1, just use different ranges with the for loops.

3) There are a few topics on this. Best results come from finding a method and tweaking it till it's satisfactory. If you specify exactly what you want the terrain to look like then we could help you better.
B
91
S
31
G
99
Posts: 5,192
Reputation: 65,670


Return to How do I....?

Who is online

Users browsing this forum: Hiddendanger, plinkie and 2 guests