Author Topic: Quick Data Example[BB2D]  (Read 388 times)

0 Members and 1 Guest are viewing this topic.

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7245
  • Karma: 71
    • View Profile
Quick Data Example[BB2D]
« on: January 17, 2007 »


Quick Data Example By Doctor
Originally Posted at Home Brew Forums.


Just a quick example of reading data in Blitz Basic:

Code: [Select]

;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
« Last Edit: July 21, 2007 by Shockwave »
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: