home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter07 / demo07-02.bb < prev    next >
Encoding:
Text File  |  2003-04-06  |  828 b   |  39 lines

  1. ;demo 07-02.bb - Translates an image using Translate()
  2. Graphics 640,480 
  3.  
  4. ;Set up BackBuffer and AutoMidHandle
  5. SetBuffer BackBuffer() 
  6. AutoMidHandle True
  7.  
  8. ;IMAGES
  9. ;Load the ship that will be drawn on the screen
  10. shipimage = LoadImage("enemy.bmp") 
  11.  
  12. ;Make ship start at top left corner
  13. shipx = 0
  14. shipy = 0
  15.  
  16. While Not KeyDown(1)
  17. ;Clear the Screen before every frame
  18. Cls
  19.  
  20. ;Draw the ship at its coordinates
  21. DrawImage shipimage,shipx,shipy
  22.  
  23.  
  24. ;Translate the ship image 7 pixels right and 5 pixels down
  25. shipx = Translate(shipx,7)
  26. shipy = Translate(shipy,5)
  27.  
  28. Delay 50
  29. Flip
  30. Wend
  31. ;END OF MAIN LOOP
  32.  
  33. ;FUNCTIONS
  34. ;Function Translate(x,dx) - Translates a coordinate a specified amount
  35. ;x: the coordinate that will be translated
  36. ;dx: the translation factor
  37. Function Translate(x,dx)
  38. Return x+dx
  39. End Function