The great thing is, this can be adapted to any lights or other animation that was created using alpha ramps, as it will reduce the performance hit to only the amount of ramps showing at any one time instead of all of the ramps included in the light/animation. As it is now, they are still drawn, only with a width of 0 to make them appear invisible, but they still causes a drop in performance.
This new method basically 'turns off' the alpha ramp, so when it isn't being used, it isn't seen and it isn't being drawn as an alpha ramp, so no additional drop in performance.
As you can see below, instead of setting .widthtop and .widthbottom to 0 to make it appear invisible, this turns the .alpha property on and off which also causes it to disappear and not be drawn when off. It is scripted below much like drop walls are, except with the necessary light refresh to update the animation.
New Alpha Ramp Plunger Code:
Plunger - Timer Enabled with Interval set at 40, and Enable Mechanical Plunger checked
If keycode = PlungerKey Then Plunger.Pullback:Pcount = 0:PTime.Enabled = 1:Plunger.TimerEnabled=0
End Sub
Sub Table_KeyUp(ByVal keycode)
If keycode = PlungerKey Then
PTime.Enabled = 0:Pcount = 0:PTime2.Enabled = 1:Plunger.Fire:Plunger.TimerEnabled=1
If(BallinPlunger = 1) then 'the ball is in the plunger lane
PlaySound "Plunger2"
Else
PlaySound "Plunger"
End if
End If
End Sub
'***********************
'Koadic's NewStyle Alpha Ramp Plunger Scripting
'(based heavily on and modified from JP's work)
'***********************
Dim Plungers:Plungers = Array(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p12)
Dim PlNewPos, PlOldPos, PCount, BallinPlunger
ResetPlungers
Sub swPlunger_Hit:BallinPlunger = 1:End Sub 'in this sub you may add a switch, for example Controller.Switch(14) = 1
Sub swPlunger_UnHit:BallinPlunger = 0:End Sub 'in this sub you may add a switch, for example Controller.Switch(14) = 0
Sub ResetPlungers
For x = 1 to 12:Plungers(x).alpha = 0:Next
Plungers(0).alpha = 1
Pcount = 0
PlNewPos = 0
PlOldPos = 0
PRefresh.state = ABS(PRefresh.state - 1)
End Sub
Sub PTime_Timer
If Pcount <12 Then
Plungers(Pcount).alpha = 0
Pcount = Pcount + 1
Plungers(Pcount).alpha = 1
PRefresh.state = ABS(PRefresh.state - 1)
End If
End Sub
Sub PTime2_Timer
Select Case Pcount
Case 0:ResetPlungers
Case 1:Plungers(0).alpha = 0:Plungers(2).alpha = 1:PRefresh.state = ABS(PRefresh.state - 1)
Case 2:ResetPlungers:Me.Enabled = 0
End Select
Pcount = Pcount + 1
End Sub
Sub Plunger_Timer()
Plungers(PlOldPos).alpha = 0
PlNewPos = INT(Plunger.Position/2)
If PlNewPos > 12 Then PlNewPos = 12
Plungers(PlNewPos).alpha = 1
PlOldPos = PlNewPos
PRefresh.state = ABS(PRefresh.state - 1)
End Sub




Contributor
Top















are all trademarks of VPFORUMS.