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

  1. ;demo10-06.bb - Demonstrates the return value of KeyHit()
  2.  
  3. ;Set up graphics so that you can read all of the text, make it windowed
  4. Graphics 800,600,0,2
  5.  
  6. ;Begin introductory text
  7. Print "You know what's cool? Game Programming."
  8. Print "Although Maneesh ain't that uncool, either."
  9.  
  10. ;Print blank line
  11. Print ""
  12.  
  13. ;Continue text
  14. Print "Anyway, press Esc as many times as you can in the Next 5 seconds."
  15. Print "At the end of the program, the number of times will be printed."
  16.  
  17.  
  18. ;Allow the player 5 seconds to hit esc as many times as possible
  19. Delay 5000
  20.  
  21.  
  22. ;Set numberofhits equal to the amount of times Esc was hit (return value of KeyHit(1) )
  23. numberofhits = KeyHit(1)
  24.  
  25. ;Print the number of times Esc was hit
  26. Print "Esc was hit " + numberofhits + " times."
  27. Print "You gotta love KeyHit(), huh?"
  28.  
  29. ;Hold on a sec so the player can see the final text
  30. Delay 1000
  31.  
  32. ;Make sure the key input memory is cleared by calling FlushKeys
  33. FlushKeys
  34.  
  35. ;Wait for user to press a key before exiting
  36. Print "Press any key to Esc."
  37. WaitKey