Array problem

For questions about using Classic.

Post » Thu Dec 13, 2012 7:58 am

I apologize if this question has been asked before.

I am having trouble with the array object. I put values in (X,X,1) for a 2D array, but when I debug all I'm getting are the values for the first set of numbers like its a 1 dimensional array (X,1,1). I don't understand why.
B
3
Posts: 59
Reputation: 418

Post » Thu Dec 13, 2012 2:20 pm

The debugger will only display a 1d array regardless if your array is 2d or 3d.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Dec 13, 2012 5:05 pm

That makes the debugger kind of useless for arrays doesn't it?

Is there other way I can check the values in those positions that wont show up?
B
3
Posts: 59
Reputation: 418

Post » Thu Dec 13, 2012 11:58 pm

I'm trying to build a grid system in code (invisible grid) and thought an array would be the best option.

I wanted the array grid to change values (0 = false, 1 = true) if an object was covering those corresponding potions on the game field.

I tried a few variations of:

Start of Layout
->Set Array size to X=layoutWidth/gridsize Y=layoutHeight/gridsize

Fox "x" from 0 to layoutWidth/gridsize
Fox "y" from 0 to layoutHeight/gridsize
--If object is over gridsize*loopindex("x"),gridsize*loopindex("y")
->Set Array Index (loopindex("x"),loopindex("x")) to 1
--Else
->Set Array Index (loopindex("x"),loopindex("x")) to 0

But the array just wont recognize if something has been placed over the corresponding coordinates.

Can I not use the array this way?
B
3
Posts: 59
Reputation: 418

Post » Wed Dec 19, 2012 5:57 pm

its a lot easy're to use the (for each element)condition than dealing with custom loops if your checking everything in an array.

further more, just convert the point your checking to a point in the array
so:
set value: x to round(.x / 128) set value: y to round(.y / 128)or whatever your tile sizes are.
and just work with those values, Its just a lot easier to deal with.
B
6
S
2
G
5
Posts: 249
Reputation: 2,323


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests