home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 63 / CDACTUAL63.iso / Aplicaciones / DarkBasic / DemoDarkBasic.exe / help / examples / bobs / exam03.dba < prev    next >
Encoding:
Text File  |  1999-09-07  |  2.4 KB  |  96 lines

  1. Rem * Title  : Draw Bob to Screen
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ===================================================
  5. rem DARK BASIC EXAMPLE PROGRAM 3
  6. rem ===================================================
  7. rem This program will draw a bob on screen 
  8. rem ---------------------------------------------------
  9.  
  10. rem Set the ink to white and paper color to black 
  11. ink rgb(244,214,210),1
  12.  
  13. rem Load a bitmap on to the screen
  14. load bitmap "face.bmp"
  15.  
  16. rem Load back ground to bitmap 1
  17. load bitmap "back.bmp",1
  18.  
  19. rem When you load a bitmap that bitmap becomes the current bitmap
  20. rem where all drawing is done 
  21.  
  22. rem Use this command to set drawing to the screen
  23. set current bitmap 0 
  24.  
  25. rem Grab image 1 from bitmap
  26. get image 1,18,17,156,196
  27.  
  28. rem Now we will make a bob
  29. bob 1,100,100,1
  30.  
  31. rem Copy background to screen
  32. copy bitmap 1,0
  33.  
  34. rem The is were on screen bob will appear
  35. acrossscreen=100
  36. downscreen=100
  37.  
  38. rem This is were bob will move to
  39. targetacross=0
  40. targetdown=0
  41.  
  42. rem When you run the program the image will move to the position
  43. rem the mouse was when you pressed the left mouse button
  44. rem has you can see the bob is position on screen from the top left
  45. rem of the image 
  46. rem if you wish the bob to be drawn on screen from another part of the image
  47. rem then use the OFFSET BOB command
  48.  
  49.  
  50. remstart **** please remove this line ****
  51.  
  52. rem Get bob width and find the middle of it going across
  53. bobwidth=(bob width(1)/2)
  54.  
  55. rem Get bob height and find the middle of it going down
  56. bobheight=(bob height(1)/2)
  57.  
  58. rem New offset for bob 1 
  59. offset bob 1,bobwidth,bobheight
  60.  
  61. remend   **** please remove this line ****
  62.  
  63.  
  64. print "using the offset bob command"
  65. do
  66.     rem Have we pressed the left mouse button    
  67.     if mouseclick()=1
  68.         rem get were mouse is across the screen
  69.         targetacross=mousex()
  70.         rem get were mouse is down the screen    
  71.         targetdown=mousey()
  72.     endif
  73.  
  74.     rem This next part home the bob on the target x and target y position
  75.     if acrossscreen<targetacross:acrossscreen=acrossscreen+1:endif
  76.     if acrossscreen>targetacross:acrossscreen=acrossscreen-1:endif
  77.     if downscreen<targetdown:downscreen=downscreen+1:endif
  78.     if downscreen>targetdown:downscreen=downscreen-1:endif
  79.     
  80.     rem Draw the bob at the new position
  81.     bob 1,acrossscreen,downscreen,1
  82.  
  83. loop
  84.  
  85. rem Clear the screen
  86. cls 
  87.  
  88. rem Remove the bob from memory
  89. delete bob 1
  90.  
  91. rem Remove image 1 from memory
  92. delete image 1
  93.  
  94. rem End the program
  95. end
  96.