Pages : 1
#1 Le 07/03/2020, à 18:06
- commentallezvous
equivalent en python ?
bonjour
quelqu'un saurait trouver l’équivalent en python ,? merci
' *********************************************************************
' ** **
' ** FUTURE PINBALL **
' ** **
' ** Generic Table Script v1.0 **
' ** **
' ** (C) 2007 Chris Leathley - BSP Software Design Solutions **
' ** **
' ** This script should provide a simple frame work you can use in **
' ** your own tables as a starting point. **
' ** **
' *********************************************************************
Option Explicit ' Force explicit variable declaration
' Define any Constants
Const constMaxPlayers = 4 ' Maximum number of players per game (between 1 and 4)
Const constBallSaverTime = 5000 ' Time in which a free ball is given if it lost very quickly
' Set this to 0 if you don't want this feature
Const constMaxMultiplier = 6 ' Defines the maximum bonus multiplier level
' Define Global Variables
'
Dim PlayersPlayingGame ' number of players playing the current game
Dim CurrentPlayer ' current player (1-4) playing the game
Dim BonusPoints(4) ' Bonus Points for the current player
Dim BonusMultiplier(4) ' Bonus Multiplier for the current player
Dim BallsRemaining(4) ' Balls remaining to play (inclusive) for each player
Dim ExtraBallsAwards(4) ' number of EB's out-standing (for each player)
' Define Game Control Variables
Dim LastSwitchHit ' Id of last switch hit
Dim BallsOnPlayfield ' number of balls on playfield (multiball exclusive)
Dim BallsInLock ' number of balls in multi-ball lock
' Define Game Flags
Dim bFreePlay ' Either in Free Play or Handling Credits
Dim bOnTheFirstBall ' First Ball (player one). Used for Adding New Players
Dim bBallInPlungerLane ' is there a ball in the plunger lane
Dim bBallSaverActive ' is the ball saver active
Dim bMultiBallMode ' multiball mode active ?
Dim bEnteringAHighScore ' player is entering their name into the high score table
' *********************************************************************
' ** **
' ** Future Pinball Defined Script Events **
' ** **
' *********************************************************************
' The Method Is Called Immediately the Game Engine is Ready to
' Start Processing the Script.
'
Sub FuturePinball_BeginPlay()
' seed the randomiser (rnd(1) function)
Randomize
' initalise the player display reel to the last known player scores
Player1Reel.SetValue(nvScore1)
Player2Reel.SetValue(nvScore2)
Player3Reel.SetValue(nvScore3)
Player4Reel.SetValue(nvScore4)
' We want the player to put in credits (Change this
bFreePlay = FALSE
' kill the last switch hit (this this variable is very usefull for game control)
set LastSwitchHit = DummyTrigger
' initialse any other flags
bOnTheFirstBall = FALSE
bEnteringAHighScore = FALSE
BallsOnPlayfield = 0
BallsInLock = 0
EndOfGame()
End Sub
' This Method is Called when the user has exited the Game Player. It should
' save any RAM variables that need to be persistant.
'
Sub FuturePinball_EndPlay()
End Sub
' The User Has Pressed A Key on the Keyboard..
'
Sub FuturePinball_KeyPressed(ByVal KeyCode)
'AddDebugText "KeyCode = " & KeyCode
'AddDebugText "Titled = " & fpTilted
'
' Process any keys which are valid at all times
'
' The Player has Inserted a Coin
If (KeyCode = GetKeyCode(InsertCoinKey)) Then
PlaySound "CoinIn"
nvCredits = nvCredits + 1
'AddDebugText "Insert Coin, Credits = " & nvCredits
' If not Tilted, then give some feed back to the player
If (fpTilted = FALSE) Then
' Flash the Slingshot Bulbs. This is rather Common on Pinball machines
' though you can do anything at this point
LeftSlingshotBulb1.FlashForMs 200, 100, BulbOff
LeftSlingshotBulb2.FlashForMs 200, 100, BulbOff
RightSlingshotBulb1.FlashForMs 200, 100, BulbOff
RightSlingshotBulb2.FlashForMs 200, 100, BulbOff
' Maybe play a sound at this point or put something on the display
End If
End If
' The Player is Pulling back the Plunger
If (KeyCode = GetKeyCode(PlungerKey)) Then
Plunger.Pull
End If
'
' Process The Next set of keys depeding of wether there is a game in progress or not
'
' Is A Game in Progress?
If (fpGameInPlay = TRUE) Then
' and not Tilted ?
If (fpTilted = FALSE) Then
' If the Left Flipper Key Has Been Press, Activate The Left Flipper(s)
If (KeyCode = GetKeyCode(LeftFlipperKey)) Then
LeftFlipper.SolenoidOn
PlaySound "Flipper"
End If
' If the Right Flipper Key Has Been Press, Activate The Right Flipper(s)
If (KeyCode = GetKeyCode(RightFlipperKey)) Then
RightFlipper.SolenoidOn
PlaySound "Flipper"
End If
' Another player starting?
If (KeyCode = GetKeyCode(StartGameKey)) Then
' must be less than max players and must be on the the very first ball of the game
If ((PlayersPlayingGame < constMaxPlayers) And (bOnTheFirstBall = TRUE)) Then
' free play or credits
If (bFreePlay = TRUE) Then
' add the extra player
PlayersPlayingGame = PlayersPlayingGame + 1
'AddDebugText "Extra Player (Free Play)" & PlayersPlayingGame
' Update the stats
nvTotalGamesPlayed = nvTotalGamesPlayed + 1
Else
If (nvCredits > 0) then
PlayersPlayingGame = PlayersPlayingGame + 1
'AddDebugText "Extra Player (Credits)" & PlayersPlayingGame
' update the stats
nvTotalGamesPlayed = nvTotalGamesPlayed + 1
nvCredits = nvCredits - 1
Else
' Not Enough Credits to start a game.
' Maybe Play a Sound or put "Insert Coin" on a display
End If
End If
End If
End If
End If ' If (fpTilted)
Else ' If (fpGameInPlay)
' there isn't a game in play (we are in the attract mode)
' wait for the start key to be pressed and start a new game
If (KeyCode = GetKeyCode(StartGameKey)) Then
' Free Play Mode ?
If (bFreePlay = TRUE) Then
' Yep. Only allow a game to Start if there are no balls on the playfield.
' This can happen if the player starts a game too quick after finishing the
' last game and the machine is ejecting any locked balls.
If (BallsOnPlayfield = 0) Then
' A Game is now in progress, reset the table for a new Game
ResetForNewGame()
End If
Else
' paying by credits, do we have any ?
If (nvCredits > 0) Then
' Yep. Only allow a game to start if there are no balls on the playfield
If (BallsOnPlayfield = 0) Then
' remove a credit
nvCredits = nvCredits - 1
' much the same as above
ResetForNewGame()
End If
Else
' Not Enough Credits to start a game.
' Maybe Play a Sound or put "Insert Coin" on a display
End If
End If
End If
End If ' If (fpGameInPlay)
End Sub
' The User Has Released A Key on the Keyboard..
'
Sub FuturePinball_KeyReleased(ByVal KeyCode)
'
' Process any keys which are valid at all times
'
' The Player has released the Plunger, Let it go..
If (KeyCode = GetKeyCode(PlungerKey)) Then
Plunger.LetGo
PlaySound "PlungerRelease"
End If
'
' Process The Next set of keys depeding of wether there is a game in progress or not
'
' Is A Game in Progress?
If (fpGameInPlay = TRUE) Then
' and not tilted
If (fpTilted = FALSE) Then
' The Left Flipper Key has been released, Turn Off the Left Flipper(s)
If (KeyCode = GetKeyCode(LeftFlipperKey)) Then
LeftFlipper.SolenoidOff
End If
' The Right Flipper Key has been released, Turn Off the Right Flipper(s)
If (KeyCode = GetKeyCode(RightFlipperKey)) Then
RightFlipper.SolenoidOff
End If
End If
End If
End Sub
' The User Has Paused The Game..
'
Sub FuturePinball_Paused()
End Sub
' The User Has UnPaused (Resumed) The Game..
'
Sub FuturePinball_UnPaused()
End Sub
' The Played has Nudged the Table a little too hard/much and a Warning
' must be given to the player
'
Sub FuturePinball_TiltWarning(ByVal Warnings)
'AddDebugText "Tilt Warning" & Warnings
' play a sound at this point and put something on a display
End Sub
' The Player has tilted the machine (Too Many Warnings)
'
Sub FuturePinball_Tilted()
'AddDebugText "**Tilted**"
' play a sound
PlaySound "Tilt"
' ensure that the flippers are down (as the keys won't work from now on)
LeftFlipper.SolenoidOff
RightFlipper.SolenoidOff
' you may wish to turn off any lights at this point. (The Light Sequencer
' will make this very easy)
' start the tilt recovery timer which waits until all balls have drained
' before doing the end of ball sequence (or end of game)
TiltRecoveryTimer.Interval = 2000
TiltRecoveryTimer.Enabled = TRUE
End Sub
' A Music Channel has finished Playing.
'
' Channel is set to the channel number that has finished.
'
Sub FuturePinball_MusicFinished(ByVal Channel)
End Sub
' High Score entry has been completed by the player.
'
' Position is set to the position in the high score table (1 - 4)
' if it is set to 0 then there was no new High Score
'
' Special is set to 1 if the Special High Score was beaten
'
Sub FuturePinball_NameEntryComplete(ByVal Position, ByVal Special)
' has the player beaten a high score
If (Position <> 0) Then
' maybe award something (like an extra credit) based on the high score position
End If
' has the player beaten the special score (if applicable)
If (Special <> 0) Then
End If
bEnteringAHighScore = FALSE
' check to see if there are any more players playing to the current game
EndOfBallComplete()
End Sub
' *********************************************************************
' ** **
' ** User Defined Script Events **
' ** **
' *********************************************************************
' Initialise the Table for a new Game
'
Sub ResetForNewGame()
Dim i
'AddDebugText "ResetForNewGame"
' get Future Pinball to zero out the nvScore (and nvSpecialScore) Variables
' aswell and ensure the camera is looking in the right direction.
' this also Sets the fpGameInPlay flag
BeginGame()
Player1Reel.ResetToZero
Player2Reel.ResetToZero
Player3Reel.ResetToZero
Player4Reel.ResetToZero
' increment the total number of games played
nvTotalGamesPlayed = nvTotalGamesPlayed + 1
' Start with player 1
CurrentPlayer = 1
' Single player (for now, more can be added in later)
PlayersPlayingGame = 1
' We are on the First Ball (for Player One)
bOnTheFirstBall = TRUE
' initialise all the variables which are used for the duration of the game
' (do all players incase any new ones start a game)
For i = 1 To constMaxPlayers
' Bonus Points for the current player
BonusPoints(i) = 0
' Initial Bonus Multiplier
BonusMultiplier(i) = 1
' Balls Per Game
BallsRemaining(i) = nvBallsPerGame
' Number of EB's out-standing
ExtraBallsAwards(i) = 0
Next
' initialise any other flags
bMultiBallMode = FALSE
' you may wish to start some music, play a sound, do whatever at this point
' set up the start delay to handle any Start of Game Attract Sequence
FirstBallDelayTimer.Interval = 500
FirstBallDelayTimer.Enabled = TRUE
End Sub
' This Timer is used to delay the start of a game to allow any attract sequence to
' complete. When it expires it creates a ball for the player to start playing with
'
Sub FirstBallDelayTimer_Expired()
' stop the timer
FirstBallDelayTimer.Enabled = FALSE
' reset the table for a new ball
ResetForNewPlayerBall()
' create a new ball in the shooters lane
CreateNewBall()
End Sub
' (Re-)Initialise the Table for a new ball (either a new ball after the player has
' lost one or we have moved onto the next player (if multiple are playing))
'
Sub ResetForNewPlayerBall()
' make sure the correct display is upto date
AddScore(0)
' set the current players bonus multiplier back down to 1X
SetBonusMultiplier(1)
' reset any drop targets, lights, game modes etc..
ShootAgainLight.State = BulbOff
End Sub
' Create a new ball on the Playfield
'
Sub CreateNewBall()
' create a ball in the plunger lane kicker.
PlungerKicker.CreateBall
' There is a (or another) ball on the playfield
BallsOnPlayfield = BallsOnPlayfield + 1
' kick it out..
PlungerKicker.SolenoidPulse
End Sub
' The Player has lost his ball (there are no more balls on the playfield).
' Handle any bonus points awarded
'
Sub EndOfBall()
Dim BonusDelayTime
'AddDebugText "EndOfBall"
' the first ball has been lost. From this point on no new players can join in
bOnTheFirstBall = FALSE
' only process any of this if the table is not tilted. (the tilt recovery
' mechanism will handle any extra balls or end of game)
If (fpTilted = FALSE) Then
Dim AwardPoints
' add in any bonus points (multipled by the bunus multiplier)
AwardPoints = BonusPoints(CurrentPlayer) * BonusMultiplier(CurrentPlayer)
AddScore(AwardPoints)
'AddDebugText "Bonus Points = " & AwardPoints
' you may wish to do some sort of display effects which the bonus is
' being added to the players score
' add a bit of a delay to allow for the bonus points to be added up
BonusDelayTime = 1000
Else
' no bonus, so move to the next state quickly
BonusDelayTime = 20
End If
' start the end of ball timer which allows you to add a delay at this point
EndOfBallTimer.Interval = BonusDelayTime
EndOfBallTimer.Enabled = TRUE
End Sub
' The Timer which delays the machine to allow any bonus points to be added up
' has expired. Check to see if there are any extra balls for this player.
' if not, then check to see if this was the last ball (of the currentplayer)
'
Sub EndOfBallTimer_Expired()
' disable the timer
EndOfBallTimer.Enabled = FALSE
' if were tilted, reset the internal tilted flag (this will also
' set fpTiltWarnings back to zero) which is useful if we are changing player LOL
fpTilted = FALSE
' has the player won an extra-ball ? (might be multiple outstanding)
If (ExtraBallsAwards(CurrentPlayer) <> 0) Then
'AddDebugText "Extra Ball"
' yep got to give it to them
ExtraBallsAwards(CurrentPlayer) = ExtraBallsAwards(CurrentPlayer) - 1
' if no more EB's then turn off any shoot again light
If (ExtraBallsAwards(CurrentPlayer) = 0) Then
ShootAgainLight.State = BulbOff
End If
' You may wish to do a bit of a song and dance at this point
' Create a new ball in the shooters lane
CreateNewBall()
Else ' no extra balls
BallsRemaining(CurrentPlayer) = BallsRemaining(CurrentPlayer) - 1
' was that the last ball ?
If (BallsRemaining(CurrentPlayer) <= 0) Then
'AddDebugText "No More Balls, High Score Entry"
' Submit the currentplayers score to the High Score system built into Future Pinball
' if they have gotten a high score then it will ask them for their initials. If not
' it will call the FuturePinball_NameEntryComplete right away
bEnteringAHighScore = TRUE
EnterHighScore(CurrentPlayer)
' you may wish to play some music at this point
Else
' not the last ball (for that player)
' if multiple players are playing then move onto the next one
EndOfBallComplete()
End If
End If
End Sub
' This function is called when the end of bonus display
' (or high score entry finished) and it either end the game or
' move onto the next player (or the next ball of the same player)
'
Sub EndOfBallComplete()
Dim NextPlayer
'AddDebugText "EndOfBall - Complete"
' are there multiple players playing this game ?
If (PlayersPlayingGame > 1) Then
' then move to the next player
NextPlayer = CurrentPlayer + 1
' are we going from the last player back to the first
' (ie say from player 4 back to player 1)
If (NextPlayer > PlayersPlayingGame) Then
NextPlayer = 1
End If
Else
NextPlayer = CurrentPlayer
End If
'AddDebugText "Next Player = " & NextPlayer
' is it the end of the game ? (all balls been lost for all players)
If ((BallsRemaining(CurrentPlayer) <= 0) And (BallsRemaining(NextPlayer) <= 0)) Then
' you may wish to do some sort of Point Match free game award here
' generally only done when not in free play mode
' set the machine into game over mode
EndOfGame()
' you may wish to put a Game Over message on the
Else
' set the next player
CurrentPlayer = NextPlayer
' make sure the correct display is upto date
AddScore(0)
' reset the playfield for the new player (or new ball)
ResetForNewPlayerBall()
' and create a new ball
CreateNewBall()
End If
End Sub
' This frunction is called at the End of the Game, it should reset all
' Drop targets, and eject any 'held' balls, start any attract sequences etc..
Sub EndOfGame()
'AddDebugText "End Of Game"
' let Future Pinball know that the game has finished.
' This also clear the fpGameInPlay flag.
EndGame()
' ensure that the flippers are down
LeftFlipper.SolenoidOff
RightFlipper.SolenoidOff
' turn off the reel bulbs
Player1Reel.State = BulbOff
Player2Reel.State = BulbOff
Player3Reel.State = BulbOff
Player4Reel.State = BulbOff
' set any lights for the attract mode
SetAllLightsForAttractMode()
' you may wish to light any Game Over Light you may have
End Sub
' The tilt recovery timer waits for all the balls to drain before continuing on
' as per normal
'
Sub TiltRecoveryTimer_Expired()
' disable the timer
TiltRecoveryTimer.Enabled = FALSE
' if all the balls have been drained then..
If (BallsOnPlayfield = 0) Then
' do the normal end of ball thing (this dosn't give a bonus if the table is tilted)
EndOfBall()
Else
' else retry (checks again in another second)
TiltRecoveryTimer.Interval = 1000
TiltRecoveryTimer.Enabled = TRUE
End If
End Sub
' Set any lights for the Attract Mode.
'
Sub SetAllLightsForAttractMode()
ShootAgainLight.State = BulbBlink
End Sub
' *********************************************************************
' ** **
' ** Drain / Plunger Functions **
' ** **
' *********************************************************************
' lost a ball ;-( check to see how many balls are on the playfield.
' if only one then decrement the remaining count and test for End of game
' if more than 1 ball (multi-ball) then kill of the ball but don't create
' a new one
'
Sub Drain_Hit()
' Destroy the ball
Drain.DestroyBall
BallsOnPlayfield = BallsOnPlayfield - 1
' pretend to knock the ball into the ball storage mech
PlaySound "Drain"
' if there is a game in progress and
If (fpGameInPlay = TRUE) And (fpTilted = FALSE) Then
' is the ball saver active,
If (bBallSaverActive = TRUE) Then
' yep, create a new ball in the shooters lane
CreateNewBall()
' you may wish to put something on a display or play a sound at this point
Else
' cancel any multiball if on last ball (ie. lost all other balls)
'
If (BallsOnPlayfield = 1) Then
' and in a multi-ball??
If (bMultiBallMode = True) then
' not in multiball mode any more
bMultiBallMode = False
' you may wish to change any music over at this point and
' turn off any multiball specific lights
End If
End If
' was that the last ball on the playfield
If (BallsOnPlayfield = 0) Then
' handle the end of ball (change player, high score entry etc..)
EndOfBall()
End If
End If
End If
End Sub
' A ball is pressing down the trigger in the shooters lane
'
Sub PlungerLaneTrigger_Hit()
bBallInPlungerLane = TRUE
' remember last trigger hit by the ball
set LastSwitchHit = PlungerLaneTrigger
End Sub
' A Ball may of rolled into the Plunger Lane Kicker, if so then kick it
' back out again
'
Sub PlungerKicker_Hit()
PlungerKicker.SolenoidPulse
End Sub
' The Ball has rolled out of the Plunger Lane. Check to see if a ball saver machanisim
' is needed and if so fire it up.
'
Sub PlungerLaneGate_Hit()
' if there is a need for a ball saver, then start off a timer
' only start if it is currently not running, else it will reset the time period
If (constBallSaverTime <> 0) And (bBallSaverActive <> TRUE) Then
' and only if the last trigger hit was the plunger wire.
' (ball in the shooters lane)
If (LastSwitchHit.Name = "PlungerLaneTrigger") Then
' set our game flag
bBallSaverActive = TRUE
' start the timer
BallSaverTimer.Enabled = FALSE
BallSaverTimer.Interval = constBallSaverTime
BallSaverTimer.Enabled = TRUE
' if you have a ball saver light you might want to turn it on at this
' point (or make it flash)
End If
End If
End Sub
' The ball saver timer has expired. Turn it off and reset the game flag
'
Sub BallSaverTimer_Expired()
' stop the timer from repeating
BallSaverTimer.Enabled = FALSE
' clear the flag
bBallSaverActive = FALSE
' if you have a ball saver light then turn it off at this point
End Sub
' *********************************************************************
' ** **
' ** Supporting Score Functions **
' ** **
' *********************************************************************
' Add points to the score and update the score board
'
Sub AddScore(points)
If (fpTilted = FALSE) Then
' add the points to the current players score variable
nvScore(CurrentPlayer) = nvScore(CurrentPlayer) + points
' update the score displays
Player1Reel.State = BulbOff
Player2Reel.State = BulbOff
Player3Reel.State = BulbOff
Player4Reel.State = BulbOff
' add the points to the correct display and light the current players display
Select Case (CurrentPlayer)
Case 1: Player1Reel.AddValue(points)
Player1Reel.State = BulbOn
Case 2: Player2Reel.AddValue(points)
Player2Reel.State = BulbOn
Case 3: Player3Reel.AddValue(points)
Player3Reel.State = BulbOn
Case 4: Player4Reel.AddValue(points)
Player4Reel.State = BulbOn
End Select
End if
' you may wish to check to see if the player has gotten a replay
End Sub
' Add some points to the current Jackpot.
'
Sub AddJackpot(points)
' Jackpots only generally increment in multiball mode and not tilted
' but this dosn't have to tbe the case
If (fpTilted = False) Then
If (bMultiBallMode = TRUE) Then
nvJackpot = nvJackpot + points
' you may wish to limit the jackpot to a upper limit, ie..
' If (nvJackpot >= 6000) Then
' nvJackpot = 6000
' End if
End if
End if
End Sub
' Will increment the Bonus Multiplier to the next level
'
Sub IncrementBonusMultiplier()
Dim NewBonusLevel
' if not at the maximum bonus level
if (BonusMultiplier(CurrentPlayer) < constMaxMultiplier) then
' then set it the next next one and set the lights
NewBonusLevel = BonusMultiplier(CurrentPlayer) + 1
SetBonusMultiplier(NewBonusLevel)
End if
End Sub
' Set the Bonus Multiplier to the specified level and set any lights accordingly
'
Sub SetBonusMultiplier(Level)
' Set the multiplier to the specified level
BonusMultiplier(CurrentPlayer) = Level
' If the multiplier is 1 then turn off all the bonus lights
If (BonusMultiplier(CurrentPlayer) = 1) Then
' insert your own code here
Else
' there is a bonus, turn on all the lights upto the current level
If (BonusMultiplier(CurrentPlayer) >= 2) Then
' insert your own code here
End If
' etc..
End If
End Sub
' *********************************************************************
' ** **
' ** Table Object Script Events **
' ** **
' *********************************************************************
' The Left Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
'
Sub LeftSlingshotRubber_Hit()
' add some points
AddScore(5)
' flash the lights around the slingshot
LeftSlingshotBulb1.FlashForMs 100, 50, BulbOff
LeftSlingshotBulb2.FlashForMs 100, 50, BulbOff
End Sub
' The Right Slingshot has been Hit, Add Some Points and Flash the Slingshot Lights
'
Sub RightSlingshotRubber_Hit()
' add some points
AddScore(5)
' flash the lights around the slingshot
RightSlingshotBulb1.FlashForMs 100, 50, BulbOff
RightSlingshotBulb2.FlashForMs 100, 50, BulbOff
End Sub
' The Left InLane trigger has been Hit
'
Sub LeftInLaneTrigger_Hit()
' add some points
AddScore(1)
' remember last trigger hit by the ball
set LastSwitchHit = LeftInLaneTrigger
End Sub
' The Right InLane trigger has been Hit
'
Sub RightInLaneTrigger_Hit()
' add some points
AddScore(1)
' remember last trigger hit by the ball
set LastSwitchHit = RightInLaneTrigger
End Sub
' The Left OutLane trigger has been Hit
'
Sub LeftOutLaneTrigger_Hit()
' add some points
AddScore(10)
' remember last trigger hit by the ball
set LastSwitchHit = LeftOutLaneTrigger
End Sub
' The Right OutLane trigger has been Hit
'
Sub RightOutLaneTrigger_Hit()
' add some points
AddScore(10)
' remember last trigger hit by the ball
set LastSwitchHit = RightOutLaneTrigger
End Sub
Hors ligne
Pages : 1