Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from toontown.minigame.DistributedMinigame import *
- from direct.fsm import ClassicFSM, State
- # PS: All the toons are kept on a list
- # self.avIdList
- class DistributedCoolGame(DistributedMinigame):
- def __init__(self, cr):
- DistributedMinigame.__init__(self, cr)
- # This is our game FSM, it defines all the states
- # the minigame is going to have, eg. toon dies, toon wins, etc.
- self.gameFSM = ClassicFSM.ClassicFSM(
- 'DistributedCoolGame', [
- ]
- )
- self.addChildGameFSM(self.gameFSM)
- # Here goes all your initial variables
- self.myHappyness = 0
- def getTitle(self):
- # Title of our minigame
- return "Cool Minigame"
- def getInstructions(self):
- # Instructions
- return "Just do it right"
- def getMaxDuration(self):
- # Max duration of the minigame in seconds
- return 3 * 60
- def load(self):
- # This is where you load all your game resources, such as environment,
- # props, gui, and such.
- self.environment = loader.loadModel("environment.egg")
- self.prop = loader.loadModel("sphere.egg")
- def unload(self):
- # You should unload everything you added on load here
- self.environment.removeNode()
- self.prop.removeNode()
- def onstage(self):
- # That means the toons are on the instructions screen
- # and the game should start rendering now, also intro movies.
- # (You can start playing a music from here)
- DistributedMinigame.onstage(self) # Keep this.
- self.environment.reparentTo(render)
- self.prop.reparentTo(render)
- def offstage(self)
- # The game is preparing to unload, set everything
- # invisible again
- self.environment.reparentTo(hidden)
- self.prop.reparentTo(hidden)
- DistributedMinigame.offstage(self) # keep this.
- def setGameReady(self):
- # If you want to do something right when the game is ready
- # to go, do it here
- if DistributedMinigame.setGameReady(self):
- return # avoid duplicates
- self.prop.setPos(0, 0, 5)
- def setGameStart(self, ts):
- # The game has started, do all the gameplay
- # stuff here
- DistributedMinigame.setGameStart(self, ts) # keep this
- base.localAvatar.b_setAnimState("Swim")
- # All the game should use States from now on,
- # you can also add timeout handlers by using ToontownTimer
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement