data

BlitzPlus Forums/BlitzPlus Programming/data

hi,
i keep seeing people use the data command to create a tile-like look on their game. Like on platform games where they have different numbers translate to a different image.

example:

data 1,1,1,1,1
data 1,0,0,0,1
data 1,0,0,0,1
data 1,0,0,0,1
data 1,1,1,1,1

this would create like an outline sort of thing.

anyway if you understand a thing i tried to explain please help me out and show me how to do it.

thanks in advance.

I suppose this would be the most basic way to do that:
graphics 320, 240, 0, 2
setbuffer backbuffer()

;jump to first data
restore

for x = 1 to 5
for y = 1 to 5
  ;get number from data
  read filled
  ;if number = 1 then plot a pixel
  if (filled = 1) then plot x, y
next
next

flip

waitkey()
end

data 1,1,1,1,1
data 1,0,0,0,1
data 1,0,0,0,1
data 1,0,0,0,1
data 1,1,1,1,1

(the drawing is really small)

Like b32 said only bigger so you don't have to squint :)

sw = 800
sh = 600

Graphics sw,sh,32,2
SetBuffer BackBuffer()

;use 'box' data
Restore box

;change these for different size boxes
boxX = 48
boxY = 48

;pixel spacing between boxes
;change to 0 for no spacing
spacing = 2

For y = 0 To 4
	For x = 0 To 4
		;read a color (i.e. a number 1-4)
		Read colorData
		;Define your color scheme here
		Select colorData
			Case 0: Color 255,255,255
			Case 1: Color 255,  0,  0
			Case 2: Color   0,255,  0
			Case 3: Color   0,  0,255
			Case 4: Color 255,255,  0
			Default: Color 255,255,255
		End Select

		;Rect x*(boxX + spacing ), y*(boxY + spacing ), boxX, boxY, True
		
		;just add an offset to move the tiles  to where ever you want on screen (centered here)
		offSetX = (sw - (5 * (boxX + spacing))) /2
		offSetY = (sh - (5 * (boxY + spacing))) /2
		Rect x*(boxX + spacing ) + offSetX, y*(boxY + spacing ) + offSetY, boxX, boxY, True
		
	Next
Next

Text 5,560,"Left click to exit"

Flip

WaitMouse() ;wait for a mouse click to exit
End

.box
Data 4,1,1,1,1
Data 4,0,0,0,2
Data 4,0,0,0,2
Data 4,0,0,0,2
Data 3,3,3,3,2


This may interest you: http://www.blitzbasic.com/codearcs/codearcs.php?code=1987 you need to add the setcursorpos command in the user32 decls.

I'd avoid data statements and use one of the following:
- a binary file created by a map editor that goes into a 2d array.
- a set of functions that *create* high-level things like platforms, boxes etc. Then a map is a matter of performing some of those functions. Again going into a 2d array.

Data can be sufficient for 4 values orso, but when your map has like 256 different tiles, you aren't going to love data statements.

In addition: your signature is truly over-sized!

CS_TBL is absolutely correct, in that large, complex maps are best stored in binary files on disk.

Data statements are good for learning how to implement those binary files. Using data statements to change a small detail just change one of the values; instant gratification. Using binary files you'll need to use a small routine or better yet a map editor to update the map file.

Binary files are best used when you already know what you're doing, data statements can be useful while learning but you'll soon outgrow them.

Here's a small example of my 2nd point however, using functions to create a map. Note that I've been using a bank, but it's easy to see how to deal with it in the Showmap and Maprect functions.

Graphics 640,480

map=CreateMap(32,24)

Maprect map,0,0,32,24,255,100

Maprect map,1,1,30,22,32,100

For t=1 To 9
	Maprect map,1,1,30,22,32+(t*12),40
Next

Maprect map,0,4,8,2,255,100

Maprect map,8,12,8,4,255,100

Maprect map,24,16,6,4,255,100


Showmap Map

Flip

Repeat
Until KeyDown(1) ; Esc
End

Function Showmap(map)
	mapw=PeekShort(map,0)
	maph=PeekShort(map,2)
	For y=0 To maph-1
		For x=0 To mapw-1
			v=PeekByte(map,4+x+mapw*y) ; 'v' here contains the number of the tile (0..255 in this case)
			Color v,v,v
			Rect x*8,y*8,8,8,True
		Next
	Next
End Function

Function CreateMap(w,h)
	bank=CreateBank(w*h+4)
	PokeShort bank,0,w
	PokeShort bank,2,h
	Return bank
End Function

Function Maprect(map,px,py,w,h,v,chance)
	mapw=PeekShort(map,0)
	maph=PeekShort(map,2)
	If w<1 w=1
	If h<1 h=1	
	For y=0 To h-1
		For x=0 To w-1
			If InBox(x+px,y+py,0,0,mapw,maph)
				If Rnd(100)<=chance
					PokeByte map,4+(px+x+mapw*(py+y)),v
				EndIf
			EndIf
		Next
	Next
End Function

Function InBox(px,py,x,y,w,h)
	If px>=x And px<(x+w) And py>=y And py<(y+h) Return 1 Else Return 0
End Function


Your InBox function... You might want to look at rectsoverlap.

Yeah, well.. :P

In a number of cases, making a small function takes less time than finding something appropriate in the help. ^_^ Btw, this one works for 1 pixel, not for a rect.

I ran into a problem.
When i put cls in the loop the tiles aren't drawn.

Here's a loop in which to draw things:

-------------------
CLS

DrawAllYourStuff

FLIP
-------------------

i tried that but it says it ran out of data because i put the whole for...next loop in the main loop. I know im doing something wrong but i don't know how to fix it.

The standard forum answer: show us the code!

Oh wait, don't tell me, I know.. :P

You have your 'read' function inside the mainloop!

Wanna bet? :P

 Graphics 1280, 1024, 0, 2
SetBuffer BackBuffer()

Type bullet
	Field x#,y#
	Field xv#,yv#
	Field frame
End Type

Global bullet.bullet



cl1 = LoadImage("Images\Clouds\Cloud_1.bmp")
cl2 = LoadImage("Images\Clouds\Cloud_2.bmp")

pl1 = LoadImage("Images\Platforms\Platform_1.bmp")
pl2 = LoadImage("Images\Platforms\Platform_2.bmp")
pl3 = LoadImage("Images\Platforms\Platform_3.bmp")
pl4 = LoadImage("Images\Platforms\Platform_4.bmp")
pl5 = LoadImage("Images\Platforms\Platform_5.bmp")
pl6 = LoadImage("Images\Platforms\Platform_6.bmp")

wl1 = LoadImage("Images\Walls\Wall_1.bmp")
wl2 = LoadImage("Images\Walls\Wall_2.bmp")

vn1 = LoadImage("Images\Misc\Vine_1.bmp")

Global chtr = LoadAnimImage("Chtr.bmp",47,53,0,24)
	Global chtr_bullet = LoadAnimImage("Chtr_bullet.bmp",19,7,0,2)
	Global chtr_frame = 0
	Global cx# = 0
	Global cy# = 600 - ImageHeight(chtr)

	Global chtr_frame_t = MilliSecs()
	Global chtr_frame_ta = True
	Global chtr_frame_delay = 50
	Global chtr_freeze = 0
	Global chtr_jump = False
	Global chtr_yv# = 0
	
;jump to first data
Restore level1



While Not KeyHit(1)









UpdateBullet()
UpdatePlayer()

For y = 0 To 18
	
	For x = 0 To 24

		Read filled

		Select filled  
	
			Case 1
	
				DrawImage cl1,x*32,y*32
			
			Case 2
		
				DrawImage cl2,x*32,y*32
		
			Case 3
		
				DrawImage pl1,x*32,y*32
								
			Case 4
			
				DrawImage pl7,x*32,y*32
		
			Case 5
		
				DrawImage pl6,x*32,y*32
			
			Case 6
		
				DrawImage wl2,x*32,y*32

			Case 6
		
				DrawImage vn1,x*32,y*32
			
		End Select							
	
	Next
	
Next















Flip

Wend
End

Function UpdatePlayer()

DrawImage chtr,cx#,cy#,chtr_frame



;walk

If KeyDown(205)
	
	cx# = cx# + 2
	
	chtr_freeze = 0
	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	


		chtr_frame = chtr_frame + 1
	
		chtr_frame_ta = False
		
		If chtr_frame > 8
	
			chtr_frame = 0
		
		EndIf
		
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf KeyDown(203)
	
	cx# = cx# - 2
		chtr_freeze = 12

	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	

		
		chtr_frame = chtr_frame - 1
	
		chtr_frame_ta = False	
		
		If chtr_frame < 13
	
			chtr_frame = 23
		
		EndIf
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf Not KeyDown(203) And KeyDown(205)

	chtr_frame = chtr_freeze

	
EndIf

;end walk

;shoot
If KeyHit(57)

	If chtr_freeze = 0

		CreateBullet(cx# + (ImageWidth(chtr)/2),cy# + 20,20,0)
		
	ElseIf chtr_freeze = 12

		CreateBullet(cx#,cy# + 20,20,0)
		
	EndIf
	
EndIf

;end shoot

;Jump

If chtr_jump = False

If KeyHit(200)

	chtr_jump = True
	
	chtr_yv# = -5
	
EndIf

EndIf

If chtr_jump = True

	chtr_yv# = chtr_yv# + .1
	
EndIf

cy# = cy# + chtr_yv#

If cy# > 600 - ImageHeight(chtr)

	chtr_yv# = 0
	
	cy# = 600 - ImageHeight(chtr)

	chtr_jump = False

EndIf
;end jump

End Function


Function CreateBullet(x#,y#,xv#,yv#)

b.bullet = New bullet

b\x# = x#
b\y# = y#

b\xv# = xv#
b\yv# = yv#

	If chtr_freeze = 0
	
		b\xv# = b\xv#
		b\frame = 1
		
	Else
	
		b\xv# = -b\xv#
		b\frame = 0
		
	EndIf
	

End Function



Function UpdateBullet()

For h.bullet = Each bullet

	h\x# = h\x# + h\xv#
	
	If	h\x# < 0
	
		Delete h
		
	ElseIf h\x# > 800
	
		Delete h
		
	Else DrawImage chtr_bullet,h\x#,h\y#,h\frame
	
	EndIf
	
Next

End Function























.level1
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,3,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,3,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,3,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 



here is my code.
if i don't put the Read command in the main loop where do i put it

never mind i got it!!

finally!!

thanks for all the help!

hold on i thought i had it but it's not working again.

You could also put 'Restore' right before the first For..Next loop that reads the data.

Could someone post an example of how to use binary files with the code that I posted, or give an example that shows its use instead of data.

Sure .. at some point, you read the map from the Data.
Right after that, you can put this map in a file.
I made a 'short version' that shows this:
Const 	Map_Length=49
Const	Map_Height=49

Dim Map$(Map_Length,Map_Height)

;;;Goto skipsave ;;<-- remove the comments after running it once

	;------------------
	;read map from Data
	;------------------
		
		Restore level0
		For y=0 To Map_Height
			Read Value$ 
			For x=0 To Map_Length
				Map(x,y)=Mid(Value$,x+1,1)
			Next
		Next
	
	;------------------
	;write data to file
	;------------------
	   ff = WriteFile("map.dat")
	   For y = 0 To Map_Height
	       For x = 0 To Map_Length
	           WriteByte ff, Asc(Map(x, y)) 
			   ;you could also use WriteString, but this way, the file is smaller
	       Next
	   Next
	   CloseFile ff
	

.skipsave

;-------------------
;read data from file
;-------------------
   ff = ReadFile("map.dat")
   For y = 0 To Map_Height
       For x = 0 To Map_Length
           Map(x, y) = Chr$(ReadByte(ff))
		   ;Chr$ converts the number back into the app. character
       Next
   Next
   CloseFile ff

;---------
;test/show
;---------

Graphics 800, 600, 0, 2
Cls

For y = 0 To Map_Height
For x = 0 To Map_Length
	
	Text x * 12, y * 12, Map$(x, y)
	
Next
Next

WaitKey()
End


.level0
Data "00000000000000000000000000000000000000000000000000";1
Data "00000000000000000000000000000000000000000000000000";2
Data "00000000000000000000000000000000000000000000000000";3
Data "00000000000000000000000000000000000000000000000000";4
Data "00000000000000000000000000000000000000000000000000";5
Data "00000000000000000000000000000000000000000000000000";6
Data "00000000000000000000000000000000000000000000000000";7
Data "00000000000000000000000000000000000000000000000000";8
Data "00000000000000000000000000000000000000000000000000";9
Data "00000000000000000000000000000000000000000000000000";10
Data "00000000000000000000000000000000000000000000000000";11
Data "00000000000000000000000000000000000000000000000000";12
Data "00000000000000000000000000000000000000000000000000";13
Data "00000000000000000000000000000000000000000000000000";14
Data "00000000000000000000000000000000000000000000000000";15
Data "00000000000000000000000000000000000000000000000000";16
Data "00000000000000000000000000000000000000000000000000";17
Data "00000000000000000000000000000000000000000000000000";18
Data "00000000000000000000000000000000000000000000000000";19
Data "00000000000000000000000000000000000000000000000000";20
Data "00000000000000000000000000000000000000000000000000";21
Data "00000000000000000000000333000000000000000000000000";22
Data "0000000000000000G000003333300000000000000000000000";23
Data "3333333000033333Z333333333333333333333333333333333";24
Data "313F3DZ0000EZ333Z333333363333333333333333333333323";25
Data "3333333000033333Z333333333333333333333333333333333";26
Data "0000000000000000Z000003333300000000000000000000000";27
Data "00000000000000000000000333000000000000000000000000";28
Data "00000000000000000000000000000000000000000000000000";29
Data "00000000000000000000000000000000000000000000000000";30
Data "00000000000000000000000000000000000000000000000000";31
Data "00000000000000000000000000000000000000000000000000";32
Data "00000000000000000000000000000000000000000000000000";33
Data "00000000000000000000000000000000000000000000000000";34
Data "00000000000000000000000000000000000000000000000000";35
Data "00000000000000000000000000000000000000000000000000";36
Data "00000000000000000000000000000000000000000000000000";37
Data "00000000000000000000000000000000000000000000000000";38
Data "00000000000000000000000000000000000000000000000000";39
Data "00000000000000000000000000000000000000000000000000";40
Data "00000000000000000000000000000000000000000000000000";41
Data "00000000000000000000000000000000000000000000000000";42
Data "00000000000000000000000000000000000000000000000000";43
Data "00000000000000000000000000000000000000000000000000";44
Data "00000000000000000000000000000000000000000000000000";45
Data "00000000000000000000000000000000000000000000000000";46
Data "00000000000000000000000000000000000000000000000000";47
Data "00000000000000000000000000000000000000000000000000";48
Data "00000000000000000000000000000000000000000000000000";49
Data "00000000000000000000000000000000000000000000000000";50


the images aren't drawing can you guys show me how to do it

Type bullet
	Field x#,y#
	Field xv#,yv#
	Field frame
End Type

Global bullet.bullet


Here's an advice: stick to the common rule to call your types T<name> and the variable you're going to use bullet, so in this case: TBullet and bullet. (or Bullet, whatever you want) This makes the difference between a type definition and an instance more clear.

	Select filled  
			Case 1
				DrawImage cl1,x*32,y*32
			Case 2
				DrawImage cl2,x*32,y*32
			Case 3
				DrawImage pl1,x*32,y*32
			Case 4
				DrawImage pl7,x*32,y*32
			Case 5
				DrawImage pl6,x*32,y*32
			Case 6
				DrawImage wl2,x*32,y*32
			Case 6
				DrawImage vn1,x*32,y*32
; was this second case 6 supposed to be right??
		End Select	


You may want to consider arrays. Like Dim picture(10) can hold 10 images. Then in your draw routine you don't need to Select-Case on the value, you just draw the right picture from the array according to the mapvalue.
So if you mapvalue is 4, then:
DrawImage picture(mapvalue),x*32,y*32

draws image 4. This will especially be practical when you have 100+ tiles.. :P

In any case, when you're done experimenting with 'data', really consider working with binaries. Did you try/test my map-function example?

As for your code, the images are drawing, so I think they are not loaded. Try putting them in the same folder as your code first, as a test.
 Graphics 1280, 1024, 0, 2
SetBuffer BackBuffer()

Type bullet
	Field x#,y#
	Field xv#,yv#
	Field frame
End Type

Global bullet.bullet



cl1 = LoadImage("Images\Clouds\Cloud_1.bmp")
cl2 = LoadImage("Images\Clouds\Cloud_2.bmp")

pl1 = LoadImage("Images\Platforms\Platform_1.bmp")
pl2 = LoadImage("Images\Platforms\Platform_2.bmp")
pl3 = LoadImage("Images\Platforms\Platform_3.bmp")
pl4 = LoadImage("Images\Platforms\Platform_4.bmp")
pl5 = LoadImage("Images\Platforms\Platform_5.bmp")
pl6 = LoadImage("Images\Platforms\Platform_6.bmp")

wl1 = LoadImage("Images\Walls\Wall_1.bmp")
wl2 = LoadImage("Images\Walls\Wall_2.bmp")

vn1 = LoadImage("Images\Misc\Vine_1.bmp")

Global chtr = LoadAnimImage("Chtr.bmp",47,53,0,24)
	Global chtr_bullet = LoadAnimImage("Chtr_bullet.bmp",19,7,0,2)
	Global chtr_frame = 0
	Global cx# = 0
	Global cy# = 600 - ImageHeight(chtr)

	Global chtr_frame_t = MilliSecs()
	Global chtr_frame_ta = True
	Global chtr_frame_delay = 50
	Global chtr_freeze = 0
	Global chtr_jump = False
	Global chtr_yv# = 0
	
;jump to first data
Restore level1



While Not KeyHit(1)









UpdateBullet()
UpdatePlayer()

Restore
For y = 0 To 18
	
	For x = 0 To 24

		Read filled

		Select filled  
	
			Case 1
	
				DrawImage cl1,x*32,y*32
			
			Case 2
		
				DrawImage cl2,x*32,y*32
		
			Case 3
		
				DrawImage pl1,x*32,y*32
								
			Case 4
			
				DrawImage pl7,x*32,y*32
		
			Case 5
		
				DrawImage pl6,x*32,y*32
			
			Case 6
		
				DrawImage wl2,x*32,y*32

			Case 6
		
				DrawImage vn1,x*32,y*32
			
		End Select							
	
	Next
	
Next















Flip

Wend
End

Function UpdatePlayer()

DrawImage chtr,cx#,cy#,chtr_frame



;walk

If KeyDown(205)
	
	cx# = cx# + 2
	
	chtr_freeze = 0
	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	


		chtr_frame = chtr_frame + 1
	
		chtr_frame_ta = False
		
		If chtr_frame > 8
	
			chtr_frame = 0
		
		EndIf
		
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf KeyDown(203)
	
	cx# = cx# - 2
		chtr_freeze = 12

	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	

		
		chtr_frame = chtr_frame - 1
	
		chtr_frame_ta = False	
		
		If chtr_frame < 13
	
			chtr_frame = 23
		
		EndIf
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf Not KeyDown(203) And KeyDown(205)

	chtr_frame = chtr_freeze

	
EndIf

;end walk

;shoot
If KeyHit(57)

	If chtr_freeze = 0

		CreateBullet(cx# + (ImageWidth(chtr)/2),cy# + 20,20,0)
		
	ElseIf chtr_freeze = 12

		CreateBullet(cx#,cy# + 20,20,0)
		
	EndIf
	
EndIf

;end shoot

;Jump

If chtr_jump = False

If KeyHit(200)

	chtr_jump = True
	
	chtr_yv# = -5
	
EndIf

EndIf

If chtr_jump = True

	chtr_yv# = chtr_yv# + .1
	
EndIf

cy# = cy# + chtr_yv#

If cy# > 600 - ImageHeight(chtr)

	chtr_yv# = 0
	
	cy# = 600 - ImageHeight(chtr)

	chtr_jump = False

EndIf
;end jump

End Function


Function CreateBullet(x#,y#,xv#,yv#)

b.bullet = New bullet

b\x# = x#
b\y# = y#

b\xv# = xv#
b\yv# = yv#

	If chtr_freeze = 0
	
		b\xv# = b\xv#
		b\frame = 1
		
	Else
	
		b\xv# = -b\xv#
		b\frame = 0
		
	EndIf
	

End Function



Function UpdateBullet()

For h.bullet = Each bullet

	h\x# = h\x# + h\xv#
	
	If	h\x# < 0
	
		Delete h
		
	ElseIf h\x# > 800
	
		Delete h
		
	Else DrawImage chtr_bullet,h\x#,h\y#,h\frame
	
	EndIf
	
Next

End Function























.level1
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,3,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,3,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,3,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 


Function LoadImage(n$)

	im = CreateImage(64, 64)
	For i = 0 To 100
	  Color Rand(255), Rand(255), Rand(255)
  	  Oval Rand(64), Rand(64), 10, 10
	Next
	GrabImage im, 0, 0
	Return im
	
End Function

Function LoadAnimImage(n$, w, h, d, f)

	im = CreateImage(w, h, f)
	For fr = 0 To f - 1
	For i = 0 To 100
	  Color Rand(255), Rand(255), Rand(255)
  	  Oval Rand(64), Rand(64), 10, 10
	Next
	GrabImage im, 0, 0, fr
	Next
	Return im

End Function


everything is loaded fine. my problem is that i can't figure out what part of the code to in the main loop so they draw.

i know they're loaded because when i remove the Cls command the show but when i put it back in they don't because the drawimage commands aren't in the main loop.

Are we still talking about the code you posted above ? I've included the Cls command, and placed the character in the middle of the screen:
 Graphics 1280, 1024, 0, 2
SetBuffer BackBuffer()

Type bullet
	Field x#,y#
	Field xv#,yv#
	Field frame
End Type


cl1 = LoadImage("Images\Clouds\Cloud_1.bmp")
cl2 = LoadImage("Images\Clouds\Cloud_2.bmp")

pl1 = LoadImage("Images\Platforms\Platform_1.bmp")
pl2 = LoadImage("Images\Platforms\Platform_2.bmp")
pl3 = LoadImage("Images\Platforms\Platform_3.bmp")
pl4 = LoadImage("Images\Platforms\Platform_4.bmp")
pl5 = LoadImage("Images\Platforms\Platform_5.bmp")
pl6 = LoadImage("Images\Platforms\Platform_6.bmp")

wl1 = LoadImage("Images\Walls\Wall_1.bmp")
wl2 = LoadImage("Images\Walls\Wall_2.bmp")

vn1 = LoadImage("Images\Misc\Vine_1.bmp")

Global chtr = LoadAnimImage("Chtr.bmp",47,53,0,24)
	Global chtr_bullet = LoadAnimImage("Chtr_bullet.bmp",19,7,0,2)
	Global chtr_frame = 0
	Global cx# = 400
	Global cy# = 400 - ImageHeight(chtr)

	Global chtr_frame_t = MilliSecs()
	Global chtr_frame_ta = True
	Global chtr_frame_delay = 50
	Global chtr_freeze = 0
	Global chtr_jump = False
	Global chtr_yv# = 0
	
;jump to first data
Restore level1



While Not KeyHit(1)






Cls

Restore
For y = 0 To 18
	
	For x = 0 To 24

		Read filled

		Select filled  
	
			Case 1
	
				DrawImage cl1,x*32,y*32
			
			Case 2
		
				DrawImage cl2,x*32,y*32
		
			Case 3
		
				DrawImage pl1,x*32,y*32
								
			Case 4
			
				DrawImage pl7,x*32,y*32
		
			Case 5
		
				DrawImage pl6,x*32,y*32
			
			Case 6
		
				DrawImage wl2,x*32,y*32

			Case 6
		
				DrawImage vn1,x*32,y*32
			
		End Select							
	
	Next
	
Next

UpdateBullet()
UpdatePlayer()

Flip

Wend
End

Function UpdatePlayer()

DrawImage chtr,cx#,cy#,chtr_frame

;walk

If KeyDown(205)
	
	cx# = cx# + 2
	
	chtr_freeze = 0
	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	


		chtr_frame = chtr_frame + 1
	
		chtr_frame_ta = False
		
		If chtr_frame > 8
	
			chtr_frame = 0
		
		EndIf
		
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf KeyDown(203)
	
	cx# = cx# - 2
		chtr_freeze = 12

	
	If MilliSecs() > chtr_frame_t + chtr_frame_delay
	

		
		chtr_frame = chtr_frame - 1
	
		chtr_frame_ta = False	
		
		If chtr_frame < 13
	
			chtr_frame = 23
		
		EndIf
		
	EndIf
	
	If chtr_frame_ta = False
	
		chtr_frame_t = MilliSecs()
		
		chtr_frame_ta = True
		
	EndIf
	
ElseIf Not KeyDown(203) And KeyDown(205)

	chtr_frame = chtr_freeze

	
EndIf

;end walk

;shoot
If KeyHit(57)

	If chtr_freeze = 0

		CreateBullet(cx# + (ImageWidth(chtr)/2),cy# + 20,20,0)
		
	ElseIf chtr_freeze = 12

		CreateBullet(cx#,cy# + 20,20,0)
		
	EndIf
	
EndIf

;end shoot

;Jump

If chtr_jump = False

If KeyHit(200)

	chtr_jump = True
	
	chtr_yv# = -5
	
EndIf

EndIf

If chtr_jump = True

	chtr_yv# = chtr_yv# + .1
	
EndIf

cy# = cy# + chtr_yv#

If cy# > 600 - ImageHeight(chtr)

	chtr_yv# = 0
	
	cy# = 600 - ImageHeight(chtr)

	chtr_jump = False

EndIf
;end jump

End Function


Function CreateBullet(x#,y#,xv#,yv#)

b.bullet = New bullet

b\x# = x#
b\y# = y#

b\xv# = xv#
b\yv# = yv#

	If chtr_freeze = 0
	
		b\xv# = b\xv#
		b\frame = 1
		
	Else
	
		b\xv# = -b\xv#
		b\frame = 0
		
	EndIf
	

End Function



Function UpdateBullet()

For h.bullet = Each bullet

	h\x# = h\x# + h\xv#
	
	If	h\x# < 0
	
		Delete h
		
	ElseIf h\x# > 800
	
		Delete h
		
	Else DrawImage chtr_bullet,h\x#,h\y#,h\frame
	
	EndIf
	
Next

End Function























.level1
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,0,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,0,3,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,0,3,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,0,0,0,0,0,3,5,5,5,5,0,0,0,0,0,0,0,0,0,0,0,0,0,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
Data 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 


Function LoadImage(n$)

	im = CreateImage(64, 64)
	For i = 0 To 100
	  Color Rand(255), 0, 0
  	  Oval Rand(64), Rand(64), 10, 10
	Next
	GrabImage im, 0, 0
	Return im
	
End Function

Function LoadAnimImage(n$, w, h, d, f)

	im = CreateImage(w, h, f)
	For fr = 0 To f - 1
	For i = 0 To 100
	  Color 0, 0, Rand(255)
  	  Oval Rand(64), Rand(64), 10, 10
	Next
	GrabImage im, 0, 0, fr
	Next
	Return im

End Function

I replaced LoadImage/LoadAnimImage with a custom function, for testing. If you run it, you can see the blue thingie walk around the red thingies world.
If you comment the functions out, it should load the original image files again.

i finally got it every one. My mistake was not putting the restore command in the loop.

thanks for all the help!