home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter05 / demo05-03.bb < prev    next >
Encoding:
Text File  |  2003-04-06  |  1.0 KB  |  53 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; demo05-03.bb;;;;;;;;;;;;;;;;;;;;;
  3. ; By Maneesh Sethi;;;;;;;;;;;;;;;;;
  4. ; Creates an image and displays it!
  5. ; No input parameters required;;;;;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7. ;INITIALIZATION
  8.  
  9. ;Set up the graphics
  10. Graphics 640,480 
  11.  
  12. ;Seed the Random Generator
  13. SeedRnd MilliSecs() 
  14.  
  15. ;CONSTANTS
  16. ;The length of each block
  17. Const LENGTH = 100 
  18.  
  19. ;The height of each block
  20. Const HEIGHT = 100 
  21.  
  22. ;The amount of dots in each block
  23. Const DOTS  = 100 
  24. ;END CONSTANTS
  25.  
  26.  
  27. ;IMAGES
  28. ;Create the dotfield image
  29. dotfieldimage = CreateImage(LENGTH,HEIGHT) 
  30. ;END IMAGES
  31.  
  32. ;For each dot, draw a random dot at a random location
  33. For loop = 0 To DOTS ;For every star
  34.     ;draw only on created image
  35.     SetBuffer ImageBuffer(dotfieldimage) 
  36.     
  37.     ;Plot the dot
  38.     Plot Rnd(LENGTH), Rnd(HEIGHT) 
  39.     
  40. Next
  41.  
  42. ;Set buffer back to normal
  43. SetBuffer FrontBuffer() 
  44. ;END INITIALIZATION
  45.  
  46. ;MAIN LOOP
  47.  
  48. ;Tile the image until the user quits (presses ESC)
  49. While (Not KeyDown(1)) 
  50. TileImage dotfieldimage 
  51. Wend
  52.  
  53. ;END MAIN LOOP