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

  1. ;demo06-01.bb - A not-so-greatly animated ship
  2. ;Initialize the Graphics
  3. Graphics 800,600 
  4.  
  5. ;load the ship image
  6. shipimage = LoadImage("ship.bmp") 
  7.  
  8. ;Seed the random generator
  9. SeedRnd(MilliSecs())
  10.  
  11. ;create a ship type
  12. Type ship 
  13.     Field x,y   ;the x and y coords
  14. End Type
  15.  
  16. ;create the ship
  17. ship.ship = New ship 
  18.     
  19. ;position the ship randomly
  20. ship\x = Rand(0,800) 
  21. ship\y = Rand(0,600)
  22.  
  23. While Not KeyDown(1) 
  24.     ;Clear the screen
  25.     Cls 
  26.     ;move ship left and right
  27.     ship\x = ship\x + Rand(-8,8) 
  28.     ;Move ship up And down
  29.     ship\y = ship\y + Rand(-8,8) 
  30.     
  31.     ;If ship goes off screen, move it back on
  32.     If ship\x < 0
  33.         ship\x = 15
  34.     ElseIf ship\x > 800
  35.         ship\x = 790
  36.     ElseIf ship\y < 0
  37.         ship\y = 10
  38.     ElseIf ship\y >600
  39.         ship\y = 590
  40.     EndIf
  41.  
  42.     ;Draw the ship
  43.     DrawImage(shipimage,ship\x,ship\y)
  44. Wend