@MisterBull:
What can I do as a simple alternative?
You could use Arrays.
Strict
Import Mojo
Class Program Extends App
Field _map1:Int[][] = [ [1,2,1,2,1,2,1,2,1,2,1,2,1,2,1],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,2],
[1,0,2,0,2,0,2,2,2,0,0,0,0,0,1],
[2,0,2,2,2,0,0,2,0,0,0,0,0,0,2],
[1,0,2,0,2,0,2,2,2,0,0,0,0,0,1],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,2],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[2,0,0,0,0,0,0,0,0,0,0,0,0,0,2],
[1,0,0,0,0,0,0,0,0,0,0,0,0,0,1],
[2,1,2,1,2,1,2,1,2,1,2,1,2,1,2] ]
Method OnCreate:Int()
SetUpdateRate 30
Return 0
End
Method OnRender:Int()
Cls 128,128,128
For Local y:Int = 0 To 9
For Local x:Int = 0 To 14
If _map1[y][x] = 1 Then DrawRect x*16,y*16,16,16
If _map1[y][x] = 2 Then
SetColor 255,0,0
DrawRect x*16,y*16,16,16
Endif
SetColor 255,255,255
Next
Next
Return 0
End
End
Function Main:Int()
New Program
Return 0
End
More like ReadData:
Strict
Import Mojo
Global _map1:Int[] = [ 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
1,0,2,0,2,0,2,2,2,0,0,0,0,0,1,
2,0,2,2,2,0,0,2,0,0,0,0,0,0,2,
1,0,2,0,2,0,2,2,2,0,0,0,0,0,1,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
2,0,0,0,0,0,0,0,0,0,0,0,0,0,2,
1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,
2,1,2,1,2,1,2,1,2,1,2,1,2,1,2 ]
Class Program Extends App
Method OnCreate:Int()
SetUpdateRate 30
Return 0
End
Method OnRender:Int()
Local index:Int = 0
Local a:Int
Cls 128,128,128
For Local y:Int = 0 To 9
For Local x:Int = 0 To 14
a = _map1[index]
index += 1
If a = 1 Then DrawRect x*16,y*16,16,16
If a = 2 Then
SetColor 255,0,0
DrawRect x*16,y*16,16,16
Endif
SetColor 255,255,255
Next
Next
Return 0
End
End
Function Main:Int()
New Program
Return 0
End
|