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

  1. Rem * Title  : Using Bobs
  2. Rem * Author : DBS-MB
  3. Rem * Date   : 1st August 99
  4. rem ===================================================
  5. rem DARK BASIC EXAMPLE PROGRAM 4
  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 Get bob width and find the middle of it going across
  32. bobwidth=(bob width(1)/2)
  33.  
  34. rem Get bob height and find the middle of it going down
  35. bobheight=(bob height(1)/2)
  36.  
  37. rem Get other bob data
  38. bobexists=bob exist(1)
  39. bobvert=bob flipped(1)
  40. bobhori=bob mirrored(1)
  41.  
  42. rem New offset for bob 1 
  43. offset bob 1,bobwidth,bobheight
  44.  
  45. rem Copy background to screen
  46. copy bitmap 1,0
  47.  
  48. rem The is were on screen bob will appear
  49. acrossscreen=100
  50. downscreen=100
  51.  
  52. rem This is were bob will move to
  53. targetacross=100
  54. targetdown=100
  55.  
  56. rem When you make a bob the bob is set so that it save the background
  57. rem and restore it when it has moved
  58. rem you can switch of this by using the command SET BOB
  59.  
  60. rem The bob will not save the background
  61. rem please remove the REM command before running
  62. REM set bob 1,0,1 
  63.  
  64. rem please replace the REM command before using the next set bob command
  65.  
  66. rem The background color grab with the image will not be transparent
  67. rem please remove the ` before running
  68. `set bob 1,1,0 
  69.  
  70. print "setting save background and transparent on a bob"
  71. do
  72.     rem Have we pressed the left mouse button    
  73.     if mouseclick()=1
  74.         rem get were mouse is across the screen
  75.         targetacross=mousex()
  76.         rem get were mouse is down the screen    
  77.         targetdown=mousey()
  78.     endif
  79.  
  80.     rem This next part home the bob on the target x and target y position
  81.     if acrossscreen<targetacross:acrossscreen=acrossscreen+1:endif
  82.     if acrossscreen>targetacross:acrossscreen=acrossscreen-1:endif
  83.     if downscreen<targetdown:downscreen=downscreen+1:endif
  84.     if downscreen>targetdown:downscreen=downscreen-1:endif
  85.     
  86.     rem Draw the bob at the new position
  87.     bob 1,acrossscreen,downscreen,1
  88.  
  89. loop
  90.  
  91. rem Clear the screen
  92. cls 
  93.  
  94. rem Remove the bob from memory
  95. delete bob 1
  96.  
  97. rem Remove image 1 from memory
  98. delete image 1
  99.  
  100. rem End the program
  101. end
  102.  
  103.