Array Output

Discussion and feedback on Construct 2

Post » Mon Jul 25, 2011 3:17 pm

Hi and sorry for spamming the forum with this problem, but i dont find a solution

I filled a 2-dimensional array with values, but on access they keep "0".
Can u help me put random entries of the array in the dataTxt textfield?

capx here.

I would love to continue this project, please help :)
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Jul 25, 2011 3:25 pm

The array has a width of 1 and a height of 2. So setting the element at, for example, (3,3) has no effect. It's outside the array! Click the array in the project or object bar to show its properties and make it as big as you need.

I would strongly advise you use Tiled Background objects wherever possible. Creating lots of sprites is really bad for performance. A tiled background, no matter how big, is as fast as a single sprite. So if you create 2500 grass sprites it's 2500 times slower than using a tiled background the same size.Ashley2011-07-25 15:28:08
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Mon Jul 25, 2011 3:38 pm

Did make the sprites for the array to insert the coordinates of the grid. As u can see, the background layer is the same but as tiled background. It's just for testing purposes.


I guess if i want a grid, i need the count of squares which build the grid...in this case 50*50=2500. So i did set the width now "2500". Every square has 2 variables, X and Y, so i did set the height now to "2".

Now the output doesn't work anymore, the textfield is not changing. What am i still doing wrong?

link
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Jul 25, 2011 4:09 pm

[QUOTE=Kyatric]
First thing to do in the startup is to set up the size of your array.
Action Array:Set size. Three fields again Width (X), Height (Y) and Depth (Z).[/QUOTE]

[QUOTE=Ashley] The array has a width of 1 and a height of 2. So setting the element at, for example, (3,3) has no effect. It's outside the array! Click the array in the project or object bar to show its properties and make it as big as you need.[/quote]

Your array is not of the right size. At the moment it is barely made of 2 elements.

Also there are redundances and unuseful events in your code (but that's not the main problem).
The stuff is you are relying on grass_q.Y to aim mapGrid's Y. This can't work, as grass_q.y may be as high as 900+ and mapgrid only has 2 Y.

Anyway check the corrected capx. It outputs both Y = 0 and Y = 1.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Jul 25, 2011 4:20 pm

Big Thanks :)

I just dont understand why you use "loopindex" for X and ".id" for Y. I guess i could take both the same, because .id is set to loopindex before, right?
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Jul 25, 2011 4:38 pm

Yes.
I was just messing around to find what was wrong with the version you posted at first. i just didn't change it back.

Two ways of doing the same stuff.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Mon Jul 25, 2011 5:15 pm

I'll add you to my friends list on scirra :D
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Jul 25, 2011 6:44 pm

Heres a tutorial http://www.scirra.com/forum/procedural-generation-for-beginnerspdf_topic43387.html?KW=procedurally+generated
B
3
G
1
Posts: 14
Reputation: 553


Return to Construct 2 General

Who is online

Users browsing this forum: andreyin, Eisenhans, shinichild and 8 guests