def __init__(self, eventLoop, size=None): self.eventLoop = eventLoop Event.attach(self, 'onFrame', 'onResize', 'onSetupFrame', 'onDrawFrame', 'onFinishFrame', 'onRenderChild_before', 'onRenderChild_after') # This makes it easier for RegionMixin to override the parent and rootView # while still having it set correctly for show() below. if not hasattr(self, 'parent'): self.parent = None self.rootView = self self.rect = None self.rectExp = None self.size = None if size is not None: self.setRect((0,0) + size) self.renderSequence = [ self.onRenderChild_before, self.onSetupFrame, self.onDrawFrame, self.onRenderChild_after, self.onFinishFrame, ] self.visible = False self.show()
def __init__(self): self.id = None self.status = [] self.identity = Identity() self.motion = Motion() self.score = Score() Event.attach(self, 'onChangeStatus', 'onMove')
def __init__(self): self.players = {} # Indexed by player Id self.flags = {} # Indexed by flag number self.teams = {} # Indexed by color, represented as a string self.world = World.Empty() self.time = Animated.Timekeeper() Event.attach(self, 'onChangePlayerList', 'onAddPlayer', 'onRemovePlayer', 'onAddFlag')
def init(self): Network.Endpoint.init(self) self.connected = 0 self.protocolVersion = BZFlag.protocolVersion self.options.update({ 'server': None, }) Event.attach(self, 'onConnect', 'onDisconnect', 'onConnectUDP')
def init(self): BaseClient.init(self) self.game = Game.Game() self.worldCache = None Event.attach(self, 'onStartWorldDownload', 'onNegotiateFlags') # Immediately after connecting, ask for a world hash so # we can check our cache for a copy of that world self.onConnect.observe(self.negotiateFlags)
def init(self): Network.Endpoint.init(self) self.protocolVersion = BZFlag.protocolVersion self.clientsByID = {} self.clientsBySocket = {} self.clientsByIP = {} self.nextClientID = 0 self.clientIDIncrement = 1 self.options.update({ 'interface': '', }) Event.attach(self, 'onListen', 'onConnect', 'onDisconnect')
def __init__(self, eventLoop, size=(800,600), targetFrameRate=None, resizable=True): pygame.display.init() pygame.key.set_repeat(500, 30) self.display = pygame.display self.resizable = resizable Viewport.__init__(self, eventLoop, size) # Add event handlers for all the pygame events we can find for i in xrange(100): name = pygame.event.event_name(i) if name != "Unknown": Event.attach(self, 'on' + name) self.init() self.frameTimer = None self.setTargetFrameRate(targetFrameRate)
def init(self): StatefulClient.init(self) self.options.update({ 'callSign': None, 'team': 'rogue', 'email': 'PyBZFlag', 'playerType': 'tank', }) # We won't have a player instance until we get a MsgAddPlayer # back for ourselves and StatefulClient adds it to the Game. self.inGame = 0 self.player = None Event.attach(self, 'onEnterGame') # Set up an observer for the game's onAddPlayer that will set # up our player member whenever that MsgAddPlayer is received. self.game.onAddPlayer.observe(self.addPlayer) self.game.world.onLoad.observe(self.enterGame)
def init(self): BaseServer.init(self) self.game = Game.Game() self.binaryWorld = None self.publicityTimer = None self.worldBlockSize = 1000 self.options.update({ 'world': None, 'welcomeMessage': BZFlag.serverWelcomeMessage, 'publicTitle': None, 'publicityInterval': 30 * 60, 'gameStyle': [], 'shots': 1, }) Event.attach(self, 'onAttemptEnter', 'onEnter', 'onFinishEnter', 'onWelcome') self.onListen.observe(self.publicize)
def __init__(self, **options): """Any options passed to the constructor will be sent to setOptions""" self.tcp = None self.udp = None self.options = {} from BZFlag import Event Event.attach(self, 'onAnyMessage', 'onUnhandledMessage') # Add events for all messages, with onUnhandledMessage as an # unhandled event handler. for message in Common.getMessageDict(self.incoming).values(): eventName = self.getMsgHandlerName(message) if hasattr(self, eventName): event = Event.Event(getattr(self, eventName)) else: event = Event.Event() event.unhandledCallback = self.onUnhandledMessage setattr(self, eventName, event) self.init() self.setOptions(**options)
def __init__(self): Event.attach(self, 'onLoad', 'onAddObject', 'onRemoveObject', 'onChangeObject') self.erase()
def __init__(self, number=None): self.number = number self.status = None self.owner = None self.motion = FlagMotion() Event.attach(self, 'onGrab', 'onDrop', 'onUpdate')