Esempio n. 1
0
 def update(self):
     caption, ready = None, None
     if self._update_count > 100:
         caption = ptext.draw(self.game.round.name,
                              (235, self.game.paddle.rect.center[1] - 150),
                              fontname=MAIN_FONT,
                              fontsize=24,
                              color=(255, 255, 255))
     if self._update_count > 200:
         ready = ptext.draw('ready', (250, caption[1][1] + 50),
                            fontname=MAIN_FONT,
                            fontsize=24,
                            color=(255, 255, 255))
         self.game.ball.anchor(self.game.paddle,
                               (self.game.paddle.rect.width // 2,
                                -self.game.ball.rect.height))
         if not self._paddle_reset:
             self.game.paddle.reset()
             self._paddle_reset = True
         self.game.paddle.visible = True
         self.game.ball.visible = True
     if self._update_count == 201:
         self.game.paddle.transition(MaterializeState(self.game.paddle))
         for brick in self.game.round.bricks:
             brick.animate()
     if self._update_count > 310:
         self._screen.blit(self.game.round.background, caption[1])
         self._screen.blit(self.game.round.background, ready[1])
     if self._update_count > 340:
         self.game.ball.release(BALL_START_ANGLE_RAD)
         self.game.state = RoundPlayState(self.game)
     self._update_count += 1
     if not self.game.paddle.visible:
         self.game.paddle.stop()
Esempio n. 2
0
 def _display_score_titles(self):
     ptext.draw('1UP', (self._screen.get_width() - 70, 10),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(230, 0, 0))
     ptext.draw('HIGH SCORE', (self._screen.get_width() - 205, 75),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(230, 0, 0))
Esempio n. 3
0
 def _display_score_titles(self):
     ptext.draw('1UP', (self._screen.get_width() - 70, 10),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(230, 0, 0))
     ptext.draw('HIGH SCORE', (self._screen.get_width() - 205, 75),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(230, 0, 0))
Esempio n. 4
0
 def _display_score(self, value, y):
     score_surf = pygame.Surface((150, 20)).convert_alpha()
     ptext.draw(str(value),
                topright=(150, 0),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(255, 255, 255),
                surf=score_surf)
     position = self._screen.get_width() - 160, y
     self._screen.blit(self._background, position, score_surf.get_rect())
     self._screen.blit(score_surf, position)
Esempio n. 5
0
 def _display_score(self, value, y):
     score_surf = pygame.Surface((150, 20)).convert_alpha()
     ptext.draw(str(value),
                topright=(150, 0),
                fontname=MAIN_FONT,
                fontsize=24,
                color=(255, 255, 255),
                surf=score_surf)
     position = self._screen.get_width() - 160, y
     self._screen.blit(self._background, position, score_surf.get_rect())
     self._screen.blit(score_surf, position)
Esempio n. 6
0
    def update(self):
        """Handle the sequence of events that happen at the beginning of a
        round just before gameplay starts.
        """
        caption, ready = None, None

        if self._update_count > 100:
            # Display the caption after a short delay.
            caption = ptext.draw(self.game.round.name,
                                 (235, self.game.paddle.rect.center[1] - 150),
                                 fontname=MAIN_FONT,
                                 fontsize=24,
                                 color=(255, 255, 255))
        if self._update_count > 200:
            # Display the "Ready" message.
            ready = ptext.draw('ready',
                               (250, caption[1][1] + 50),
                               fontname=MAIN_FONT,
                               fontsize=24,
                               color=(255, 255, 255))
            # Anchor the ball to the paddle.
            self.game.ball.anchor(self.game.paddle,
                                  (self.game.paddle.rect.width // 2,
                                   -self.game.ball.rect.height))
            # Display the sprites.
            if not self._paddle_reset:
                self.game.paddle.reset()
                self._paddle_reset = True
            self.game.paddle.visible = True
            self.game.ball.visible = True
        if self._update_count == 201:
            # Animate the paddle materializing onto the screen.
            self.game.paddle.transition(MaterializeState(self.game.paddle))
            # Animate the bricks
            for brick in self.game.round.bricks:
                brick.animate()
        if self._update_count > 310:
            # Erase the text.
            self._screen.blit(self.game.round.background, caption[1])
            self._screen.blit(self.game.round.background, ready[1])
        if self._update_count > 340:
            # Release the anchor.
            self.game.ball.release(BALL_START_ANGLE_RAD)
            # Normal gameplay begins.
            self.game.state = RoundPlayState(self.game)

        self._update_count += 1

        # Don't let the paddle move when it's not displayed.
        if not self.game.paddle.visible:
            self.game.paddle.stop()
Esempio n. 7
0
    def update(self):
        """Handle the sequence of events that happen at the beginning of a
        round just before gameplay starts.
        """
        caption, ready = None, None

        if self._update_count > 100:
            # Display the caption after a short delay.
            caption = ptext.draw(self.game.round.name,
                                 (235, self.game.paddle.rect.center[1] - 150),
                                 fontname=MAIN_FONT,
                                 fontsize=24,
                                 color=(255, 255, 255))
        if self._update_count > 200:
            # Display the "Ready" message.
            ready = ptext.draw('ready',
                               (250, caption[1][1] + 50),
                               fontname=MAIN_FONT,
                               fontsize=24,
                               color=(255, 255, 255))
            # Anchor the ball to the paddle.
            self.game.ball.anchor(self.game.paddle,
                                  (self.game.paddle.rect.width // 2,
                                   -self.game.ball.rect.height))
            # Display the sprites.
            if not self._paddle_reset:
                self.game.paddle.reset()
                self._paddle_reset = True
            self.game.paddle.visible = True
            self.game.ball.visible = True
        if self._update_count == 201:
            # Animate the paddle materializing onto the screen.
            self.game.paddle.transition(MaterializeState(self.game.paddle))
            # Animate the bricks
            for brick in self.game.round.bricks:
                brick.animate()
        if self._update_count > 310:
            # Erase the text.
            self._screen.blit(self.game.round.background, caption[1])
            self._screen.blit(self.game.round.background, ready[1])
        if self._update_count > 340:
            # Release the anchor.
            self.game.ball.release(BALL_START_ANGLE_RAD)
            # Normal gameplay begins.
            self.game.state = RoundPlayState(self.game)

        self._update_count += 1

        # Don't let the paddle move when it's not displayed.
        if not self.game.paddle.visible:
            self.game.paddle.stop()
Esempio n. 8
0
    def show(self):
        if not self._registered:
            receiver.register_handler(pygame.KEYUP, self._on_keyup)
            self._registered = True
        if not self._init:
            self._init = True
            self._screen.blit(pygame.Surface((600, 650)), (0, TOP_OFFSET))
        ptext.draw('POWERUPS', (210, 200),
                   fontname=ALT_FONT,
                   fontsize=32,
                   color=(255, 255, 255))
        left, top = 30, 270
        for anim, name, desc in self._powerups:
            if self._display_count % 4 == 0:
                image, _ = next(anim)
                self._screen.blit(image, (left, top))
                ptext.draw(name.upper(),
                           (left + image.get_width() + 20, top - 3),
                           fontname=ALT_FONT,
                           fontsize=20,
                           color=(255, 255, 255))
                ptext.draw(desc.upper(), (left, top + 25),
                           fontname=ALT_FONT,
                           fontsize=14,
                           color=(255, 255, 255))
            left += 180
            if left > 400:
                left = 30
                top += 100

        if self._display_count % 15 == 0:
            self._text_color_1 = next(self._text_colors_1)
            self._text_color_2 = next(self._text_colors_2)
        ptext.draw('SPACEBAR TO START', (50, 500),
                   fontname=ALT_FONT,
                   fontsize=48,
                   color=self._text_color_1,
                   shadow=(1.0, 1.0),
                   scolor="grey")
        ptext.draw('OR ENTER LEVEL', (160, 575),
                   fontname=ALT_FONT,
                   fontsize=32,
                   color=self._text_color_2)
        self._user_input_pos = ptext.draw(self._user_input, (280, 625),
                                          fontname=ALT_FONT,
                                          fontsize=40,
                                          color=(255, 255, 255))[1]
        ptext.draw(
            'Based on original Arkanoid game\nby Taito Corporation 1986',
            (100, 700),
            align='center',
            fontname=ALT_FONT,
            fontsize=24,
            color=(128, 128, 128))
        self._display_count += 1
Esempio n. 9
0
    def show(self):
        """Display the start screen and register event listeners for
        capturing keyboard input.

        This method is designed to be called repeatedly by the main game loop.
        """
        if not self._registered:
            receiver.register_handler(pygame.KEYUP, self._on_keyup)
            self._registered = True

        if not self._init:
            self._init = True
            self._screen.blit(pygame.Surface((600, 650)), (0, TOP_OFFSET))

        ptext.draw('POWERUPS', (210, 200),
                   fontname=ALT_FONT,
                   fontsize=32,
                   color=(255, 255, 255))

        left, top = 30, 270

        for anim, name, desc in self._powerups:
            if self._display_count % 4 == 0:
                image, _ = next(anim)
                self._screen.blit(image, (left, top))
                ptext.draw(name.upper(), (left + image.get_width() + 20,
                                          top-3),
                           fontname=ALT_FONT,
                           fontsize=20,
                           color=(255, 255, 255))
                ptext.draw(desc.upper(), (left, top + 25),
                           fontname=ALT_FONT,
                           fontsize=14,
                           color=(255, 255, 255))
            left += 180

            if left > 400:
                left = 30
                top += 100

        if self._display_count % 15 == 0:
            self._text_color_1 = next(self._text_colors_1)
            self._text_color_2 = next(self._text_colors_2)

        ptext.draw('SPACEBAR TO START', (50, 500),
                   fontname=ALT_FONT,
                   fontsize=48,
                   color=self._text_color_1,
                   shadow=(1.0, 1.0),
                   scolor="grey")

        ptext.draw('OR ENTER LEVEL', (160, 575),
                   fontname=ALT_FONT,
                   fontsize=32,
                   color=self._text_color_2)

        self._user_input_pos = ptext.draw(self._user_input, (280, 625),
                                          fontname=ALT_FONT,
                                          fontsize=40,
                                          color=(255, 255, 255))[1]

        ptext.draw('Based on original Arkanoid game\n'
                   'by Taito Corporation 1986',
                   (100, 700),
                   align='center',
                   fontname=ALT_FONT,
                   fontsize=24,
                   color=(128, 128, 128))

        self._display_count += 1