Runtime Error "Out of Data"

Blitz3D Forums/Blitz3D Beginners Area/Runtime Error "Out of Data"

Hi All, I am a noobie to Blitz3D. I'm not actually using the 3D components yet as I'm trying to wrap my head around 2D games still. Anyway, I've got a problem. I'm Trying to create a maze game using a single wall bitmap and data statements. The code appears to generate the maze, but also a dialogue box "Out of Data". Now being the newbie I am, I cant find the problem. I am trying to keep this maze code as simple as I can. Anyway, here is the source. Hope it comes up in those little code windows..... Any help would be greatly appreciated.

; Basically learning how to draw maps based on data statements
; it works except I receive: "Out of Data" error

Graphics 640,480
SetBuffer BackBuffer()

Global gfxwall = LoadImage("wall12.png")   ; load 32x32 pixel wall image

While Not KeyHit(1)
	Cls
	y=25 ; dont start drawing at the top of the screen
	For t = 0 To 14 ; read down the data
		For x = 15 To 480 Step 32
			Read i
			If i<>0 Then	; only draw the tile if the data = 1
				DrawImage gfxwall,x,y
			EndIf
		Next ;x
		y=y+32 ; make sure you dont overwrite tiles.
	Next ;y
	
	Flip	
Wend
End


Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,0,1,1,0,1,0,1,0,1,0,1,1,0,1
Data 1,0,0,1,0,1,0,1,0,1,0,1,1,0,1
Data 1,0,0,0,0,0,0,0,0,1,0,0,0,0,1
Data 1,0,1,0,0,1,1,1,0,1,0,1,1,0,1
Data 1,1,1,1,0,1,1,1,1,1,0,1,1,0,1
Data 1,0,0,0,0,1,1,0,0,0,0,0,1,0,1
Data 1,0,1,1,0,1,0,0,1,1,1,0,1,0,1
Data 1,0,0,0,0,1,0,1,1,1,0,0,1,0,1
Data 1,0,1,0,1,1,0,1,1,1,1,0,1,1,1
Data 1,0,1,1,1,0,1,0,0,0,1,1,1,0,1
Data 1,0,0,0,0,0,0,0,0,0,0,0,0,0,1
Data 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1


Cheers.

sorry the code didnt work like I thought it would :-(

Use [ brackets instead of < to get it to appear in 'green'

Data statements read sequentially - so after your first loop the read statement is trying to read past the end of your data 'block' A better method would be to read the data before entering the loop and storing its results in an array, or a type, or a 2 dimensional array. Also check the 'restore' command which is also used with data.

Thanks for all that Matty. I will go give what you said a try :-)

Cheers

What are the forum codes?
Note that you can edit your posts by clicking on the Edit link at the top right of your posts.

The code tries to read 15 rows of data when there are only 14.


For x = 15 To 480 Step 32

DrawImage gfxwall,x,y



its easier to debug if you do something like:
For x = 1 To 14

DrawImage gfxwall, x * 32, y

easier to see only 14 lines of data, then change the for x loop to x = 0 to 14

multiplying the loop variables, makes it easier to spot where the lack of data is
personal preference though.

Thanks to everyone that posted and helped with this. I am still tweeking and poking things at Blitz Basic to see what I can do with it. So far I am really impressed. But unfortunately I dont currently have the programming knowledge to put everything together to make a game. But that will come with practice, practice and more practice.