Hey guys! I'm trying to create a 2D array and 'draw' it, It doesn't work as expected. I used a function some guy posted in another topic. My code:
'Import Falling
Import mojo
Const MapWidth=20
Const MapHeight=15
Class FallingGame Extends App
Field Map:=ArrayCreate(20,15)
Method OnCreate()
Local I:Int
Local J:Int
For I=0 To MapWidth-1
For J=0 To MapHeight-1
Map[I][J]=1
End
End
SetUpdateRate(30)
End
Method OnRender()
Cls()
Local I:Int
Local J:Int
For I=0 To MapWidth-1
For J=0 To MapHeight-1
DrawText(I*16,J*16,Map[I][J])
End
End
End
End
Function Main()
New FallingGame()
End
'================================
Function ArrayCreate:Int[][](rows:Int, cols:Int)
Local a:Int[][] = New Int[rows][]
For Local i:Int = 0 Until rows
a[i] = New Int[cols]
End
Return a
End
What I get: http://prntscr.com/4cr34z
Could somebody help me? Thanks in advance! :)
|