Array question

Get help using Construct 2

Post » Mon Sep 09, 2013 3:32 am

What expression would I use during "for each XY element" to set a 10x28 array to...

00,01,02,03,04,05,06,07,08,09,
10,11,12,13,14,15,16,17,18,19
20,21,22,23,24,25,26,27,28,29

...and so on?

I had this working before but no longer have the .capx. It was really simple, too! Just can't think of it atm -.-;;
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Mon Sep 09, 2013 2:39 pm

for from 0 to Array.width
--for from 0 to array.height

Wrote this from my smartphone so hope its right.
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Mon Sep 09, 2013 3:52 pm

There are multiple ways to do this. Here is one way:

For each XY Element
   (
   Set Value at (Array.CurX, Array.CurY) to (Array.CurY * Array.Width + Array.CurX)
   )zatyka2013-09-09 15:52:50
B
63
S
19
G
8
Posts: 341
Reputation: 12,130

Post » Mon Sep 09, 2013 6:27 pm

Another way :

for i = 0 to Array.Width * Array.Height - 1
--Set Array.At(i % Array.Width, int(i/Array.Width)) = i
B
69
S
28
G
24
Posts: 977
Reputation: 18,739


Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 12 guests