map wont load

BlitzPlus Forums/BlitzPlus Programming/map wont load

GameCoder(Posted 2003) [#1]
here is my code

Graphics 800,600
SetBuffer BackBuffer()

Global platform = LoadAnimImage("platforms.png",32,32,0,2)

Global jump = 0
Global jumpheight = 10
Global frame = 0

Const gravity = 0.5

Dim map(25,19)

loadmap()

While Not KeyHit ( 1 )

	Cls

		drawmap()

	Flip

Wend
End

Function loadmap()
Restore leveldata

For y = 0 To 17

	Read level

		For x = 0 To 24

			map(x,y) = level

	Next
Next

End function

Function drawmap()

			For i = 0 To 17

			For x = 0 To 24

				If map(x,y) = 3 Then
					DrawImage platform,x*32,y*32,1
				EndIf 

			Next

		Next

End Function 

.leveldata
Data "2222222222222222222222222"
Data "2333333333333333333333332"
Data "2333333333333333333333022"
Data "2333333333333333333333332"
Data "2222222033333333333333332"
Data "2333333333322222222222222"
Data "2333333333333333333333332"
Data "2222222222222222222233332"
Data "2333333333333333333333332"
Data "2222233333333222222223322"
Data "2333333333333333333333332"
Data "2222222223333333222222232"
Data "2333333333333333333333332"
Data "2223322332233223322332232"
Data "2333333333333333333333332"
Data "2222222222233333333222222"
Data "2333333333333333333333332"
Data "2222222222222222222222222"



skidracer(Posted 2003) [#2]
instead of map(x,y)=level

you need something like:

map(x,y) = mid$(level,x+1,1)

which will extract each digit from the string individually


GameCoder(Posted 2003) [#3]
thx, i have put that code in and i still get a black screen

Thankyou for helping me by the way :)


Perturbatio(Posted 2003) [#4]

			For i = 0 To 17

			For x = 0 To 24

				If map(x,y) = 3 Then
					DrawImage platform,x*32,y*32,1
				EndIf 

			Next

		Next



the problem might be that you are using i instead of y in the first for loop


GameCoder(Posted 2003) [#5]
oh my god. I didnt see that. LMAO. Boy do I feel like an idiot.

Thankyou for that Perturbatio


Warren(Posted 2003) [#6]
I could bring up the need for variable declarations again, but I won't. ;)


Perturbatio(Posted 2003) [#7]
ok, don't :)