home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 60 / supercd60_2.iso / BlitzBasic / Blitz2DPCP / data1.cab / Support / help / samples / bombtrail.bb < prev    next >
Encoding:
Text File  |  2001-11-21  |  3.5 KB  |  159 lines

  1. ; Bomb Trail by Simon Harrison (si@si-design.co.uk)
  2. ;verified 1.48 4/18/2001
  3.  
  4. ; Set display mode values
  5. Const width=640,height=480
  6.  
  7. ; Set display mode
  8. Graphics 640,480
  9.  
  10. ; Draw to back buffer
  11. SetBuffer BackBuffer()
  12.  
  13. ; Load bomb image
  14. bomb=LoadImage("graphics/bomb.bmp")
  15.  
  16. ; Load spark anim image
  17. spark=LoadAnimImage("graphics/spark.bmp",32,32,0,3)
  18.  
  19. ; Mask bomb and spark images so that pink background colour is invisible
  20. MaskImage bomb,255,0,255
  21. MaskImage spark,255,0,255
  22.  
  23. ; Load boom sound
  24. Global boom=LoadSound("sounds/boom.wav")
  25.  
  26. ; Create fuse custom type
  27. Type fuse
  28. Field x#,y#
  29. End Type
  30.  
  31. ; Set initial countdown value to 10 seconds
  32. countdown=10
  33.  
  34. ; Set initial old mouse values
  35. oldmousex=1
  36. oldmousey=1
  37.  
  38. ; Get current timer value - soon to be old...
  39. oldmilli=MilliSecs()
  40.  
  41. ; Repeat following loop until escape key is pressed
  42. While Not KeyDown(1)
  43.  
  44. ; Clear screen
  45. Cls
  46.  
  47. ; If mouse position isn't the same as last loop (and so is moving), create new fuse object at same position as mouse
  48. If oldmousex<>MouseX() Or oldmousey<>MouseY()
  49. a.fuse=New fuse 
  50. a\x#=MouseX()
  51. a\y#=MouseY()
  52. EndIf
  53.  
  54. ; Get current mouse position values - soon to be old
  55. oldmousex=MouseX()
  56. oldmousey=MouseY()
  57.  
  58. ; Draw each spot of fuse to the screen
  59. For a=Each fuse
  60. Color 255,255,255
  61. Plot a\x#,a\y#
  62. Next
  63.  
  64. ; If lit flag=0...
  65. If lit=0
  66.  
  67. ; If 2000 millisecs (2 secs) have passed since last getting timer value, then deduct 1 sec off timer. Update timer value.
  68. If MilliSecs()-oldmilli>1000 Then countdown=countdown-1 : oldmilli=MilliSecs()
  69.  
  70. EndIf
  71.  
  72. ; If countdown=0 then set lit flag to 1...
  73. If countdown=0 Then lit=1
  74.  
  75. ; If lit flag=1...
  76. If lit=1
  77.  
  78. ; Get the first fuse object in the list (the oldest one)
  79. a=First fuse
  80.  
  81. ; Draw spark anim image to screen using current frame value
  82. DrawImage spark,a\x#-16,a\y#-16,frame
  83.  
  84. ; Increase frame value by 1, if frame value exceeds maximum number of frames then reset frame value to 0
  85. frame=frame+1 : If frame=3 Then frame=0
  86.  
  87. ; If the first object exists then delete it
  88. If a<>Null Then Delete a
  89.  
  90. EndIf
  91.  
  92. ; Get the last fuse object in the list (the newest one)
  93. a=Last fuse
  94.  
  95. ; If the last object exists...
  96. If a<>Null 
  97.  
  98. ; Draw bomb image to screen
  99. DrawImage bomb,a\x#,a\y#
  100.  
  101. ; Print countdown text to screen just above bomb
  102. Color 255,255,255
  103. Text a\x#+24,a\y#-16,countdown,1
  104.  
  105. EndIf
  106.  
  107. ; If coundown reaches 0...
  108. If countdown=0
  109.  
  110. ; Get first object in list
  111. a=First fuse
  112.  
  113. ; If first object in list doesn't exist (i.e. list is empty) then call explode function
  114. If a=Null Then Explode()
  115.  
  116. EndIf
  117.  
  118. ; Flip screen buffers
  119. Flip
  120.  
  121. Wend
  122.  
  123. ; *************************************************************************************************************************
  124.  
  125. ; Explode function
  126. Function Explode()
  127.  
  128. ; Play boom sound
  129. PlaySound boom
  130.  
  131. ; Repeat the following loop until the fade colour values have finally gone from black to yellow to white to black
  132. Repeat
  133.  
  134. ; Increase yellow colour value
  135. yellow=yellow+10
  136.  
  137. ; If yellow colour value exceeds maximum (255), then start increasing white colour value
  138. If yellow>255 Then yellow=255 : white=white+10
  139.  
  140. ; If white colour value exceeds maximum, then start increasing black colour value
  141. If white>255 Then black=black+10 : white=255
  142.  
  143. ; Set clear screen colour
  144. ClsColor yellow-black,yellow-black,white-black
  145.  
  146. ; Clear screen
  147. Cls
  148.  
  149. ; Flip screen bufffers
  150. Flip
  151.  
  152. Until black>255
  153.  
  154. ; End program
  155. End
  156.  
  157. End Function
  158.  
  159. ; *************************************************************************************************************************