home *** CD-ROM | disk | FTP | other *** search
/ Game Programming for Teens / GameProgrammingForTeens.iso / Source / chapter08 / demo08-01.bb < prev    next >
Encoding:
Text File  |  2003-04-06  |  1.2 KB  |  64 lines

  1. ;demo08-01.bb - A moving static image
  2.  
  3. Graphics 800,600
  4.  
  5. ;Make back buffer default and set automidhandle to true
  6. SetBuffer BackBuffer()
  7. AutoMidHandle True
  8.  
  9. ;IMAGES
  10. ;Load the image that will be drawn on screen
  11. playerimage = LoadImage("staticboy.bmp")
  12.  
  13. ;TYPES
  14. ;This type defines the coordinate position of the player
  15. Type player
  16.     Field x,y 
  17. End Type
  18.  
  19. ;Create the player
  20. player.player = New player 
  21.  
  22. ;Set up beginning values for player
  23. player\x = 400
  24. player\y = 300
  25.  
  26.  
  27. ;MAIN LOOP
  28. While Not KeyDown(1) ;While user does not press Esc
  29.  
  30. ;Clear the screen
  31. Cls
  32.  
  33. ;Make sure text is printed in top left corner of screen
  34. Locate 0,0
  35.  
  36. Print "X Coordinate: " + player\x
  37. Print "Y Coordinate: " + player\y
  38.  
  39. ;If player presses left, move bitmap left
  40. If KeyDown (203) 
  41.     player\x = player\x - 5
  42. EndIf
  43.  
  44. ;If player presses left, move bitmap right
  45. If KeyDown(205)
  46.     player\x = player\x + 5
  47. EndIf
  48.  
  49. ;If player presses up, move bitmap up
  50. If KeyDown (200) 
  51.     player\y = player\y -5
  52. EndIf
  53.  
  54. ;If player presses down, move bitmap down
  55. If KeyDown (208)
  56.     player\y = player\y + 5
  57. EndIf
  58.  
  59. ;Draw the player on screen
  60. DrawImage playerimage, player\x,player\y
  61.  
  62. Flip
  63. Wend
  64. ;END OF MAIN LOOP