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

  1. ;demo05-02.bb - Demonstrates a rotated image with 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. ;Rotate images from the CENTER!
  12. AutoMidHandle True
  13.  
  14.  
  15. ;Load the player image
  16. playerimage = LoadImage("player.bmp") 
  17.  
  18. ;Create every frame of the rotation
  19. For loop = 0 To PLAYERFRAMES - 1 
  20.     
  21.     ;copy the image (with no rotation) to the array
  22.     player(loop) = CopyImage(playerimage) 
  23.     
  24.     ;Rotate the image For later use
  25.     RotateImage player(loop), loop*360/PLAYERFRAMES
  26.  
  27. Next ;Next frame
  28. ;END INITIALIZATION
  29.  
  30. ;GAME LOOP
  31. While(Not KeyDown(1))
  32.  
  33.     ;Clear the screen
  34.     Cls 
  35.     ;go to next frame 
  36.     currentframe = currentframe + 1 
  37.  
  38.  
  39.     ;if you reach the last frame start from the beginning
  40.     If currentframe > PLAYERFRAMES - 1 
  41.         currentframe = 0 
  42.     EndIf
  43.  
  44.     ;draw the rotated player
  45.     DrawImage(player(currentframe),320,240) 
  46.  
  47.  
  48.     ;slow it down a bit
  49.     Delay 50 
  50.     Flip 
  51.     
  52. Wend ;End of While Loop