Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '############################################################################################
- '############################################################################################
- '####### ########
- '####### Dark Shadow ########
- '####### (Nuova Bell Games 1986) ########
- '####### ########
- '############################################################################################
- '############################################################################################
- '
- ' Version 1.0
- '
- ' Thanks go to:
- ' Peter Blakemore from www.specialwhenlit.co.uk for providing lots of detailed images and gameplay videos.
- ' The videos can still be found on Youtube
- ' Joey2001 for playtesting the table fine tuning the flipper settings.
- Option Explicit
- On Error Resume Next
- ExecuteGlobal GetTextFile("controller.vbs")
- If Err Then MsgBox "You need the Controller.vbs file in order to run this table (installed with the VPX package in the scripts folder)"
- On Error Goto 0
- Randomize
- '-----------------------------------
- '------ Global Configurations -----
- '-----------------------------------
- Const FreePlay = True 'adds a coin on StartGame
- Const VolumeMultiplier = 2 'adjust the general sound volume of table objects and ball rolling
- Const MotorSound = True 'Play a sound while the target motor is running
- Const DimGI=10 'set GI lights intensity (base value is 10)
- Const EnableUpperPost = True 'add a Post below the top left target. The hole is there but I am not sure if it was installed on the production run
- Const EasyUpperFlipper = False 'increases the end angle of the upper flipper to allow direct target hits and easier cradled balls
- Const cGameName = "darkshad"
- Const UseSolenoids=1,UseLamps=1,SSolenoidOn="SolOn",SSolenoidOff="SolOff",SFlipperOn="",SFlipperOff="",SCoin="coin3"
- LoadVPM "01560000","nuova.vbs",3.2
- '-------------------------------
- '------ Keybord Handler ------
- '-------------------------------
- Dim i
- Sub Table1_KeyDown(ByVal keycode)
- If keycode = PlungerKey Then
- Plunger.PullBack
- PlaySound "plungerpull",0,1,AudioPan(Plunger),0.25,0,0,1,AudioFade(Plunger)
- End If
- If keycode = LeftFlipperKey Then
- if flipperactive then
- LeftFlipper.RotateToEnd
- PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
- end if
- End If
- If keycode = RightFlipperKey Then
- controller.switch(12) = 1
- if flipperactive then
- RightFlipper.RotateToEnd
- URightFlipper.RotateToEnd
- PlaySound SoundFX("fx_flipperup",DOFFlippers), 0, .67, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
- end if
- End If
- if FreePlay and keycode = Startgamekey then
- vpmtimer.pulsesw 9
- end if
- if keycode = LeftMagnaSave then
- ' controller.Switch(-7) = True
- end if
- If vpmKeyDown(KeyCode) Then Exit Sub
- ' Manual Ball Control
- If keycode = 46 Then ' C Key
- If EnableBallControl = 1 Then
- EnableBallControl = 0
- Else
- EnableBallControl = 1
- End If
- End If
- If EnableBallControl = 1 Then
- If keycode = 48 Then ' B Key
- If BCboost = 1 Then
- BCboost = BCboostmulti
- Else
- BCboost = 1
- End If
- End If
- If keycode = 203 Then BCleft = 1 ' Left Arrow
- If keycode = 200 Then BCup = 1 ' Up Arrow
- If keycode = 208 Then BCdown = 1 ' Down Arrow
- If keycode = 205 Then BCright = 1 ' Right Arrow
- End If
- End Sub
- Sub Table1_KeyUp(ByVal keycode)
- If keycode = PlungerKey Then
- Plunger.Fire
- PlaySound "plunger",0,1,AudioPan(Plunger),0.25,0,0,1,AudioFade(Plunger)
- End If
- If keycode = LeftFlipperKey Then
- LeftFlipper.RotateToStart
- if flipperactive then
- PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(LeftFlipper), 0.05,0,0,1,AudioFade(LeftFlipper)
- end if
- End If
- If keycode = RightFlipperKey Then
- controller.switch(12) = 0
- RightFlipper.RotateToStart
- URightFlipper.RotateToStart
- if flipperactive then
- PlaySound SoundFX("fx_flipperdown",DOFFlippers), 0, 1, AudioPan(RightFlipper), 0.05,0,0,1,AudioFade(RightFlipper)
- end if
- End If
- if keycode = LeftMagnaSave then
- controller.Switch(-7) = False
- end if
- If vpmKeyUp(KeyCode) Then Exit Sub
- 'Manual Ball Control
- If EnableBallControl = 1 Then
- If keycode = 203 Then BCleft = 0 ' Left Arrow
- If keycode = 200 Then BCup = 0 ' Up Arrow
- If keycode = 208 Then BCdown = 0 ' Down Arrow
- If keycode = 205 Then BCright = 0 ' Right Arrow
- End If
- End Sub
- '-----------------------------------
- '------ Solenoid Assignment ------
- '-----------------------------------
- SolCallback(19)="Sol_GameOn"
- SolCallback(15)="vpmSolSound SoundFX(""knocker"",DOFKnocker),"
- SolCallback(14)="bsTrough.SolOut"
- SolCallback(11)="Sol_DT"
- SolCallback(10)="Sol_Kicker"
- SolCallback(18)="Sol_Motor"
- SolCallback(17)="Sol_Diverter"
- Dim KickerBall
- Sub KickerArea_Hit
- Set KickerBall = ActiveBall
- Controller.Switch(5) = 1
- End Sub
- Sub KickerArea_Unhit:Controller.Switch(5) = 0:End Sub
- Randomize
- Sub Sol_Kicker(Enabled)
- if enabled and (KickerArea.ballcntover > 0) Then
- PlaySound SoundFX("popper_ball",DOFContactors),0,1,AudioPan(P_Kicker),0.25,0,0,1,AudioFade(P_Kicker)
- KickerBall.vely = - 35 - (15 * rnd)
- P_Kicker.TransZ = -40
- KickerArea.timerenabled = True
- end If
- End Sub
- Sub KickerArea_timer
- KickerArea.timerenabled = False
- P_Kicker.TransZ = 0
- End Sub
- Sub Sol_Motor(Enabled)
- Dim ii
- MotorTimer.enabled = enabled
- End Sub
- Sub Sol_Diverter(Enabled)
- if enabled Then
- Diverter_Open.isdropped = True
- Diverter_Closed.isdropped = False
- Diverter1.rotatetostart
- Diverter2.rotatetostart
- Else
- Diverter_Open.isdropped = False
- Diverter_Closed.isdropped = True
- Diverter1.rotatetoend
- Diverter2.rotatetoend
- end If
- S17.state = abs(not Enabled)
- End Sub
- ' this code is avoiding stuck balls behind or on the drop targets
- Sub Sol_DT(Enabled)
- if enabled Then
- DTTrigger.timerenabled = True
- end If
- End Sub
- Sub DTTrigger_Timer
- if DTTrigger.ballcntover = 0 Then
- DropTargetBank.DropSol_On
- DTTrigger.timerenabled = False
- end if
- End Sub
- Flipperactive = False
- Sub Sol_GameOn(enabled)
- VpmNudge.SolGameOn enabled
- Flipperactive = enabled
- if not Flipperactive Then
- LeftFlipper.RotateToStart
- URightFlipper.RotateToStart
- RightFlipper.RotateToStart
- end If
- end sub
- 'SolCallback(sLLFlipper)="vpmSolFlipper LeftFlipper,Nothing,"
- 'SolCallback(sLRFlipper)="vpmSolFlipper RightFlipper,URightFlipper,"
- for each obj in DimGICol
- obj.intensity = DimGI
- Next
- for each obj in GI
- obj.state = 1
- Next
- for each obj in GIBulbs
- obj.state = 1
- Next
- '--------------------------
- '------ Table Init ------
- '--------------------------
- Dim DesktopMode: DesktopMode = Table1.ShowDT
- If DesktopMode = True Then 'Show Desktop components
- Ramp17.visible=1
- Ramp16.visible=1
- Ramp15.visible=1
- SideWood.visible=1
- Else
- Ramp17.visible=0
- Ramp16.visible=0
- Ramp15.visible=0
- SideWood.visible=0
- End if
- P_upperpost.visible = enableUpperPost
- UpperPostRubber.visible = enableUpperPost
- UpperPostWall.isdropped = not enableUpperPost
- if EasyUpperFlipper Then
- URightFlipper.endangle = -78
- End If
- Dim bsTrough,obj,DropTargetBank,Flipperactive
- Sub Table1_init
- vpminit me
- Controller.GameName=cGameName
- Controller.SplashInfoLine="Dark Shadow" & vbNewLine & "created by mfuegemann"
- Controller.HandleKeyboard=False
- Controller.ShowTitle=0
- Controller.ShowFrame=0
- Controller.ShowDMDOnly=1
- 'Controller.Hidden = 1 'enable to hide DMD if You use a B2S backglass
- ' DMD position for 3 Monitor Setup
- ' Controller.Games(cGameName).Settings.Value("dmd_pos_x")=3850 'set this to 0 if You cannot find the DMD
- ' Controller.Games(cGameName).Settings.Value("dmd_pos_y")=300 'set this to 0 if You cannot find the DMD
- ' Controller.Games(cGameName).Settings.Value("dmd_width")=505
- ' Controller.Games(cGameName).Settings.Value("dmd_height")=155
- ' Controller.Games(cGameName).Settings.Value("rol")=0
- ' Controller.Games(cGameName).Settings.Value("ddraw") = 0 'set to 0 if You have problems with DMD showing or table stutter
- Controller.HandleMechanics=0
- Controller.Run
- If Err Then MsgBox Err.Description
- On Error Goto 0
- PinMAMETimer.Interval=PinMAMEInterval
- PinMAMETimer.Enabled = true
- vpmNudge.TiltSwitch=15
- vpmNudge.Sensitivity=5
- vpmNudge.TiltObj = Array(Bumper1,Bumper2,LeftSlingShot,RightSlingShot)
- vpmMapLights AllLights
- Set bsTrough=New cvpmBallStack
- bsTrough.InitSw 0,8,0,0,0,0,0,0 '0.1 = Switch 0
- bsTrough.InitKick BallRelease,90,5
- bsTrough.InitExitSnd SoundFX("BallRel",DOFContactors),SoundFX("Solenoid",DOFContactors)
- bsTrough.Balls=1
- set DropTargetBank = new cvpmDropTarget
- DropTargetBank.InitDrop Array(DT1,DT2,DT3,DT4), Array(17,18,19,20)
- DropTargetBank.InitSnd SoundFX("Targetdrop1",DOFContactors),SoundFX("TargetBankreset1",DOFContactors)
- DropTargetBank.CreateEvents "DropTargetBank"
- Diverter_Open.isdropped = True
- Diverter_Closed.isdropped = False
- End Sub
- Sub Table1_Exit()
- Controller.Pause = False
- Controller.Stop
- End Sub
- '------------------------------
- '------ Trough Handler ------
- '------------------------------
- Sub Drain_Hit()
- PlaySound "drain",0,1,AudioPan(Drain),0.25,0,0,1,AudioFade(Drain)
- bsTrough.AddBall Me
- End Sub
- '------------------------------
- '------ Switch Handler ------
- '------------------------------
- Sub TopHole_Hit:bsTopHole.addball Me:End Sub
- Sub Bumper1_Hit:vpmtimer.pulsesw(14):End Sub
- Sub Bumper2_Hit:vpmtimer.pulsesw(28):End Sub
- Sub Spinner1_Spin:vpmtimer.pulsesw(7):End Sub
- Sub MovingTargetCol_hit(idx):vpmtimer.pulsesw(26):HitMoveTarget:End Sub
- Sub LeftOutlane_Hit:Controller.Switch(37) = 1:DOF 103, DOFOn:End Sub
- Sub LeftOutlane_Unhit:Controller.Switch(37) = 0:DOF 103, DOFOff:End Sub
- Sub RightOutlane_Hit:Controller.Switch(25) = 1:End Sub
- Sub RightOutlane_Unhit:Controller.Switch(25) = 0:End Sub
- Sub Leftinlane_Hit:Controller.Switch(1) = 1:DOF 101, DOFOn:End Sub
- Sub Leftinlane_Unhit:Controller.Switch(1) = 0:DOF 101, DOFOff:End Sub
- Sub Rightinlane_Hit:Controller.Switch(1) = 1:DOF 102, DOFOn:End Sub
- Sub Rightinlane_Unhit:Controller.Switch(1) = 0:DOF 102, DOFOff:End Sub
- Sub EnterPlayfield_Hit:Controller.Switch(33) = 1:End Sub
- Sub EnterPlayfield_Unhit:Controller.Switch(33) = 0:End Sub
- Sub LeftTarget1_hit:vpmtimer.pulsesw(21):End Sub
- Sub LeftTarget2_hit:vpmtimer.pulsesw(22):End Sub
- Sub LeftTarget3_hit:vpmtimer.pulsesw(23):End Sub
- Sub LeftTarget4_hit:vpmtimer.pulsesw(24):End Sub
- Sub TopRollover1_Hit:Controller.Switch(2) = 1:End Sub
- Sub TopRollover1_Unhit:Controller.Switch(2) = 0:End Sub
- Sub TopRollover2_Hit:Controller.Switch(3) = 1:End Sub
- Sub TopRollover2_Unhit:Controller.Switch(3) = 0:End Sub
- Sub TopRollover3_Hit:Controller.Switch(4) = 1:End Sub
- Sub TopRollover3_Unhit:Controller.Switch(4) = 0:End Sub
- Sub TopTarget_Hit:vpmtimer.pulsesw(38):End Sub
- Sub RightTarget_Hit:vpmtimer.pulsesw(37):DOF 104, DOFPulse:End Sub
- '-----------------------------
- '------ Moving Target ------
- '-----------------------------
- Dim MovingDir,MTargets,MTargetsX,MTPos,ArrayPos,MTInterval,MTargetWalls,MTy,Pi,MTSpan,MotorAngle,MotorAngle2,LastPos,UpperLoopStartAngle,UpperLoopEndAngle
- Pi = 3.1415926535897932
- MotorAngle = 270
- MTPos = MT001.x
- MTy = MT001.y
- MTInterval = (MT019.x-MT001.x)/18
- MTSpan = MT019.x-MT001.x
- LastPos = -1
- MTargets = Array(MT001,MT002,MT003,MT004,MT005,MT006,MT007,MT008,MT009,MT010,MT011,MT012,MT013,MT014,MT015,MT016,MT017,MT018,MT019)
- MTargetsX = Array(MT020,MT021,MT022,MT023,MT024,MT025,MT026,MT027,MT028,MT029,MT030,MT031,MT032,MT033,MT034,MT035,MT036,MT037,MT038)
- MTargetWalls = Array(MTW01,MTW02,MTW03,MTW04,MTW05,MTW06,MTW07,MTW08,MTW09,MTW10,MTW11,MTW12,MTW13,MTW14,MTW15,MTW16,MTW17,MTW18,MTW19)
- UpperLoopStartAngle = 255
- UpperLoopEndAngle = 105
- Sub MotorTimer_Timer
- MotorAngle = MotorAngle + 1
- if MotorAngle > 359 Then
- MotorAngle = 0
- End If
- 'convert the rotating motor into lateral movement
- MTPos = MT001.x + ((MTSpan / 2) * (Sin(MotorAngle * Pi / 180) + 1))
- ArrayPos = cint((MTPos-MT001.x)/(MTInterval))
- if ArrayPos > 18 Then
- ArrayPos = 18
- End If
- if ArrayPos < 0 Then
- ArrayPos = 0
- End If
- 'visibility updates only if necessary
- if LastPos <> ArrayPos Then
- LastPos = ArrayPos
- for i=0 to 18
- MTargets(i).visible = False
- MTargetsX(i).visible = False
- MTargetWalls(i).isdropped = True
- Next
- 'activate the second "hit" row if target has been hit
- if MTMoveTimer.enabled Then
- MTargetsX(ArrayPos).visible = True
- Else
- MTargets(ArrayPos).visible = True
- End If
- MTargetWalls(ArrayPos).isdropped = False
- end if
- if MotorSound Then
- PlaySound SoundFX("metalhit_thin",DOFContactors),0,0.0002,0,0.25,0,0,1,AudioFade(MT001)
- End If
- End Sub
- Sub HitMoveTarget
- DOF 105, DOFPulse
- MTMoveTimer.enabled = False
- MTMoveTimer.enabled = True
- End Sub
- Sub MTMoveTimer_Timer
- MTMoveTimer.enabled = False
- End Sub
- '**********Sling Shot Animations
- ' Rstep and Lstep are the variables that increment the animation
- '****************
- Dim RStep, Lstep
- Sub RightSlingShot_Slingshot
- PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05
- vpmtimer.pulsesw(13)
- RSling.Visible = 0
- RSling1.Visible = 1
- sling1.TransZ = -20
- RStep = 0
- RightSlingShot.TimerEnabled = 1
- End Sub
- Sub RightSlingShot_Timer
- Select Case RStep
- Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
- Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0
- End Select
- RStep = RStep + 1
- End Sub
- Sub LeftSlingShot_Slingshot
- PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05
- vpmtimer.pulsesw(29)
- LSling.Visible = 0
- LSling1.Visible = 1
- sling2.TransZ = -20
- LStep = 0
- LeftSlingShot.TimerEnabled = 1
- End Sub
- Sub LeftSlingShot_Timer
- Select Case LStep
- Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
- Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0
- End Select
- LStep = LStep + 1
- End Sub
- '*********************************************************************
- ' Positional Sound Playback Functions
- '*********************************************************************
- ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
- ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
- ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
- Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
- PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
- End Sub
- ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
- Sub PlaySoundAt(soundname, tableobj)
- PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
- End Sub
- Sub PlaySoundAtBall(soundname)
- PlaySoundAt soundname, ActiveBall
- End Sub
- '*********************************************************************
- ' Supporting Ball & Sound Functions
- '*********************************************************************
- 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
- Dim tmp
- tmp = tableobj.y * 2 / Table1.height-1
- If tmp > 0 Then
- AudioFade = Csng(tmp ^10)
- Else
- AudioFade = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "Table1" is the name of the table
- Dim tmp
- tmp = tableobj.x * 2 / Table1.width-1
- If tmp > 0 Then
- AudioPan = Csng(tmp ^10)
- Else
- AudioPan = Csng(-((- tmp) ^10) )
- End If
- End Function
- Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
- Vol = Csng(BallVel(ball) ^2 / 300) * VolumeMultiplier
- End Function
- Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
- Pitch = BallVel(ball) * 20
- End Function
- Function BallVel(ball) 'Calculates the ball speed
- BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
- End Function
- '*****************************************
- ' JP's VP10 Rolling Sounds
- '*****************************************
- Const tnob = 5 ' total number of balls
- ReDim rolling(tnob)
- InitRolling
- Sub InitRolling
- Dim i
- For i = 0 to tnob
- rolling(i) = False
- Next
- End Sub
- Sub RollingTimer_Timer()
- Dim BOT, b
- BOT = GetBalls
- ' stop the sound of deleted balls
- For b = UBound(BOT) + 1 to tnob
- rolling(b) = False
- StopSound("fx_ballrolling" & b)
- Next
- ' exit the sub if no balls on the table
- If UBound(BOT) = -1 Then Exit Sub
- ' play the rolling sound for each ball
- For b = 0 to UBound(BOT)
- If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
- rolling(b) = True
- PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
- Else
- If rolling(b) = True Then
- StopSound("fx_ballrolling" & b)
- rolling(b) = False
- End If
- End If
- Next
- End Sub
- '**********************
- ' Ball Collision Sound
- '**********************
- Sub OnBallBallCollision(ball1, ball2, velocity)
- PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
- End Sub
- '*****************************************
- ' ninuzzu's FLIPPER SHADOWS
- '*****************************************
- sub FlipperTimer_Timer()
- FlipperLSh.RotZ = LeftFlipper.currentangle
- FlipperRSh.RotZ = RightFlipper.currentangle
- FlipperURSh.RotZ = URightFlipper.currentangle
- End Sub
- '*****************************************
- ' ninuzzu's BALL SHADOW
- '*****************************************
- Dim BallShadow
- BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
- Sub BallShadowUpdate_timer()
- Dim BOT, b
- BOT = GetBalls
- ' hide shadow of deleted balls
- If UBound(BOT)<(tnob-1) Then
- For b = (UBound(BOT) + 1) to (tnob-1)
- BallShadow(b).visible = 0
- Next
- End If
- ' exit the Sub if no balls on the table
- If UBound(BOT) = -1 Then Exit Sub
- ' render the shadow for each ball
- For b = 0 to UBound(BOT)
- If BOT(b).X < Table1.Width/2 Then
- BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
- Else
- BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
- End If
- ballShadow(b).Y = BOT(b).Y + 12
- If BOT(b).Z > 20 Then
- BallShadow(b).visible = 1
- Else
- BallShadow(b).visible = 0
- End If
- Next
- End Sub
- '************************************
- ' What you need to add to your table
- '************************************
- ' a timer called RollingTimer. With a fast interval, like 10
- ' one collision sound, in this script is called fx_collide
- ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
- ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
- '******************************************
- ' Explanation of the rolling sound routine
- '******************************************
- ' sounds are played based on the ball speed and position
- ' the routine checks first for deleted balls and stops the rolling sound.
- ' The For loop goes through all the balls on the table and checks for the ball speed and
- ' if the ball is on the table (height lower than 30) then then it plays the sound
- ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
- ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
- ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
- ' according to the position of the ball on the table.
- '**************************************
- ' Explanation of the collision routine
- '**************************************
- ' The collision is built in VP.
- ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
- ' 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
- ' depending of the speed of the collision.
- Sub Pins_Hit (idx)
- PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
- End Sub
- Sub Targets_Hit (idx)
- PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals_Thin_Hit (idx)
- PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals_Medium_Hit (idx)
- PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Metals2_Hit (idx)
- PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Gates_Hit (idx)
- PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Sub
- Sub Spinner_Spin
- PlaySound "fx_spinner", 0, 0.5, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
- End Sub
- Sub Rubbers_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 20 then
- PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End if
- If finalspeed >= 2 AND finalspeed <= 20 then
- RandomSoundRubber()
- End If
- End Sub
- Sub Posts_Hit(idx)
- dim finalspeed
- finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
- If finalspeed > 16 then
- PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End if
- If finalspeed >= 3 AND finalspeed <= 16 then
- RandomSoundRubber()
- End If
- End Sub
- Sub RandomSoundRubber()
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Select
- End Sub
- Sub LeftFlipper_Collide(parm)
- RandomSoundFlipper()
- End Sub
- Sub RightFlipper_Collide(parm)
- RandomSoundFlipper()
- End Sub
- Sub URightFlipper_Collide(parm)
- RandomSoundFlipper()
- End Sub
- Sub RandomSoundFlipper()
- Select Case Int(Rnd*3)+1
- Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
- End Select
- End Sub
- '*****************************************
- ' rothbauerw's Manual Ball Control
- '*****************************************
- Dim BCup, BCdown, BCleft, BCright
- Dim ControlBallInPlay, ControlActiveBall, EnableBallControl
- Dim BCvel, BCyveloffset, BCboostmulti, BCboost
- BCboost = 1 'Do Not Change - default setting
- BCvel = 4 'Controls the speed of the ball movement
- BCyveloffset = -0.01 'Offsets the force of gravity to keep the ball from drifting vertically on the table, should be negative
- BCboostmulti = 3 'Boost multiplier to ball veloctiy (toggled with the B key)
- ControlBallInPlay = false
- Sub StartBallControl_Hit()
- Set ControlActiveBall = ActiveBall
- ControlBallInPlay = true
- End Sub
- Sub StopBallControl_Hit()
- ControlBallInPlay = false
- End Sub
- Sub BallControlTimer_Timer()
- If EnableBallControl and ControlBallInPlay then
- If BCright = 1 Then
- ControlActiveBall.velx = BCvel*BCboost
- ElseIf BCleft = 1 Then
- ControlActiveBall.velx = -BCvel*BCboost
- Else
- ControlActiveBall.velx = 0
- End If
- If BCup = 1 Then
- ControlActiveBall.vely = -BCvel*BCboost
- ElseIf BCdown = 1 Then
- ControlActiveBall.vely = BCvel*BCboost
- Else
- ControlActiveBall.vely = bcyveloffset
- End If
- End If
- End Sub
- '-------------------------------
- '------ DIP Switch Menu ------
- '-------------------------------
- Sub editDips
- Dim vpmDips:Set vpmDips=New cvpmDips
- With vpmDips
- .AddForm 200,280,"Dark Shadows DIP switches"
- .AddFrame 0, 0,270,"Balls per game",&HC0000000,Array("2 balls",&HC0000000,"3 balls",0,"4 balls",&H80000000,"5 balls",&H40000000)
- .AddChk 5,80,270,Array("Match feature",&H08000000)
- .AddChk 5,100,270,Array("Show credits",&H04000000)
- .AddLabel 0,130,280,20,"After hitting OK, press F3 to reset game with new settings."
- .ViewDips
- End With
- End Sub
- Set vpmShowDips=GetRef("editDips")
Advertisement
Add Comment
Please, Sign In to add comment