Const BAM_VERSION = 0
Dim TableMiniplayfield
Dim TableShakeCounter, TableShakeFrames, TableShakeForce
Sub BAM_Init()
' Create the mini playfield
Dim w, h, m : w = xBAM.Table.Width : h = xBAM.Table.Length : m = 256
Set TableMiniplayfield = xBAM.CreateMiniPlayfield(-m, w+m, -m, h+m, -300, 300, w / 2, h / 2, 0)
End Sub
' Function call that shakes the table by an amount of milliseconds and with a defined force
Function ShakeTable(ByVal Frames, ByVal Force)
If (BAM_VERSION = 0) Then Exit Function
TableShakeTimer.Enabled = True
TableShakeCounter = 0
TableShakeFrames = Int(Frames / TableShakeTimer.Interval)
TableShakeForce = Force
PlayMusic 1, "ShakeMotor"
End Function
Sub TableShakeTimer_Expired()
TableShakeCounter = TableShakeCounter + 1
Dim CurrentForce : CurrentForce = TableShakeForce
If ((TableShakeCounter Mod 2) = 0) Then CurrentForce = -CurrentForce
TableMiniplayfield.MoveTo (xBAM.Table.Width / 2) + CurrentForce, (xBAM.Table.Length / 2), 0, 0, 0, 0, 1, TableShakeTimer.Interval / 1000
If (TableShakeCounter >= TableShakeFrames) Then
TableMiniplayfield.MoveTo (xBAM.Table.Width / 2), (xBAM.Table.Length / 2), 0, 0, 0, 0, 1, TableShakeTimer.Interval / 1000
TableShakeTimer.Enabled = False
StopMusic 1
End If
End Sub