home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter05 / demo05-01.bb next >
Encoding:
Text File  |  2004-08-28  |  1022 b   |  50 lines

  1. ;demo05-01.bb - Demonstrates a rotated image without AutoMidHandle
  2. Graphics 640,480
  3. SetBuffer BackBuffer()
  4.  
  5. ;INITIALIZATION
  6.  
  7. ;Defines how many rotation frames there are
  8. Const PLAYERFRAMES = 40 
  9. ;The array that hold the rotations
  10. Dim player(PLAYERFRAMES) 
  11.  
  12.  
  13. ;Load the player image
  14. playerimage = LoadImage("player.bmp") 
  15.  
  16. ;Create every frame of the rotation
  17. For loop = 0 To PLAYERFRAMES - 1 
  18.     
  19.     ;copy the image (with no rotation) to the array
  20.     player(loop) = CopyImage(playerimage) 
  21.     
  22.     ;Rotate the image For later use
  23.     RotateImage player(loop), loop*360/PLAYERFRAMES
  24.  
  25. Next ;Next frame
  26. ;END INITIALIZATION
  27.  
  28. ;GAME LOOP
  29. While(Not KeyDown(1))
  30.  
  31.     ;Clear the screen
  32.     Cls 
  33.     ;go to next frame 
  34.     currentframe = currentframe + 1 
  35.  
  36.  
  37.     ;if you reach the last frame start from the beginning
  38.     If currentframe > PLAYERFRAMES - 1 
  39.         currentframe = 0 
  40.     EndIf
  41.  
  42.     ;draw the rotated player
  43.     DrawImage(player(currentframe),320,240) 
  44.  
  45.  
  46.     ;slow it down a bit
  47.     Delay 50 
  48.     Flip 
  49.     
  50. Wend ;End of While Loop