Arrays in AppGameKit are not rectangular. You can think of them as more like array of arrays. When you define blarg as integer[2,2]. you create an array with 3 elements, each element containing an array of 3 elements of integers. When you do blarg.length = 8, now you have an array of 9 elements, the first three are still defined as arrays of 3 integers, the last 6 are not defined with length of -1. When you do blarg[0].length = 8, you now lengthen the first element of blarg to 9 elements of integers, leaving the next 2 at three, and the last 6 still undefined.
Hopefully, this will demonstrate what I'm trying to explain. Run it and you see the length of each element of blarg, press space to increase the size of blarg, press space again to increase the size of the first element of blarg.
// Project: hi
// Created: 2018-07-16
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "hi" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
//set array as 2x2
blarg as integer[2,2]
do
//print out the length of each element
for i = 0 to blarg.length
printc( right(" " + str(blarg[i].length),2) + " ")
next
if getrawkeypressed(32) = 1
if blarg.length = 2
blarg.length = 8 //increase on first keypress
elseif blarg[0].length = 2
blarg[0].length = 8 //increase on second keypress
endif
endif
sync()
loop
Edit: second example same as first, but numbers replaced by grid. Might make things a bit clearer.
// Project: hi
// Created: 2018-07-16
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "hi" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
text = createtext("blarg.length")
settextsize(text,16)
offsetx = GetTextTotalWidth(text)+20
SetTextPosition(text,10,10)
//set array as 2x2
blarg as integer[2,2]
do
//print out the length of each element
for x = 0 to blarg.length
drawbox(x*32+offsetx,0,x*32+offsetx+30,30,0xffff0000,0xffff0000,0xffff0000,0xffff0000,1)
for y = 0 to blarg[x].length
drawbox(x*32+offsetx,y*32+32,x*32+30+offsetx,y*32+62,0xffffffff,0xffffffff,0xffffffff,0xffffffff,1)
next
next
if getrawkeypressed(32) = 1
if blarg.length = 2
blarg.length = 8 //increase on first keypress
elseif blarg[0].length = 2
blarg[0].length = 8 //increase on second keypress
endif
endif
sync()
loop