예제 #1
0
    def __init__(self, game_env):
        Text.__init__(
            self, game_env,
            size=38)  # initilizing parent class with default text color as red
        self.__game_env = game_env
        self.__gameover = Text(self.__game_env, "GAME OVER", 60)

        self.__replaytext_surf = self.font.render(
            "Replay ", 1, self.color)  # creating surface with the Replay text

        self.__y_selected_surf = self.font.render(
            "Yes", 1, self.__game_env.static.text_selection_color
        )  # creating surface with Yes text when highlighted
        self.__n_surf = self.font.render(
            "/No", 1, self.color)  # creating surface with No text
        self.__y_surf = self.font.render(
            "Yes/", 1, self.color)  # creating surface with Yes text
        self.__n_selected_surf = self.font.render(
            "No", 1, self.__game_env.static.text_selection_color
        )  # creating surface with No text when highlighted

        self.__replaytext_pos_x = self.__gameover.surf.get_width() / 2 - (
            self.__replaytext_surf.get_width() +
            self.__y_selected_surf.get_width() + self.__n_surf.get_width()) / 2

        self.__highlight_yes(
        )  # calling method to highlight Yes (the default choice)
예제 #2
0
    def __init__(self, game_env): 
        Text.__init__(self, game_env, size=20)
        self.__game_env = game_env
        seperator = self.font.render(' ', 1, self.color)
        header = self.font.render('=== HELP ===', 1, self.color)
        footer = self.font.render('=== GOOD LUCK ===', 1, self.color)
        all_surfaces = []
        all_surfaces.append(seperator)
        all_surfaces.append(self.font.render('Your objective should you choose to accept is to navigate your jet without getting hit by', 1, self.color))
        all_surfaces.append(self.font.render('the incoming missiles. For self-defence you can shoot down the enemy missiles. You are', 1, self.color))
        all_surfaces.append(self.font.render('armed with 100 special missiles. Level-up awards you another 50 special missiles and a', 1, self.color))
        all_surfaces.append(self.font.render('power-up star which will instantly deactivate all the enemy missiles.', 1, self.color))
        all_surfaces.append(self.font.render('Your jet can carry maximum 999 special missiles.', 1, self.color))
        all_surfaces.append(seperator)
        all_surfaces.append(self.font.render('With keyboard input, you should use your keyboard arrow keys to navigate and spacebar', 1, self.color))
        all_surfaces.append(self.font.render('to shoot. With mouse as input, you should use your mouse to navigate your jet and', 1, self.color))
        all_surfaces.append(self.font.render('mouse click to shoot', 1, self.color))
        all_surfaces.append(self.font.render(' ', 1, self.color))
        all_surfaces.append(self.font.render('POINTS: Destroy Missle -> 10 pts. Power-up Star -> 100 pts. Level-up -> 10 pts.', 1, self.color))
        all_surfaces.append(seperator)

        self.surf = Surface((all_surfaces[1].get_width(), all_surfaces[0].get_height() * (len(all_surfaces) + 2)), self.__game_env.SRCALPHA)

        self.surf.blit(header, (self.surf.get_width()/2 - header.get_width()/2, 0))
        for index, temp_surf in enumerate(all_surfaces):
            self.surf.blit(temp_surf, (0, header.get_height() + index * temp_surf.get_height()))
        self.surf.blit(footer, (self.surf.get_width()/2 - footer.get_width()/2, self.surf.get_height() - footer.get_height()))

        self.rect = self.surf.get_rect(center=(self.__game_env.static.screen_width/2, self.__game_env.static.screen_height/2))
예제 #3
0
파일: name.py 프로젝트: ljnath/PyBluesky
 def __init__(self, game_env):
     Text.__init__(
         self, game_env,
         size=32)  # initilizing parent class with default text color as red
     self.__game_env = game_env
     self.__header = Text(self.__game_env, "=== ENTER YOUR NAME ===", 36)
     self.__footer = Text(self.__game_env,
                          "===============================", 36)
     self.__player_name = ''  # default player name
     self.render(self.__player_name)
예제 #4
0
    def __init__(self, game_env):
        Text.__init__(self, game_env, size=20)
        self.__game_env = game_env
        name_length = self.__game_env.static.name_length * 2
        leaders = LeaderBoardHandler().load()
        seperator = self.font.render(
            '===================================================================================================',
            1, self.color)
        header = self.font.render('=== HALL OF FAME ===', 1, self.color)
        all_surfaces = []
        all_surfaces.append(seperator)
        all_surfaces.append(
            self.font.render(
                '{} {} {} {} {} {}'.format('RANK'.ljust(5),
                                           'NAME'.ljust(name_length),
                                           'SCORE'.ljust(10), 'LEVEL'.ljust(5),
                                           'ACCURACY'.ljust(8),
                                           'TIME'.rjust(21)), 1, self.color))
        all_surfaces.append(seperator)
        try:
            if len(leaders) == 0:
                all_surfaces.append(
                    self.font.render(
                        'No records, make sure you have working internet connectivity',
                        1, self.color))

            for index, score in enumerate(leaders['scores']):
                all_surfaces.append(
                    self.font.render(
                        '{} {} {} {} {} {}'.format(
                            str(index + 1).ljust(5),
                            score['name'][:name_length].ljust(name_length),
                            str(score['score']).ljust(10),
                            str(score['level']).ljust(5),
                            str(score['accuracy'] + '%').ljust(8),
                            str(time.ctime(int(score['epoch']))).rjust(25)), 1,
                        self.color))
        except:
            pass
        all_surfaces.append(seperator)

        self.surf = Surface(
            (all_surfaces[2].get_width(), all_surfaces[0].get_height() *
             (len(all_surfaces) + 1)), self.__game_env.SRCALPHA)

        self.surf.blit(header,
                       (self.surf.get_width() / 2 - header.get_width() / 2, 0))
        for index, temp_surf in enumerate(all_surfaces):
            self.surf.blit(
                temp_surf,
                (0, header.get_height() + index * temp_surf.get_height()))

        self.rect = self.surf.get_rect(
            center=(self.__game_env.static.screen_width / 2,
                    self.__game_env.static.screen_height / 2))
예제 #5
0
    def __init__(self, game_env):
        Text.__init__(
            self, game_env,
            size=36)  # initilizing parent class with default text color as red
        self.__game_env = game_env
        self.__jet = Jet(game_env)  # creating a of jet
        self.__prefix_surf = self.font.render(
            "What's your input {}?".format(
                self.__game_env.dynamic.player_name), 1,
            self.color)  # creating surface with the prefix text
        self.__mouse = self.font.render(
            ' Mouse', 1, self.color)  # creating surface with mouse text
        self.__keybrd = self.font.render(
            ' Keyboard', 1, self.color)  # creating surface with mouse text

        keybrd_surf = self.font.render(
            ' Keyboard', 1, game_env.static.text_selection_color
        )  # creating surface with Keyboard text when highlighted
        self.__keybrd_selected = Surface(
            (self.__jet.surf.get_width() + keybrd_surf.get_width(),
             keybrd_surf.get_height()), game_env.SRCALPHA
        )  # creating surface for jet and highlighted keyboard text
        self.__keybrd_selected.blit(self.__jet.surf, (0, 0))  # drawing the jet
        self.__keybrd_selected.blit(
            keybrd_surf,
            (self.__jet.surf.get_width(),
             0))  # drawing the highligted keyboard text after the jet image

        mouse_surf = self.font.render(
            ' Mouse', 1, game_env.static.text_selection_color
        )  # creating surface with mouse text when highlighted
        self.__mouse_selected = Surface(
            (self.__jet.surf.get_width() + mouse_surf.get_width(),
             mouse_surf.get_height()), game_env.SRCALPHA
        )  # creating surface for jet and highlighted mouse text
        self.__mouse_selected.blit(self.__jet.surf, (0, 0))  # drawing the jet
        self.__mouse_selected.blit(
            mouse_surf,
            (self.__jet.surf.get_width(),
             0))  # drawing the highligted mouse text after the jet image
        self.__left_padding = self.__prefix_surf.get_width(
        ) / 2 - self.__keybrd_selected.get_width() / 2
        self.__highlight_keyboard(
        )  # calling method to highlight keyboard (the default choice)
예제 #6
0
    def __init__(self, game_env):
        Text.__init__(self, game_env, size=38)
        self.__game_env = game_env
        self.__title = Text(self.__game_env, "Do you want to quit?", 48)

        self.__y_selected_surf = self.font.render(
            "Yes", 1, self.__game_env.static.text_selection_color
        )  # creating surface with Yes text when highlighted
        self.__n_surf = self.font.render(
            "/No", 1, self.color)  # creating surface with No text
        self.__y_surf = self.font.render(
            "Yes/", 1, self.color)  # creating surface with Yes text
        self.__n_selected_surf = self.font.render(
            "No", 1, self.__game_env.static.text_selection_color
        )  # creating surface with No text when highlighted

        self.__choices = self.__title.surf.get_width() / 2 - (
            self.__y_selected_surf.get_width() + self.__n_surf.get_width()) / 2
        self.__highlight_no()
예제 #7
0
 def __init__(self, game_env):
     Text.__init__(self, game_env, text="LEVEL 00 TIME 0 AMMO 0 SCORE 0", size=28, color=(103,103,103))                             # initializing parent class with defautl text and color
     self.__game_env = game_env
     self.rect = self.surf.get_rect(topright=(self.__game_env.static.screen_width-self.surf.get_width()/2 + 30, 2))       # creating rectangle from text surface