Guest User

Solar Ride DOF

a guest
Aug 5th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.82 KB | None | 0 0
  1. Option Explicit
  2. Randomize
  3.  
  4. On Error Resume Next
  5. ExecuteGlobal GetTextFile("controller.vbs")
  6. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  7. On Error Goto 0
  8.  
  9. Const cGameName="solaride",UseSolenoids=1,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff",SCoin="coin"
  10.  
  11. LoadVPM "01001100", "gts1.vbs", 3.02
  12. Dim DesktopMode: DesktopMode = Table1.ShowDT
  13.  
  14. If DesktopMode = True Then 'Show Desktop components
  15. Ramp16.visible=1
  16. Ramp15.visible=1
  17. Primitive13.visible=1
  18. Else
  19. Ramp16.visible=0
  20. Ramp15.visible=0
  21. Primitive13.visible=0
  22. End if
  23.  
  24. '*************************************************************
  25.  
  26. 'Solenoid Call backs
  27. '**********************************************************************************************************
  28. SolCallback(1)= "bsTrough.SolOut"
  29. SolCallback(2)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  30. SolCallback(6)= "bsSaucer.SolOut"
  31. SolCallBack(7)= "bsSaucer2.SolOut"
  32. SolCallback(8)= "dtDropL.SolDropUp"
  33.  
  34. SolCallback(sLRFlipper) = "SolRFlipper"
  35. SolCallback(sLLFlipper) = "SolLFlipper"
  36.  
  37. Sub SolLFlipper(Enabled)
  38. If Enabled Then
  39. PlaySound SoundFX("fx_Flipperup",DOFContactors):LeftFlipper.RotateToEnd:LeftFlipper1.RotateToEnd
  40. Else
  41. PlaySound SoundFX("fx_Flipperdown",DOFContactors):LeftFlipper.RotateToStart:LeftFlipper1.RotateToStart
  42. End If
  43. End Sub
  44.  
  45. Sub SolRFlipper(Enabled)
  46. If Enabled Then
  47. PlaySound SoundFX("fx_Flipperup",DOFContactors):RightFlipper.RotateToEnd
  48. Else
  49. PlaySound SoundFX("fx_Flipperdown",DOFContactors):RightFlipper.RotateToStart
  50. End If
  51. End Sub
  52. '**********************************************************************************************************
  53.  
  54. 'Solenoid Controlled toys
  55. '**********************************************************************************************************
  56.  
  57. 'Primitive Flipper Code
  58. Sub FlipperTimer_Timer
  59. FlipperT1.roty = LeftFlipper.currentangle + 237
  60. FlipperT2.roty = LeftFlipper1.currentangle + 237
  61. FlipperT5.roty = RightFlipper.currentangle + 122
  62. End Sub
  63.  
  64.  
  65. '*****GI Lights On
  66. dim xx
  67. For each xx in GI:xx.State = 1: Next
  68.  
  69. '**********************************************************************************************************
  70.  
  71. 'Initiate Table
  72. '**********************************************************************************************************
  73. Dim bsTrough, bsSaucer, bsSaucer2, dtDropL
  74.  
  75. Sub Table1_Init
  76. vpmInit Me
  77. On Error Resume Next
  78. With Controller
  79. .GameName = cGameName
  80. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  81. .SplashInfoLine = "Solar Ride (Gotlieb)"
  82. .HandleMechanics=0
  83. .HandleKeyboard=0
  84. .ShowDMDOnly=1
  85. .ShowFrame=0
  86. .ShowTitle=0
  87. .hidden = 1
  88. If Err Then MsgBox Err.Description
  89. End With
  90. On Error Goto 0
  91. Controller.SolMask(0)=0
  92. vpmTimer.AddTimer 2000,"Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
  93. Controller.Run
  94. If Err Then MsgBox Err.Description
  95. On Error Goto 0
  96.  
  97. PinMAMETimer.Interval=PinMAMEInterval
  98. PinMAMETimer.Enabled=1
  99.  
  100. vpmNudge.TiltSwitch = 4
  101. vpmNudge.Sensitivity = 5
  102. vpmNudge.TiltObj = Array(Bumper1,Bumper2,RightSlingshot)
  103.  
  104. Set bsTrough = New cvpmBallStack
  105. bsTrough.initnotrough ballrelease, 66, 55, 6
  106. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  107.  
  108. Set dtDropL=New cvpmDropTarget'
  109. dtDropL.InitDrop Array(sw30,sw31,sw32,sw33,sw34),Array(30,31,32,33,34)
  110. dtDropL.InitSnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  111.  
  112. Set bsSaucer2=New cvpmBallstack
  113. bsSaucer2.InitSaucer sw42,42,180,7
  114. bsSaucer2.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  115.  
  116.  
  117. Set bsSaucer=New cvpmBallstack
  118. bsSaucer.InitSaucer sw41,41,265,6
  119. bsSaucer.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  120.  
  121. End Sub
  122.  
  123. '**********************************************************************************************************
  124. 'Plunger code
  125. '**********************************************************************************************************
  126.  
  127. Sub Table1_KeyDown(ByVal KeyCode)
  128. If KeyDownHandler(keycode) Then Exit Sub
  129. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  130. End Sub
  131.  
  132. Sub Table1_KeyUp(ByVal KeyCode)
  133. If KeyUpHandler(keycode) Then Exit Sub
  134. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  135. End Sub
  136.  
  137. '**********************************************************************************************************
  138.  
  139. 'Switches
  140. '**********************************************************************************************************
  141. '**********************************************************************************************************
  142. 'Drain hole and kicker
  143. Sub Drain_Hit:playsound"drain":bsTrough.addball me:End Sub
  144. Sub sw41_Hit():bsSaucer.Addball 0 : playsound "popper_ball": End Sub
  145. Sub sw42_Hit():bsSaucer2.Addball 0 : playsound "popper_ball": End Sub
  146.  
  147. 'Bumpers
  148. Sub Bumper1_Hit : vpmTimer.PulseSw(40) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  149. Sub Bumper2_Hit : vpmTimer.PulseSw(43) : playsound SoundFXDOF("fx_bumper1",201,DOFPulse,DOFContactors): End Sub
  150. Sub Bumper3_Hit : vpmTimer.PulseSw(43) : playsound SoundFXDOF("fx_bumper1",202,DOFPulse,DOFContactors): End Sub
  151.  
  152. 'Drop Targets
  153. Sub sw30_Dropped:dtDropL.Hit 1:End Sub
  154. Sub sw31_Dropped:dtDropL.Hit 2:End Sub
  155. Sub sw32_Dropped:dtDropL.Hit 3:End Sub
  156. Sub sw33_Dropped:dtDropL.Hit 4:End Sub
  157. Sub sw34_Dropped:dtDropL.Hit 5:End Sub
  158.  
  159. 'Star Triggers
  160. Sub sw12a_Hit():Controller.Switch(12)=1 : playsound"rollover" :End Sub
  161. Sub sw12a_UnHit:Controller.Switch(12)=0:End Sub
  162. Sub sw12b_Hit():Controller.Switch(12)=1 : playsound"rollover" : End Sub
  163. Sub sw12b_UnHit:Controller.Switch(12)=0:End Sub
  164. Sub sw12ca_Hit():Controller.Switch(12)=1 : playsound"rollover":End Sub
  165. Sub sw12ca_UnHit:Controller.Switch(12)=0:End Sub
  166.  
  167. 'Scoring Gate
  168. Sub Gate1_Hit():Controller.Switch(61)=1:End Sub
  169. Sub Gate1_UnHit:Controller.Switch(61)=0:End Sub
  170.  
  171. 'Scoring Rubbers
  172. Sub sw60a_Slingshot():vpmtimer.pulsesw 60: playsound"slingshot" : End Sub
  173. Sub sw60b_Slingshot():vpmtimer.pulsesw 60: playsound"slingshot" : End Sub
  174.  
  175. 'Wire Triggers
  176. Sub sw10a_Hit():Controller.Switch(10)=1 : playsound"rollover":DOF 204, DOFOn:End Sub
  177. Sub sw10a_UnHit:Controller.Switch(10)=0:DOF 204, DOFOff:End Sub
  178. Sub sw10b_Hit():Controller.Switch(10)=1 : playsound"rollover":DOF 205, DOFOn:End Sub
  179. Sub sw10b_UnHit:Controller.Switch(10)=0:DOF 205, DOFOff:End Sub
  180. Sub sw11_Hit():Controller.Switch(11)=1 : playsound"rollover" : End Sub
  181. Sub sw11_UnHit:Controller.Switch(11)=0:End Sub
  182. Sub sw51_Hit():Controller.Switch(51)=1 : playsound"rollover":End Sub
  183. Sub sw51_UnHit:Controller.Switch(51)=0:End Sub
  184. Sub sw51a_Hit():Controller.Switch(51)=1 : playsound"rollover":End Sub
  185. Sub sw51a_UnHit:Controller.Switch(51)=0:End Sub
  186. Sub sw20_Hit():Controller.Switch(20)=1 : playsound"rollover" : End Sub
  187. Sub sw20_UnHit:Controller.Switch(20)=0:End Sub
  188. Sub sw21_Hit():Controller.Switch(21)=1 : playsound"rollover" : End Sub
  189. Sub sw21_UnHit:Controller.Switch(21)=0:End Sub
  190. Sub sw22_Hit():Controller.Switch(22)=1 : playsound"rollover" : End Sub
  191. Sub sw22_UnHit:Controller.Switch(22)=0:End Sub
  192. Sub sw23_Hit():Controller.Switch(23)=1 : playsound"rollover" : End Sub
  193. Sub sw23_UnHit:Controller.Switch(23)=0:End Sub
  194.  
  195. Sub Gate2_Hit:vpmTimer.PulseSw(52)
  196. End Sub
  197.  
  198. Sub sw51b_Hit:vpmTimer.PulseSw(51)
  199. End Sub
  200.  
  201. Sub sw13a_Hit():vpmTimer.PulseSw(13) : End Sub
  202. Sub sw13b_Hit():vpmTimer.PulseSw(13) : End Sub
  203. Sub sw13c_Hit():vpmTimer.PulseSw(13) : End Sub
  204. Sub sw13d_Hit():vpmTimer.PulseSw(13) : End Sub
  205. Sub sw13e_Hit():vpmTimer.PulseSw(13) : End Sub
  206. Sub sw13f_Hit():vpmTimer.PulseSw(13) : End Sub
  207.  
  208. '***************************************************
  209. ' JP's VP10 Fading Lamps & Flashers
  210. ' Based on PD's Fading Light System
  211. ' SetLamp 0 is Off
  212. ' SetLamp 1 is On
  213. ' fading for non opacity objects is 4 steps
  214. '***************************************************
  215.  
  216. Dim LampState(200), FadingLevel(200)
  217. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  218.  
  219. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  220. LampTimer.Interval = 5 'lamp fading speed
  221. LampTimer.Enabled = 1
  222.  
  223. ' Lamp & Flasher Timers
  224.  
  225. Sub LampTimer_Timer()
  226. Dim chgLamp, num, chg, ii
  227. chgLamp = Controller.ChangedLamps
  228. If Not IsEmpty(chgLamp) Then
  229. For ii = 0 To UBound(chgLamp)
  230. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  231. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  232. Next
  233. End If
  234. UpdateLamps
  235. End Sub
  236.  
  237.  
  238. Sub UpdateLamps
  239. If DesktopMode = True Then
  240. FadeIReel 1, EMReelGO
  241. end if
  242. If DesktopMode = True Then
  243. FadeReel 2, EMReelTilt
  244. end if
  245. If DesktopMode = True Then
  246. FadeReel 3, EMReelHTD
  247. end if
  248. NFadeLm 4, l4
  249. If DesktopMode = True Then
  250. FadeReel 4, EMReelSPSA
  251. end if
  252. NFadeL 5, l5
  253. NFadeL 6, l6
  254. NFadeL 7, l7
  255. NFadeL 8, l8
  256. NFadeL 9, l9
  257. NFadeL 10, l10
  258. NFadeL 11, l11
  259. NFadeL 12, l12
  260. NFadeL 13, l13
  261. NFadeL 14, l14
  262. NFadeL 15, l15
  263. NFadeL 16, l16
  264. 'NFadeL 17, l17
  265. NFadeL 18, l18
  266. 'NFadeL 19, l19
  267. 'NFadeL 20, l20
  268. 'NFadeL 21, l21
  269. 'NFadeL 22, l22
  270. NFadeL 23, l23
  271. NFadeL 24, l24
  272. NFadeL 25, l25
  273. NFadeL 26, l26
  274. NFadeL 27, l27
  275. NFadeL 28, l28
  276. NFadeL 29, l29
  277. NFadeL 30, l30
  278. NFadeL 31, l31
  279. NFadeL 32, l32
  280. NFadeL 33, l33
  281. 'NFadeL 34, l34
  282. 'NFadeL 35, l35
  283. 'NFadeL 36, l36
  284.  
  285.  
  286. 'FadeReel lBallInPlay, EMReelBIP
  287. 'FadeReel lNumberToMatch, EMReelNTM
  288. End Sub
  289.  
  290. ' div lamp subs
  291.  
  292. Sub InitLamps()
  293. Dim x
  294. For x = 0 to 200
  295. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  296. FadingLevel(x) = 4 ' used to track the fading state
  297. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  298. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  299. FlashMax(x) = 1 ' the maximum value when on, usually 1
  300. FlashMin(x) = 0 ' the minimum value when off, usually 0
  301. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  302. Next
  303. End Sub
  304.  
  305. Sub AllLampsOff
  306. Dim x
  307. For x = 0 to 200
  308. SetLamp x, 0
  309. Next
  310. End Sub
  311.  
  312. Sub SetLamp(nr, value)
  313. If value <> LampState(nr) Then
  314. LampState(nr) = abs(value)
  315. FadingLevel(nr) = abs(value) + 4
  316. End If
  317. End Sub
  318.  
  319. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  320.  
  321. Sub NFadeL(nr, object)
  322. Select Case FadingLevel(nr)
  323. Case 4:object.state = 0:FadingLevel(nr) = 0
  324. Case 5:object.state = 1:FadingLevel(nr) = 1
  325. End Select
  326. End Sub
  327.  
  328. Sub NFadeLm(nr, object) ' used for multiple lights
  329. Select Case FadingLevel(nr)
  330. Case 4:object.state = 0
  331. Case 5:object.state = 1
  332. End Select
  333. End Sub
  334.  
  335. 'Reels
  336. Sub FadeReel(nr, reel)
  337. Select Case FadingLevel(nr)
  338. Case 2:FadingLevel(nr) = 0
  339. Case 3:FadingLevel(nr) = 2
  340. Case 4:reel.Visible = 0:FadingLevel(nr) = 3
  341. Case 5:reel.Visible = 1:FadingLevel(nr) = 1
  342. End Select
  343. End Sub
  344.  
  345. 'Inverted Reels
  346. Sub FadeIReel(nr, reel)
  347. Select Case FadingLevel(nr)
  348. Case 2:FadingLevel(nr) = 0
  349. Case 3:FadingLevel(nr) = 2
  350. Case 4:reel.Visible = 1:FadingLevel(nr) = 3
  351. Case 5:reel.Visible = 0:FadingLevel(nr) = 1
  352. End Select
  353. End Sub
  354.  
  355. '**********************************************************************************************************
  356. '**********************************************************************************************************
  357. ' Backglass Light Displays (7 digit 7 segment displays)
  358. Dim Digits(28)
  359. Digits(0)=Array(a00,a01,a02,a03,a04,a05,a06,n,a08)
  360. Digits(1)=Array(a10,a11,a12,a13,a14,a15,a16,n,a18)
  361. Digits(2)=Array(a20,a21,a22,a23,a24,a25,a26,n,a28)
  362. Digits(3)=Array(a30,a31,a32,a33,a34,a35,a36,n,a38)
  363. Digits(4)=Array(a40,a41,a42,a43,a44,a45,a46,n,a48)
  364. Digits(5)=Array(a50,a51,a52,a53,a54,a55,a56,n,a58)
  365.  
  366.  
  367. Digits(6)=Array(b20,b21,b22,b23,b24,b25,b26,n,b28)
  368. Digits(7)=Array(b30,b31,b32,b33,b34,b35,b36,n,b38)
  369. Digits(8)=Array(b40,b41,b42,b43,b44,b45,b46,n,b48)
  370. Digits(9)=Array(b50,b51,b52,b53,b54,b55,b56,n,b58)
  371. Digits(10)=Array(c00,c01,c02,c03,c04,c05,c06,n,c08)
  372. Digits(11)=Array(c10,c11,c12,c13,c14,c15,c16,n,c18)
  373.  
  374. Digits(12)=Array(c20,c21,c22,c23,c24,c25,c26,n,c28)
  375. Digits(13)=Array(c30,c31,c32,c33,c34,c35,c36,n,c38)
  376. Digits(14)=Array(c40,c41,c42,c43,c44,c45,c46,n,c48)
  377. Digits(15)=Array(c50,c51,c52,c53,c54,c55,c56,n,c58)
  378. Digits(16)=Array(d00,d01,d02,d03,d04,d05,d06,n,d08)
  379. Digits(17)=Array(d10,d11,d12,d13,d14,d15,d16,n,d18)
  380.  
  381. Digits(18)=Array(d40,d41,d42,d43,d44,d45,d46,n,d48)
  382. Digits(19)=Array(d50,d51,d52,d53,d54,d55,d56,n,d58)
  383. Digits(20)=Array(e00,e01,e02,e03,e04,e05,e06,n,e08)
  384. Digits(21)=Array(e10,e11,e12,e13,e14,e15,e16,n,e18)
  385. Digits(22)=Array(f00,f01,f02,f03,f04,f05,f06,n,f08)
  386. Digits(23)=Array(f10,f11,f12,f13,f14,f15,f16,n,f18)
  387.  
  388. 'credit -- Ball In Play
  389. Digits(24) = Array(e2,e3,e7,e4,e5,e1,e6,n,e23)
  390. Digits(25) = Array(e9,e17,e22,e19,e20,e8,e21,n,e24)
  391. Digits(26) = Array(f2,f3,f7,f4,f5,f1,f6,n,f23)
  392. Digits(27) = Array(f9,f17,f22,f19,f20,f8,f21,n,f24)
  393.  
  394.  
  395. Sub DisplayTimer_Timer
  396. Dim ChgLED,ii,num,chg,stat,obj
  397. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  398. If Not IsEmpty(ChgLED) Then
  399. If DesktopMode = True Then
  400. For ii = 0 To UBound(chgLED)
  401. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  402. if (num < 28) then
  403. For Each obj In Digits(num)
  404. If chg And 1 Then obj.State = stat And 1
  405. chg = chg\2 : stat = stat\2
  406. Next
  407. else
  408. end if
  409. next
  410. end if
  411. end if
  412. End Sub
  413.  
  414. '**********************************************************************************************************
  415. '**********************************************************************************************************
  416. Sub editDips
  417. Dim vpmDips : Set vpmDips = New cvpmDips
  418. With vpmDips
  419. .AddForm 700,400,"System 1 - DIP switches"
  420. .AddFrame 0,0,190,"Coin chutecontrol",&H00040000,Array("seperate",0,"same",&H00040000)'dip 19
  421. .AddFrame 0,46,190,"Game mode",&H00000400,Array("extraball",0,"replay",&H00000400)'dip 11
  422. .AddFrame 0,92,190,"High game to date awards",&H00200000,Array("noaward",0,"3 replays",&H00200000)'dip 22
  423. .AddFrame 0,138,190,"Balls per game",&H00000100,Array("5 balls",0,"3balls",&H00000100)'dip 9
  424. .AddFrame 0,184,190,"Tilt effect",&H00000800,Array("game over",0,"ball in play only",&H00000800)'dip 12
  425. .AddFrame 205,0,190,"Maximum credits",&H00030000,Array("5 credits",0,"8 credits",&H00020000,"10 credits",&H00010000,"15 credits",&H00030000)'dip 17&18
  426. .AddFrame 205,76,190,"Soundsettings",&H80000000,Array("sounds",0,"tones",&H80000000)'dip 32
  427. .AddFrame 205,122,190,"Attract tune",&H10000000,Array("no attract tune",0,"attract tune played every 6 minutes",&H10000000)'dip 29
  428. .AddChk 205,175,190,Array("Match feature",&H00000200)'dip 10
  429. .AddChk 205,190,190,Array("Credits displayed",&H00001000)'dip 13
  430. .AddChk 205,205,190,Array("Play credit button tune",&H00002000)'dip 14
  431. .AddChk 205,220,190,Array("Play tones when scoring",&H00080000)'dip 20
  432. .AddChk 205,235,190,Array("Play coin switch tune",&H00400000)'dip 23
  433. .AddChk 205,250,190,Array("High game to date displayed",&H00100000)'dip 21
  434. .AddLabel 50,280,300,20,"After hitting OK, press F3 to reset game with new settings."
  435. .ViewDips
  436. End With
  437. End Sub
  438. Set vpmShowDips = GetRef("editDips")
  439.  
  440. '**********************************************************************************************************
  441. '**********************************************************************************************************
  442. 'VPX
  443. '**********************************************************************************************************
  444. '**********************************************************************************************************
  445.  
  446.  
  447. '**********Sling Shot Animations
  448. ' Rstep and Lstep are the variables that increment the animation
  449. '****************
  450. Dim RStep, Lstep
  451.  
  452. Sub RightSlingShot_Slingshot
  453. vpmTimer.PulseSw 13
  454. DOF 203, DOFPulse
  455. PlaySound SoundFX("right_slingshot",DOFContactors), 0, 1, 0.05, 0.05
  456. RSling.Visible = 0
  457. RSling1.Visible = 1
  458. sling1.TransZ = -20
  459. RStep = 0
  460. RightSlingShot.TimerEnabled = 1
  461. End Sub
  462.  
  463. Sub RightSlingShot_Timer
  464. Select Case RStep
  465. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  466. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
  467. End Select
  468. RStep = RStep + 1
  469. End Sub
  470.  
  471.  
  472.  
  473.  
  474. ' *********************************************************************
  475. ' Supporting Ball & Sound Functions
  476. ' *********************************************************************
  477.  
  478. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  479. Vol = Csng(BallVel(ball) ^2 / 2000)
  480. End Function
  481.  
  482. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  483. Dim tmp
  484. tmp = ball.x * 2 / table1.width-1
  485. If tmp > 0 Then
  486. Pan = Csng(tmp ^10)
  487. Else
  488. Pan = Csng(-((- tmp) ^10) )
  489. End If
  490. End Function
  491.  
  492. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  493. Pitch = BallVel(ball) * 20
  494. End Function
  495.  
  496. Function BallVel(ball) 'Calculates the ball speed
  497. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  498. End Function
  499.  
  500. '*****************************************
  501. ' JP's VP10 Rolling Sounds
  502. '*****************************************
  503.  
  504. Const tnob = 5 ' total number of balls
  505. ReDim rolling(tnob)
  506. InitRolling
  507.  
  508. Sub InitRolling
  509. Dim i
  510. For i = 0 to tnob
  511. rolling(i) = False
  512. Next
  513. End Sub
  514.  
  515. Sub RollingTimer_Timer()
  516. Dim BOT, b
  517. BOT = GetBalls
  518.  
  519. ' stop the sound of deleted balls
  520. For b = UBound(BOT) + 1 to tnob
  521. rolling(b) = False
  522. StopSound("fx_ballrolling" & b)
  523. Next
  524.  
  525. ' exit the sub if no balls on the table
  526. If UBound(BOT) = -1 Then Exit Sub
  527.  
  528. ' play the rolling sound for each ball
  529. For b = 0 to UBound(BOT)
  530. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  531. rolling(b) = True
  532. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  533. Else
  534. If rolling(b) = True Then
  535. StopSound("fx_ballrolling" & b)
  536. rolling(b) = False
  537. End If
  538. End If
  539. Next
  540. End Sub
  541.  
  542. '**********************
  543. ' Ball Collision Sound
  544. '**********************
  545.  
  546. Sub OnBallBallCollision(ball1, ball2, velocity)
  547. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  548. End Sub
  549.  
  550.  
  551.  
  552. '************************************
  553. ' What you need to add to your table
  554. '************************************
  555.  
  556. ' a timer called RollingTimer. With a fast interval, like 10
  557. ' one collision sound, in this script is called fx_collide
  558. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  559. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  560.  
  561.  
  562. '******************************************
  563. ' Explanation of the rolling sound routine
  564. '******************************************
  565.  
  566. ' sounds are played based on the ball speed and position
  567.  
  568. ' the routine checks first for deleted balls and stops the rolling sound.
  569.  
  570. ' The For loop goes through all the balls on the table and checks for the ball speed and
  571. ' if the ball is on the table (height lower than 30) then then it plays the sound
  572. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  573.  
  574. ' The sound is played using the VOL, PAN and PITCH functions, so the volume and pitch of the sound
  575. ' will change according to the ball speed, and the PAN function will change the stereo position according
  576. ' to the position of the ball on the table.
  577.  
  578.  
  579. '**************************************
  580. ' Explanation of the collision routine
  581. '**************************************
  582.  
  583. ' The collision is built in VP.
  584. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  585. ' 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
  586. ' depending of the speed of the collision.
  587.  
  588.  
  589. Sub Pins_Hit (idx)
  590. PlaySound "pinhit_low", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  591. End Sub
  592.  
  593. Sub Targets_Hit (idx)
  594. PlaySound "target", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  595. End Sub
  596.  
  597. Sub Metals_Thin_Hit (idx)
  598. PlaySound "metalhit_thin", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  599. End Sub
  600.  
  601. Sub Metals_Medium_Hit (idx)
  602. PlaySound "metalhit_medium", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  603. End Sub
  604.  
  605. Sub Metals2_Hit (idx)
  606. PlaySound "metalhit2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  607. End Sub
  608.  
  609. Sub Gates_Hit (idx)
  610. PlaySound "gate4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  611. End Sub
  612.  
  613. Sub Spinner_Spin
  614. PlaySound "fx_spinner",0,.25,0,0.25
  615. End Sub
  616.  
  617. Sub Rubbers_Hit(idx)
  618. dim finalspeed
  619. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  620. If finalspeed > 20 then
  621. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  622. End if
  623. If finalspeed >= 6 AND finalspeed <= 20 then
  624. RandomSoundRubber()
  625. End If
  626. End Sub
  627.  
  628. Sub Posts_Hit(idx)
  629. dim finalspeed
  630. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  631. If finalspeed > 16 then
  632. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  633. End if
  634. If finalspeed >= 6 AND finalspeed <= 16 then
  635. RandomSoundRubber()
  636. End If
  637. End Sub
  638.  
  639. Sub RandomSoundRubber()
  640. Select Case Int(Rnd*3)+1
  641. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  642. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  643. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  644. End Select
  645. End Sub
  646.  
  647. Sub LeftFlipper_Collide(parm)
  648. RandomSoundFlipper()
  649. End Sub
  650.  
  651. Sub LeftFlipper2_Collide(parm)
  652. RandomSoundFlipper()
  653. End Sub
  654.  
  655. Sub RightFlipper_Collide(parm)
  656. RandomSoundFlipper()
  657. End Sub
  658.  
  659. Sub RandomSoundFlipper()
  660. Select Case Int(Rnd*3)+1
  661. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  662. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  663. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  664. End Select
  665. End Sub
Advertisement
Add Comment
Please, Sign In to add comment