Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.71 KB | None | 0 0
  1. '**********Sling Shot Animations
  2. ' Rstep and Lstep are the variables that increment the animation
  3. '****************
  4. Dim RStep, Lstep
  5.  
  6. Sub RightSlingShot_Slingshot
  7.  
  8. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  9. RSling.Visible = 0
  10. RSling1.Visible = 1
  11. sling1.rotx = 20
  12. RStep = 0
  13. RightSlingShot.TimerEnabled = 1
  14.  
  15. End Sub
  16.  
  17. Sub RightSlingShot_Timer
  18. Select Case RStep
  19. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  20. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0
  21. End Select
  22. RStep = RStep + 1
  23. End Sub
  24.  
  25. Sub LeftSlingShot_Slingshot
  26.  
  27. PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  28. LSling.Visible = 0
  29. LSling1.Visible = 1
  30. sling2.rotx = 20
  31. LStep = 0
  32. LeftSlingShot.TimerEnabled = 1
  33.  
  34. End Sub
  35.  
  36. Sub LeftSlingShot_Timer
  37. Select Case LStep
  38. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  39. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0
  40. End Select
  41. LStep = LStep + 1
  42. End Sub
  43.  
  44.  
  45. '*********************************************************************
  46. ' Positional Sound Playback Functions
  47. '*********************************************************************
  48.  
  49. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  50. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  51. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  52. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  53. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  54. End Sub
  55.  
  56. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  57. Sub PlaySoundAt(soundname, tableobj)
  58. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  59. End Sub
  60.  
  61. Sub PlaySoundAtBall(soundname)
  62. PlaySoundAt soundname, ActiveBall
  63. End Sub
  64.  
  65.  
  66. '*********************************************************************
  67. ' Supporting Ball & Sound Functions
  68. '*********************************************************************
  69.  
  70. Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
  71. Dim tmp
  72. tmp = tableobj.y * 2 / table1.height-1
  73. If tmp > 0 Then
  74. AudioFade = Csng(tmp ^10)
  75. Else
  76. AudioFade = Csng(-((- tmp) ^10) )
  77. End If
  78. End Function
  79.  
  80. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  81. Dim tmp
  82. tmp = tableobj.x * 2 / table1.width-1
  83. If tmp > 0 Then
  84. AudioPan = Csng(tmp ^10)
  85. Else
  86. AudioPan = Csng(-((- tmp) ^10) )
  87. End If
  88. End Function
  89.  
  90. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  91. Vol = Csng(BallVel(ball) ^2 / 2000)
  92. End Function
  93.  
  94. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  95. Pitch = BallVel(ball) * 20
  96. End Function
  97.  
  98. Function BallVel(ball) 'Calculates the ball speed
  99. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  100. End Function
  101.  
  102. '*****************************************
  103. ' JP's VP10 Rolling Sounds
  104. '*****************************************
  105.  
  106. Const tnob = 5 ' total number of balls
  107. ReDim rolling(tnob)
  108. InitRolling
  109.  
  110. Sub InitRolling
  111. Dim i
  112. For i = 0 to tnob
  113. rolling(i) = False
  114. Next
  115. End Sub
  116.  
  117. Sub RollingTimer_Timer()
  118. Dim BOT, b
  119. BOT = GetBalls
  120.  
  121. ' stop the sound of deleted balls
  122. For b = UBound(BOT) + 1 to tnob
  123. rolling(b) = False
  124. StopSound("fx_ballrolling" & b)
  125. Next
  126.  
  127. ' exit the sub if no balls on the table
  128. If UBound(BOT) = -1 Then Exit Sub
  129.  
  130. ' play the rolling sound for each ball
  131. For b = 0 to UBound(BOT)
  132. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  133. rolling(b) = True
  134. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  135. Else
  136. If rolling(b) = True Then
  137. StopSound("fx_ballrolling" & b)
  138. rolling(b) = False
  139. End If
  140. End If
  141. Next
  142. End Sub
  143.  
  144. '**********************
  145. ' Ball Collision Sound
  146. '**********************
  147.  
  148. Sub OnBallBallCollision(ball1, ball2, velocity)
  149. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  150. End Sub
  151.  
  152.  
  153. '*****************************************
  154. ' ninuzzu's FLIPPER SHADOWS
  155. '*****************************************
  156.  
  157. sub FlipperTimer_Timer()
  158. FlipperLSh.RotZ = LeftFlipper.currentangle
  159. FlipperRSh.RotZ = RightFlipper.currentangle
  160.  
  161. End Sub
  162.  
  163. '*****************************************
  164. ' ninuzzu's BALL SHADOW
  165. '*****************************************
  166. Dim BallShadow
  167. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  168.  
  169. Sub BallShadowUpdate_timer()
  170. Dim BOT, b
  171. BOT = GetBalls
  172. ' hide shadow of deleted balls
  173. If UBound(BOT)<(tnob-1) Then
  174. For b = (UBound(BOT) + 1) to (tnob-1)
  175. BallShadow(b).visible = 0
  176. Next
  177. End If
  178. ' exit the Sub if no balls on the table
  179. If UBound(BOT) = -1 Then Exit Sub
  180. ' render the shadow for each ball
  181. For b = 0 to UBound(BOT)
  182. If BOT(b).X < Table1.Width/2 Then
  183. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  184. Else
  185. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  186. End If
  187. ballShadow(b).Y = BOT(b).Y + 12
  188. If BOT(b).Z > 20 Then
  189. BallShadow(b).visible = 1
  190. Else
  191. BallShadow(b).visible = 0
  192. End If
  193. Next
  194. End Sub
  195.  
  196.  
  197.  
  198. '************************************
  199. ' What you need to add to your table
  200. '************************************
  201.  
  202. ' a timer called RollingTimer. With a fast interval, like 10
  203. ' one collision sound, in this script is called fx_collide
  204. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  205. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  206.  
  207.  
  208. '******************************************
  209. ' Explanation of the rolling sound routine
  210. '******************************************
  211.  
  212. ' sounds are played based on the ball speed and position
  213.  
  214. ' the routine checks first for deleted balls and stops the rolling sound.
  215.  
  216. ' The For loop goes through all the balls on the table and checks for the ball speed and
  217. ' if the ball is on the table (height lower than 30) then then it plays the sound
  218. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  219.  
  220. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  221. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  222. ' according to the position of the ball on the table.
  223.  
  224.  
  225. '**************************************
  226. ' Explanation of the collision routine
  227. '**************************************
  228.  
  229. ' The collision is built in VP.
  230. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  231. ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning
  232. ' depending of the speed of the collision.
  233.  
  234.  
  235. Sub Pins_Hit (idx)
  236. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  237. End Sub
  238.  
  239. Sub Targets_Hit (idx)
  240. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  241. End Sub
  242.  
  243. Sub Metals_Thin_Hit (idx)
  244. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  245. End Sub
  246.  
  247. Sub Metals_Medium_Hit (idx)
  248. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  249. End Sub
  250.  
  251. Sub Metals2_Hit (idx)
  252. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  253. End Sub
  254.  
  255. Sub Gates_Hit (idx)
  256. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  257. End Sub
  258.  
  259. Sub Spinner_Spin
  260. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  261. End Sub
  262.  
  263. Sub Rubbers_Hit(idx)
  264. dim finalspeed
  265. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  266. If finalspeed > 20 then
  267. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  268. End if
  269. If finalspeed >= 6 AND finalspeed <= 20 then
  270. RandomSoundRubber()
  271. End If
  272. End Sub
  273.  
  274. Sub Posts_Hit(idx)
  275. dim finalspeed
  276. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  277. If finalspeed > 16 then
  278. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  279. End if
  280. If finalspeed >= 6 AND finalspeed <= 16 then
  281. RandomSoundRubber()
  282. End If
  283. End Sub
  284.  
  285. Sub RandomSoundRubber()
  286. Select Case Int(Rnd*3)+1
  287. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  288. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  289. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  290. End Select
  291. End Sub
  292.  
  293. Sub LeftFlipper_Collide(parm)
  294. RandomSoundFlipper()
  295. End Sub
  296.  
  297. Sub RightFlipper_Collide(parm)
  298. RandomSoundFlipper()
  299. End Sub
  300.  
  301. Sub RandomSoundFlipper()
  302. Select Case Int(Rnd*3)+1
  303. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  304. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  305. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  306. End Select
  307. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement