home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter06 / demo06-05.bb < prev    next >
Encoding:
Text File  |  2004-08-28  |  666 b   |  31 lines

  1. ;demo06-05.bb - Demonstrates the usage of SaveBuffer
  2. Graphics 800,600
  3.  
  4. ;Seed the Random Generator
  5. SeedRnd (MilliSecs()) 
  6.  
  7. ;68 is keycode for f10
  8. Const f10key = 68 
  9.  
  10. ;Screenshot number, begin at one (it is an integer)
  11. snnum = "1" 
  12.  
  13. While Not KeyDown(1)
  14.     
  15.     ;Set up random color
  16.     Color Rand(0,255),Rand(0,255),Rand(0,255)
  17.     
  18.     ;Draw a random rectangle
  19.     Rect Rand(0,800),Rand(0,600),Rand(0,200),Rand(0,200),Rand(0,1)
  20.  
  21.     ;Wait a little while
  22.     Delay 45
  23.     
  24.     ;If user presses f10, take a screenshot
  25.     If KeyHit(f10key)
  26.         SaveBuffer(FrontBuffer(), "screenshot" + snnum + ".bmp") 
  27.         
  28.         snnum = snnum + 1 ;Add 1 to the end of the filename
  29.     EndIf
  30.     
  31. Wend