예제 #1
0
 def deactivate(self):
     """Deactivate the CatchPowerUp from preventing the paddle from
     catching the ball.
     """
     self.game.paddle.ball_collide_callbacks.remove(self._catch)
     receiver.unregister_handler(self._release_ball)
     for ball in self.game.balls:
         ball.release()  # Release a currently caught ball.
예제 #2
0
    def test_unregister_handler(self):
        def handler():
            pass

        receiver._handlers['test_event'].append(handler)

        receiver.unregister_handler(handler)

        self.assertNotIn(handler, receiver._handlers['test_event'])
예제 #3
0
    def test_unregister_handler(self):
        def handler():
            pass

        receiver._handlers['test_event'].append(handler)

        receiver.unregister_handler(handler)

        self.assertNotIn(handler, receiver._handlers['test_event'])
예제 #4
0
 def __init__(self, game):
     super().__init__(game)
     game.ball.anchor(game.paddle.rect.midtop)
     game.ball.visible = False
     game.over = True
     receiver.unregister_handler(self.game.handler_move_left,
                                 self.game.handler_move_right,
                                 self.game.handler_stop)
     #---- kong ----
     receiver.unregister_handler(self.game.handler_quit)
예제 #5
0
    def test_unregister_multiple_handlers(self):
        def handler1():
            pass

        def handler2():
            pass

        receiver._handlers['test_event'] += handler1, handler2

        receiver.unregister_handler(handler1, handler2)

        self.assertNotIn(handler1, receiver._handlers['test_event'])
        self.assertNotIn(handler2, receiver._handlers['test_event'])
예제 #6
0
    def test_unregister_multiple_handlers(self):
        def handler1():
            pass

        def handler2():
            pass

        receiver._handlers['test_event'] += handler1, handler2

        receiver.unregister_handler(handler1, handler2)

        self.assertNotIn(handler1, receiver._handlers['test_event'])
        self.assertNotIn(handler2, receiver._handlers['test_event'])
예제 #7
0
파일: paddle.py 프로젝트: wkeeling/arkanoid
    def exit(self, on_exit):
        """Trigger the animation to return to normal state.

        Args:
            on_exit:
                No-args callable invoked when the laser has converted back
                to a normal paddle.
        """
        self._to_laser = False
        self._from_laser = True
        self._on_exit = on_exit
        self._laser_anim = iter(reversed(self._image_sequence))
        # Stop monitoring for spacebar presses now that we're leaving the
        # state.
        receiver.unregister_handler(self._fire)
예제 #8
0
파일: game.py 프로젝트: wkeeling/arkanoid
    def __init__(self, game):
        super().__init__(game)

        # Bring the ball back onto the screen, but hide it.
        # This prevents the offscreen callback from being called again.
        game.ball.anchor(game.paddle.rect.midtop)
        game.ball.visible = False

        # Indicate that the game is over.
        game.over = True

        # Unregister the event handlers.
        receiver.unregister_handler(self.game.handler_move_left,
                                    self.game.handler_move_right,
                                    self.game.handler_stop)
예제 #9
0
파일: paddle.py 프로젝트: sanyer/arkanoid
    def exit(self, on_exit):
        """Trigger the animation to return to normal state.

        Args:
            on_exit:
                No-args callable invoked when the laser has converted back
                to a normal paddle.
        """
        self._to_laser = False
        self._from_laser = True
        self._on_exit = on_exit
        self._laser_anim = iter(reversed(self._image_sequence))
        # Stop monitoring for spacebar presses now that we're leaving the
        # state.
        receiver.unregister_handler(self._fire)
예제 #10
0
    def __init__(self, game):
        super().__init__(game)

        # Bring the ball back onto the screen, but hide it.
        # This prevents the offscreen callback from being called again.
        game.ball.anchor(game.paddle.rect.midtop)
        game.ball.visible = False

        # Indicate that the game is over.
        game.over = True

        # Unregister the event handlers.
        receiver.unregister_handler(self.game.handler_move_left,
                                    self.game.handler_move_right,
                                    self.game.handler_stop)
예제 #11
0
파일: game.py 프로젝트: wkeeling/arkanoid
 def hide(self):
     """Hide the start screen and unregister event listeners."""
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
예제 #12
0
 def hide(self):
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
예제 #13
0
 def test_unregister_handler_raises_exception_when_no_handler(self):
     with self.assertRaises(AssertionError):
         receiver.unregister_handler()
예제 #14
0
 def exit(self, on_exit):
     self._to_laser = False
     self._from_laser = True
     self._on_exit = on_exit
     self._laser_anim = iter(reversed(self._image_sequence))
     receiver.unregister_handler(self._fire)
예제 #15
0
 def test_unregister_handler_raises_exception_when_no_handler(self):
     with self.assertRaises(AssertionError):
         receiver.unregister_handler()
예제 #16
0
 def hide(self):
     """Hide the start screen and unregister event listeners."""
     receiver.unregister_handler(self._on_keyup)
     self._registered = False
     self._init = False
예제 #17
0
 def deactivate(self):
     self.game.paddle.ball_collide_callbacks.remove(self._catch)
     receiver.unregister_handler(self._release_ball)
     for ball in self.game.balls:
         ball.release()