Here, try this:
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, March 04, 2012
Rem ***** Main Source File *****
dim GameBoardBubble(8)
restore GridData
for x = 1 to 8
read GameBoardBubble(x)
next x
gosub SortItOut
repeat
gosub DisplayTheArray
until spacekey() = 1
end
SortItOut:
for y = 1 to 8
For x = 2 to 8
If GameBoardBubble(x) = 0 ` check if current position is a 0
// swap with the previous one
GBTEMP=GameBoardBubble(x - 1) ` if so store the 0 in GBTEMP
GameBoardBubble(x - 1) = 0
GameBoardBubble(x ) = GBTEMP
endif
Next x
next y
return
DisplayTheArray:
cls
for y = 1 to 8
text 10,y * 30,str$(y) + ": " + str$(GameBoardBubble(y))
next y
return
GridData:
data 2,0,3,1,0,2,4,5
EDIT: Here it is with both dimensions:
Rem ***** Main Source File *****
Rem Project: Dark Basic Pro Project
Rem Created: Sunday, March 04, 2012
dim GameBoardBubble(8,8)
for x = 1 to 8
restore GridData
for y = 1 to 8
read GameBoardBubble(x,y)
next y
next x
gosub SortItOut
repeat
gosub DisplayTheArray
until spacekey() = 1
end
SortItOut:
for z = 1 to 8
for y = 2 to 8
For x = 1 to 8
If GameBoardBubble(x,y) = 0 ` check if current position is a 0
// swap with the previous one
GBTEMP=GameBoardBubble(x,y-1) ` if so store the 0 in GBTEMP
GameBoardBubble(x,y-1) = 0
GameBoardBubble(x,y) = GBTEMP
endif
Next x
next y
next z
return
DisplayTheArray:
cls
for y = 1 to 8
text 10,y * 30,str$(y) + ": "
for x = 1 to 8
text 10 + (x * 30),y * 30,str$(GameBoardBubble(x,y))
next x
next y
return
GridData:
data 2,0,3,1,0,2,4,5
So many games to code.......so little time.