Another question about arrays

Get help using Construct 2

Post » Mon Feb 03, 2014 12:39 pm

Hi there,

I'm using an array to generate a map for my game and there's something I can't figure out how to do - simply, at least. My array is 150 cells (X) by 114 (Y), and at the start of my layout, I want to set all cells where X < 25, Y < 19, X > 125 and Y > 95 to 4.

4 is the reference number I'm using for a 'rock' tile, so hopefully this will generate an enclosed play area with rock tiles all around the edges. Feel like it should be quite simple to do, but I've been playing around with various expressions and I can't seem to figure out how - could anyone please help?
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Mon Feb 03, 2014 1:16 pm

something like

for "X" =25 to 125
--for "Y"= 19 to 95   - array set value at (loopindex("X"),loopindex"(Y")) to 4


where -- is a sub event

?

(not tested)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Mon Feb 03, 2014 1:23 pm

I must learn to read !

try again

something like

for "X" =0 to 150
--for "Y"= 0 to 114   - array set value at (loopindex("X"),loopindex"(Y")) to 4

for "X" =25 to 125
--for "Y"= 19 to 95   - array set value at (loopindex("X"),loopindex"(Y")) to 0

where -- is a sub event



?RamPackWobble2014-02-03 13:23:33
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Mon Feb 03, 2014 1:41 pm

yep - that appears to work :)

maybe not the best example ever about arrays
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Wed Feb 05, 2014 12:04 am

Perfect, thank you very much!
B
15
S
4
G
1
Posts: 286
Reputation: 1,988

Post » Wed Feb 05, 2014 8:18 pm

(Never even occurred to use For loops like that... that's going to be incredibly helpful in this project )
B
15
S
4
G
1
Posts: 286
Reputation: 1,988


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, dop2000 and 53 guests