Is there a fast way to fill array cells?

Get help using Construct 2

Post » Sun Jul 14, 2013 11:35 am

Whatsup everyone,

I was wondering if there is a fast way to fill cells in an array grid.
I have a room that is 6400x6400 and im using 32x32 pixel tiles i have my ground level at 3200x3200 in the layout.
My question is how do i fill half of my layout with my ground tiles in such a way where i do not have to individually place what goes in each cell.
I ask this because i know there has to be a trick to doing this or i will have to place 200 blocks.

I understand how to place blocks through arrays i just want to know if there is a fast way to fill half of a layout
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sun Jul 14, 2013 2:07 pm

Use loops?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Sun Jul 14, 2013 3:53 pm

Loops are your friend, specifically For Each Element in the Array object. If you need an example give me a bit and I'll throw one together for you. If you don't know how loops work, check out this tutorial (shameless plug )

https://www.scirra.com/tutorials/40/basic-loops-and-arrays
B
55
S
12
G
9
Posts: 339
Reputation: 9,574

Post » Sun Jul 14, 2013 9:04 pm

@sqiddster @cow_trix

Thank you both,I never knew that loops are made to help with this issue.But i still do not understand how to make it run through certain cells.Like if 1-320
I guess im looking for the expressions used? or even better would be to see what you guys mean.
Thanks for replying,I know that it sounds lame but i am learning from all of this.Thanks
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Sun Jul 14, 2013 9:25 pm

Well, have you looked into 'for each element'? Or are you only wanting to fill specific cells?

Loops and arrays go together very well - you can't really use arrays to their full potential without knowing how they go with loops. Maybe look at some array tutorials?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,699

Post » Sun Jul 14, 2013 9:35 pm

@sqiddster I am trying to create the starting foundation for my game,I just want to call for specific cells that in this case would be my Ground to be created only once.
I have seen alot of the tutorials but it isnt helping me like the forums.
I actually just got done looking at the link cow_trix provided.
Like i was saying in my first post i only am trying to create my ground,I Know how to place Tiles in array cells Individually i understand that part.
I just need to know how to place a bunch of tiles at once without having to call each cell one by one.
You guys told me loops but i dont understand how to use them.Thanks for replying guys
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 15, 2013 12:31 am

@cow_trix could you explain what you mean when you say i can use the 'For function you said this in you tutorial.

A for loop can be considered a subcategory of a while loop. It is used when you know how many iterations you want, e.g.

1
For 0 to 9
2
      Print "Hello!"
This will print "Hello!" 10 times. It's important to remember Construct 2 (and a lot of programming languages) are zero-based as a rule (however, this can get confusing when we get to Arrays, but don't worry about that just yet).

You Said to use this,But you never went into detail on how to use this ingame.If you or anyone else could fill me in it would be very helpful.I really need to use this method to fill half of my layout with tiles.RookieDev2013-07-15 00:33:54
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 15, 2013 2:28 am

Check this out, see if it makes any more sense.
cow_trix2013-07-15 04:29:54
B
55
S
12
G
9
Posts: 339
Reputation: 9,574

Post » Mon Jul 15, 2013 2:30 am

@cow_trix its 404 for me.The link isnt working and thanks for replying man RookieDev2013-07-15 02:32:36
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 15, 2013 2:32 am

ImageImageImage
B
71
S
22
G
248
Posts: 3,756
Reputation: 138,058

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 49 guests