Quick Data Example By Doctor
Originally Posted at Home Brew Forums.
Just a quick example of reading data in Blitz Basic:
;Data example
Graphics 640,480,16,2
SetBuffer BackBuffer()
Global blocks=10 ; amount of blocks
Dim x(blocks) ; starting x position of each block
Dim y(blocks) ; starting y position of each block
Dim r(blocks) ; amount of red in each block
Dim g(blocks) ; amount of green in each block
Dim b(blocks) ; amount of blue in each block
For a = 1 To blocks ; For every block
Read x(a) ; read x pos
Read y(a) ; read y pos
Read r(a) ; read red amount
Read g(a) ; read green amount
Read b(a) ; read blue amount
Next
While Not KeyDown(1) ;repeat loop till escapeis pressed
Cls
update_blocks()
Flip
Wend
Function update_blocks()
For a = 1 To blocks ; For every block
Color 255,0,0
Color r(a),g(a),b(a) ; set colour and
Rect x(a),y(a),50,50 ; draw block
Next
End Function
; here is the data. It is read as:
; x position, y position, red value, green value, blue value
Data 10,10,250,0,0
Data 60,60,0,250,0
Data 110,110,250,20,0
Data 160,160,250,0,50
Data 210,210,50,0,100
Data 260,260,250,250,0
Data 310,310,0,250,250
Data 360,360,50,50,50
Data 410,410,250,0,100
Data 460,460,250,250,250



