def setup(self): ''' This method is called by the Gameloop in order to initialise the Display. It provides the implementation of the state change listener such that the Display can react on specific state transitions. ''' Gamestate.get().add_gamestate_change_listener(self.mGamestateChangeListener(self))
def setup(self): ''' This method is called by the Gameloop in order to initialise the Display. It provides the implementation of the state change listener such that the Display can react on specific state transitions. ''' setup_window_on_top_signal() set_window_on_top() Gamestate.get().add_gamestate_change_listener( self.mGamestateChangeListener(self))
def __init__(self, display, background): super(FlappyFlyingHUD, self).__init__(display) self.background = background # the score needs to be cleared and drawn everytime it updates self.score_text_sprite = pygame.sprite.Sprite() self.score_text_group = pygame.sprite.Group(self.score_text_sprite) self.update_score(0) # implement the onScoreChanged interface of FlappyFlyingState Gamestate.get().current_state.add_score_changed_listener(self.mScoreChangedListener(self))
def __init__(self, display, background): super(FlappyFlyingHUD, self).__init__(display) self.background = background # the score needs to be cleared and drawn everytime it updates self.score_text_sprite = pygame.sprite.Sprite() self.score_text_group = pygame.sprite.Group(self.score_text_sprite) self.update_score(0) # implement the onScoreChanged interface of FlappyFlyingState Gamestate.get().current_state.add_score_changed_listener( self.mScoreChangedListener(self))
def setup(self): ''' This method is called by the Gameloop in order to initialise the Sound class. It provides the implementation of the state change listener such that it can play various sounds specific to state transitions. ''' # check that the platform supports sound playback # if it doesn't, then it won't implement any listeners initialised = pygame.mixer.get_init() if initialised: debugger("Sound: __init__: Mixer is available and is initialised:" \ " frequency = {}, format = {}, channels = {}" .format(initialised[0], initialised[1], initialised[2])) Gamestate.get().add_gamestate_change_listener(self.mGamestateChangeListener(self)) else: debugger("Sound: __init__: Mixer is not available! Game will not have sounds!")
def on_flappy_flying(self): debugger("Sound: mGamestateChangeListener: on_flappy_flying: Setting ScoreChangedListener and FlappyFlapListener") Gamestate.get().current_state.flappy.add_flappy_flap_listener(self.parent.mFlappyFlapListener(self.parent)) Gamestate.get().current_state.add_score_changed_listener(self.parent.mScoreChangedListener(self.parent))