Amon
Member
- Joined
- Nov 19, 2018
- Messages
- 89
I'm trying to read level data from a text file. I am definitely going about this the wrong way and I could do with some assistance. Code below for my LoadLevel function.
I'm not getting any output on screen because I think the way I'm reading the text file is wrong as well as how I am loading each int into the array. The loadLevel function is called here:
Cerberus:
Function LoadLevel:int(_level)
Local tempx:int = 0
Local tempy:int = 0
Local LevelArray:int[][] = Arrays<int>.CreateArray(15, 9)
Local CurrentLevel:string = LoadString("levels/level" + _level + ".txt")
For Local x:int = 0 Until CurrentLevel.Length()
LevelArray[tempx][tempy] = Int(Mid(CurrentLevel, x, 1))
Select LevelArray[tempx][tempy]
Case 1
Local c:Cube = New Cube(1, GreyBlock, 5, tempx * 64, tempy * 64, True)
Cube.list.AddLast(c)
print "GREY BLOCK"
End
tempx += 1
If tempx > 16
tempx = 0
tempy += 1
EndIf
Next
Return True
End
I'm not getting any output on screen because I think the way I'm reading the text file is wrong as well as how I am loading each int into the array. The loadLevel function is called here:
Cerberus:
Method Render:Void()
Cls
DrawText "GAME SCREEN!", SCREEN_WIDTH2, SCREEN_HEIGHT2, 0.5, 0.5
If KeyHit(KEY_1)
LoadLevel(1)
EndIf
If Cube.list <> Null
For Local c:Cube = EachIn Cube.list
c.Draw()
Next
EndIf
End