예제 #1
0
	def __init__(self, window_surface, main_clock, player_one, player_two, number_of_rounds, score, winner):
		# Call the superconstructor.
		scene.Scene.__init__(self, window_surface, main_clock)

		# Tint the window surface and set it as the background surface.
		self.background_surface = window_surface.copy()
		useful.tint_surface(self.background_surface)

		# The next screen to be started when the gameloop ends.
		self.next_screen = screens.mainmenu.MainMenu

		# Keep track of the players and the score for displaying.
		self.player_one = player_one
		self.player_two = player_two
		self.score = score

		# Keep track of the number of rounds for rematch purposes.
		self.number_of_rounds = number_of_rounds

		# Store the winner
		self.winner = winner

		# Configure the GUI.
		item_side_padding = textitem.TextItem.font_size

		# This sets up the winner text, coloring it and everything.
		self.setup_winner_text()

		quit_button = textitem.TextItem("Quit")
		self.quit_menu = listmenu.ListMenu(item_side_padding + (quit_button.get_width() / 2), settings.SCREEN_HEIGHT - item_side_padding - quit_button.get_height())
		self.quit_menu.add(quit_button, self.quit)
		self.quit_menu.items[0].selected = True
		self.menu_list.append(self.quit_menu)
		
		rematch_button = textitem.TextItem("Rematch")
		self.rematch_menu = listmenu.ListMenu(settings.SCREEN_WIDTH - item_side_padding - (rematch_button.get_width() / 2), settings.SCREEN_HEIGHT - item_side_padding - rematch_button.get_height())
		self.rematch_menu.add(rematch_button, self.rematch)
		self.menu_list.append(self.rematch_menu)

		# Register all menus with each other.
		for a_menu in self.menu_list:
			a_menu.register_other_menus(self.menu_list)

		# Setup the menu transition.
		for letter_item in self.winning_player_text:
			self.transition.setup_single_item_transition(letter_item, True, True, True, True)
		self.transition.setup_transition(self.quit_menu, True, False, False, True)
		self.transition.setup_transition(self.rematch_menu, False, True, False, True)

		self.firework_spawn_time = 300
		self.time_passed = 0

		# Setup and play music.
		self.setup_music()

		self.gameloop()
예제 #2
0
	def setup_toast_menu(self):
		# Creates and adds the items to the toast menu.
		self.toast_menu = listmenu.ListMenu()
		self.toast_menu.add(textitem.TextItem("Ok"), self.resume)
		self.toast_menu.x = settings.SCREEN_WIDTH / 2
		self.toast_menu.y = self.message[len(self.message) - 1].y + self.message[0].get_height() + self.toast_menu.get_height()
		self.toast_menu.cleanup()
		self.toast_menu.items[0].selected = True
		self.menu_list.append(self.toast_menu)
예제 #3
0
 def setup_main_menu(self):
     self.main_menu = listmenu.ListMenu(settings.SCREEN_WIDTH / 2.0,
                                        settings.SCREEN_HEIGHT / 2.0)
     self.main_menu.add(textitem.TextItem("Start"), self.start)
     self.main_menu.add(textitem.TextItem("Options"), self.options)
     self.main_menu.add(textitem.TextItem("Help"), self.help)
     self.main_menu.add(textitem.TextItem("Quit"), self.quit)
     self.main_menu.items[0].selected = True
     self.menu_list.append(self.main_menu)
예제 #4
0
 def setup_pause_menu(self):
     # Creates and adds the items to the pause menu.
     self.pause_menu = listmenu.ListMenu()
     self.pause_menu.add(textitem.TextItem("Resume"), self.resume)
     self.pause_menu.add(textitem.TextItem("Options"), self.options)
     self.pause_menu.add(textitem.TextItem("Quit"), self.maybe_quit)
     self.pause_menu.x = settings.SCREEN_WIDTH / 2
     self.pause_menu.y = (settings.SCREEN_HEIGHT -
                          self.pause_menu.get_height()) / 2.0
     self.pause_menu.cleanup()
     self.pause_menu.items[0].selected = True
     self.menu_list.append(self.pause_menu)
예제 #5
0
    def __init__(self, window_surface, main_clock, title_logo=None):
        # Call the superconstructor.
        scene.Scene.__init__(self, window_surface, main_clock)

        # The next screen to be started when the gameloop ends.
        self.next_screen = None

        # Setup all the menu buttons.
        self.setup_sound_menu()

        # The back button, displayed in the middle-bottom of the screen.
        back_button = textitem.TextItem("Back")
        self.back_menu = listmenu.ListMenu()
        self.back_menu.x = settings.SCREEN_WIDTH / 2
        self.back_menu.y = settings.SCREEN_HEIGHT - (2 *
                                                     back_button.get_height())
        self.back_menu.add(back_button, self.back)
        self.back_menu.items[0].selected = True
        self.menu_list.append(self.back_menu)

        # Register all menus with each other.
        for a_menu in self.menu_list:
            a_menu.register_other_menus(self.menu_list)

        # Setup the logo and the variables needed to handle the animation of it.
        self.setup_logo(title_logo)
        self.logo_desired_position = (
            (settings.SCREEN_WIDTH - self.title_logo.get_width()) / 2,
            ((settings.SCREEN_HEIGHT - self.title_logo.get_height()) / 4))
        self.logo_transition = transition.Transition()
        self.logo_transition.speed = 2 * settings.GAME_FPS * settings.GAME_SCALE

        # Setup the menu transitions.
        self.transition.setup_single_item_transition(self.music_item, True,
                                                     False, False, False)
        self.transition.setup_single_item_transition(self.sound_item, True,
                                                     False, False, False)
        self.transition.setup_transition(self.music_volume_menu, False, True,
                                         False, False)
        self.transition.setup_transition(self.sound_volume_menu, False, True,
                                         False, False)
        self.transition.setup_transition(self.back_menu, True, True, False,
                                         False)

        # And finally, start the gameloop!
        self.gameloop()
예제 #6
0
    def setup_menu(self):
        # Setup the textitem.
        self.confirmation_text = textitem.TextItem("Are you sure?",
                                                   pygame.Color(255, 255, 255))
        self.confirmation_text.x = (settings.SCREEN_WIDTH -
                                    self.confirmation_text.get_width()) / 2

        # Setup the menu.
        self.confirmation_menu = listmenu.ListMenu()
        self.confirmation_menu.add(textitem.TextItem("Yes"), self.accept)
        self.confirmation_menu.add(textitem.TextItem("No"), self.refuse)
        self.confirmation_menu.x = settings.SCREEN_WIDTH / 2

        # Set the default action to be to refuse.
        self.confirmation_menu.items[1].selected = True
        self.menu_list.append(self.confirmation_menu)

        self.confirmation_text.y = (settings.SCREEN_HEIGHT - (
            (2 * self.confirmation_text.get_height()) +
            self.confirmation_menu.get_height())) / 2.0
        self.confirmation_menu.y = self.confirmation_text.y + (
            2 * self.confirmation_text.get_height())
        self.confirmation_menu.cleanup()
예제 #7
0
    def __init__(self, window_surface, main_clock):
        # Call the superconstructor.
        scene.Scene.__init__(self, window_surface, main_clock)

        # These are the connected and active joysticks.
        self.joysticks = [
            pygame.joystick.Joystick(x)
            for x in range(pygame.joystick.get_count())
        ]

        # The next screen to be started when the gameloop ends.
        self.next_screen = game.Game
        self.player_one_color = None
        self.player_two_color = None
        self.player_one_ai = None
        self.player_two_ai = None

        # Configure the GUI.
        distance_from_screen_edge = 9 * settings.GAME_SCALE

        # We create a gridmenu that allows the player to select the number of rounds they want to play.
        self.number_of_rounds_menu = gridmenu.GridMenu(5)

        # We set the default number of rounds to 1.
        temp_item = choiceitem.ChoiceItem(1)
        self.rounds(temp_item)

        # Add that item, and the other items to the menu.
        self.number_of_rounds_menu.add(temp_item, self.rounds)
        self.number_of_rounds_menu.add(choiceitem.ChoiceItem(3), self.rounds)
        self.number_of_rounds_menu.add(choiceitem.ChoiceItem(5), self.rounds)
        self.number_of_rounds_menu.add(choiceitem.ChoiceItem(7), self.rounds)
        self.number_of_rounds_menu.add(choiceitem.ChoiceItem(9), self.rounds)
        self.number_of_rounds_menu.x = (
            settings.SCREEN_WIDTH -
            self.number_of_rounds_menu.get_width()) / 2.0
        self.number_of_rounds_menu.y = distance_from_screen_edge * 3
        self.menu_list.append(self.number_of_rounds_menu)

        # The text displayed over the rounds menu.
        self.number_of_rounds_text = textitem.TextItem(
            "Rounds", pygame.Color(255, 255, 255))
        self.number_of_rounds_text.x = (
            settings.SCREEN_WIDTH -
            self.number_of_rounds_text.get_width()) / 2.0
        self.number_of_rounds_text.y = self.number_of_rounds_menu.y - (
            self.number_of_rounds_text.get_height() * 2)

        # The color menu for player one.
        self.color_menu_one = self.setup_color_menu(self.color_one)
        self.ai_menu_one = self.setup_ai_menu(self.ai_one)

        ai_menu_offset = self.color_menu_one.offset * 2

        self.color_menu_one.x = (
            settings.SCREEN_WIDTH - self.color_menu_one.get_width() -
            self.ai_menu_one.get_width() - ai_menu_offset) / 5.0
        self.color_menu_one.y = settings.SCREEN_HEIGHT / 2.0

        self.ai_menu_one.x = self.color_menu_one.x + self.color_menu_one.get_width(
        ) + ai_menu_offset
        self.ai_menu_one.y = self.color_menu_one.y

        self.menu_list.append(self.color_menu_one)
        self.menu_list.append(self.ai_menu_one)

        # The text above the color menu for player one.
        self.player_one_text = textitem.TextItem(settings.PLAYER_ONE_NAME,
                                                 pygame.Color(255, 255, 255))
        self.player_one_text.x = self.color_menu_one.x + ((
            (self.color_menu_one.get_width() + self.ai_menu_one.get_width() +
             ai_menu_offset) - self.player_one_text.get_width()) / 2.0)
        self.player_one_text.y = self.color_menu_one.y - (
            self.player_one_text.get_height() * 2)

        # The color menu for player two.
        self.color_menu_two = self.setup_color_menu(self.color_two)
        self.ai_menu_two = self.setup_ai_menu(self.ai_two)

        ai_menu_offset = self.color_menu_two.offset * 2

        self.color_menu_two.x = settings.SCREEN_WIDTH - (
            (settings.SCREEN_WIDTH - self.color_menu_two.get_width() -
             self.ai_menu_two.get_width() - ai_menu_offset) /
            5.0) - self.color_menu_two.get_width()
        self.color_menu_two.y = settings.SCREEN_HEIGHT / 2.0

        self.ai_menu_two.x = self.color_menu_two.x - self.ai_menu_two.get_width(
        ) - self.color_menu_two.offset * 2
        self.ai_menu_two.y = self.color_menu_two.y

        self.menu_list.append(self.color_menu_two)
        self.menu_list.append(self.ai_menu_two)

        # The text above the color menu for player two.
        self.player_two_text = textitem.TextItem(settings.PLAYER_TWO_NAME,
                                                 pygame.Color(255, 255, 255))
        self.player_two_text.x = self.ai_menu_two.x + ((
            (self.color_menu_two.get_width() + self.ai_menu_two.get_width() +
             ai_menu_offset) - self.player_two_text.get_width()) / 2.0)
        self.player_two_text.y = self.color_menu_two.y - (
            self.player_two_text.get_height() * 2)

        # The back button, displayed in the bottom-left corner of the screen.
        back_button = textitem.TextItem("Back")
        self.back_menu = listmenu.ListMenu()
        self.back_menu.x = distance_from_screen_edge + (
            back_button.get_width() / 2.0)
        self.back_menu.y = settings.SCREEN_HEIGHT - (2 *
                                                     back_button.get_height())
        self.back_menu.add(back_button, self.back)
        self.back_menu.items[0].selected = True
        self.menu_list.append(self.back_menu)

        # The start button, displayed in the bottom-right corner of the screen.
        start_button = textitem.TextItem("Start")
        self.start_menu = listmenu.ListMenu()
        self.start_menu.x = settings.SCREEN_WIDTH - distance_from_screen_edge - (
            start_button.get_width() / 2.0)
        self.start_menu.y = settings.SCREEN_HEIGHT - (
            2 * start_button.get_height())
        self.start_menu.add(start_button, self.start)
        self.menu_list.append(self.start_menu)

        # Register all menus with each other.
        for a_menu in self.menu_list:
            a_menu.register_other_menus(self.menu_list)

        # We setup all menu transition.
        self.transition.setup_transition(self.number_of_rounds_menu, True,
                                         True, False, False)
        self.transition.setup_single_item_transition(
            self.number_of_rounds_text, True, True, True, False)
        self.transition.setup_transition(self.color_menu_one, True, False,
                                         False, True)
        self.transition.setup_transition(self.ai_menu_one, True, False, False,
                                         True)
        self.transition.setup_single_item_transition(self.player_one_text,
                                                     True, False, True, False)
        self.transition.setup_transition(self.color_menu_two, False, True,
                                         False, True)
        self.transition.setup_transition(self.ai_menu_two, True, False, False,
                                         True)
        self.transition.setup_single_item_transition(self.player_two_text,
                                                     False, True, True, False)
        self.transition.setup_transition(self.back_menu, True, False, False,
                                         True)
        self.transition.setup_transition(self.start_menu, False, True, False,
                                         True)

        # And finally, we start the gameloop!
        self.gameloop()
예제 #8
0
    def __init__(self, window_surface, main_clock):
        # Call the superconstructor.
        scene.Scene.__init__(self, window_surface, main_clock)

        # The next screen to be started when the gameloop ends.
        self.next_screen = None

        # The back button, displayed in the middle-bottom of the screen.
        back_button = textitem.TextItem("Back")
        self.back_menu = listmenu.ListMenu()
        self.back_menu.x = settings.SCREEN_WIDTH / 2
        self.back_menu.y = settings.SCREEN_HEIGHT - (2 *
                                                     back_button.get_height())
        self.back_menu.add(back_button, self.back)
        self.back_menu.items[0].selected = True
        self.menu_list.append(self.back_menu)

        # We choose a smaller font size here for all the credits.
        font_size = 6 * settings.GAME_SCALE

        # Create and setup all the textitems.
        self.pyganim_credits = textitem.TextItem(
            "Pyganim is used to help animate items in the game")
        self.pyganim_credits.set_size(font_size)
        self.pyganim_credits.x = (settings.SCREEN_WIDTH -
                                  self.pyganim_credits.get_width()) / 2
        self.pyganim_credits.y = 9 * settings.GAME_SCALE

        self.pyganim_credits_source_code = textitem.TextItem(
            "Pyganim source code is not included in this game")
        self.pyganim_credits_source_code.set_size(font_size)
        self.pyganim_credits_source_code.x = (
            settings.SCREEN_WIDTH -
            self.pyganim_credits_source_code.get_width()) / 2
        self.pyganim_credits_source_code.y = self.pyganim_credits.y + self.pyganim_credits_source_code.get_height(
        )

        self.pyganim_credits_author = textitem.TextItem(
            "Pyganim is made by Al Sweigart", pygame.Color(255, 255, 255))
        self.pyganim_credits_author.set_size(font_size)
        self.pyganim_credits_author.x = (
            settings.SCREEN_WIDTH -
            self.pyganim_credits_author.get_width()) / 2
        self.pyganim_credits_author.y = self.pyganim_credits_source_code.y + self.pyganim_credits_author.get_height(
        )

        self.music_credits_title = textitem.TextItem(
            "Title screen music is sexxxy bit 3.xm")
        self.music_credits_title.set_size(font_size)
        self.music_credits_title.x = (settings.SCREEN_WIDTH -
                                      self.music_credits_title.get_width()) / 2
        self.music_credits_title.y = self.pyganim_credits_author.y + (
            2 * self.music_credits_title.get_height())

        self.music_credits_after_game = textitem.TextItem(
            "Postgame music is october chip.xm")
        self.music_credits_after_game.set_size(font_size)
        self.music_credits_after_game.x = (
            settings.SCREEN_WIDTH -
            self.music_credits_after_game.get_width()) / 2
        self.music_credits_after_game.y = self.music_credits_title.y + self.music_credits_after_game.get_height(
        )

        self.music_credits_title_author = textitem.TextItem(
            "Both made by Drozerix", pygame.Color(255, 255, 255))
        self.music_credits_title_author.set_size(font_size)
        self.music_credits_title_author.x = (
            settings.SCREEN_WIDTH -
            self.music_credits_title_author.get_width()) / 2
        self.music_credits_title_author.y = self.music_credits_after_game.y + self.music_credits_title_author.get_height(
        )

        self.music_credits_game = textitem.TextItem(
            "Game music is stardstm.mod")
        self.music_credits_game.set_size(font_size)
        self.music_credits_game.x = (settings.SCREEN_WIDTH -
                                     self.music_credits_game.get_width()) / 2
        self.music_credits_game.y = self.music_credits_title_author.y + (
            2 * self.music_credits_game.get_height())

        self.music_credits_game_author = textitem.TextItem(
            "Made by Jester", pygame.Color(255, 255, 255))
        self.music_credits_game_author.set_size(font_size)
        self.music_credits_game_author.x = (
            settings.SCREEN_WIDTH -
            self.music_credits_game_author.get_width()) / 2
        self.music_credits_game_author.y = self.music_credits_game.y + self.music_credits_game_author.get_height(
        )

        self.sound_effect_credits = textitem.TextItem(
            "Most sound effects made using bfxr")
        self.sound_effect_credits.set_size(font_size)
        self.sound_effect_credits.x = (
            settings.SCREEN_WIDTH - self.sound_effect_credits.get_width()) / 2
        self.sound_effect_credits.y = self.music_credits_game_author.y + (
            2 * self.sound_effect_credits.get_height())

        self.sound_effect_credits_author = textitem.TextItem(
            "Bfxr is made by increpare", pygame.Color(255, 255, 255))
        self.sound_effect_credits_author.set_size(font_size)
        self.sound_effect_credits_author.x = (
            settings.SCREEN_WIDTH -
            self.sound_effect_credits_author.get_width()) / 2
        self.sound_effect_credits_author.y = self.sound_effect_credits.y + self.sound_effect_credits_author.get_height(
        )

        self.more_info_and_licenses = textitem.TextItem(
            "More info and licenses are in the readme",
            pygame.Color(200, 20, 200))
        self.more_info_and_licenses.set_size(font_size)
        self.more_info_and_licenses.x = (
            settings.SCREEN_WIDTH -
            self.more_info_and_licenses.get_width()) / 2
        self.more_info_and_licenses.y = self.sound_effect_credits_author.y + (
            2 * self.more_info_and_licenses.get_height())

        self.made_by_author = textitem.TextItem(
            "Olof Karlsson AKA Pigmassacre", pygame.Color(200, 0, 0))
        self.made_by_author.set_size(font_size)
        self.made_by_author.x = (settings.SCREEN_WIDTH -
                                 self.made_by_author.get_width()) / 2
        self.made_by_author.y = self.back_menu.y - (
            2 * self.made_by_author.get_height())

        self.made_by_info = textitem.TextItem("Everything else made by me",
                                              pygame.Color(255, 255, 255))
        self.made_by_info.set_size(font_size)
        self.made_by_info.x = (settings.SCREEN_WIDTH -
                               self.made_by_info.get_width()) / 2
        self.made_by_info.y = self.made_by_author.y - self.made_by_info.get_height(
        )

        # The scale of the left and right looking pigs at the bottom of the screen.
        self.images_current_scale = 1 * settings.GAME_SCALE

        self.image_left = pygame.image.load(
            "res/splash/splash_bloody_left.png")
        self.image_left = pygame.transform.scale(
            self.image_left,
            (self.image_left.get_width() * self.images_current_scale,
             self.image_left.get_height() * self.images_current_scale))

        self.image_right = pygame.image.load(
            "res/splash/splash_bloody_right.png")
        self.image_right = pygame.transform.scale(
            self.image_right,
            (self.image_right.get_width() * self.images_current_scale,
             self.image_right.get_height() * self.images_current_scale))

        # We setup all menu transition.
        self.transition.speed = 1200 * settings.GAME_SCALE
        self.transition.setup_transition(self.back_menu, True, True, False,
                                         False)
        self.transition.setup_single_item_transition(self.pyganim_credits,
                                                     True, True, False, False)
        self.transition.setup_single_item_transition(
            self.pyganim_credits_source_code, True, True, False, False)
        self.transition.setup_single_item_transition(
            self.pyganim_credits_author, True, True, False, False)
        self.transition.setup_single_item_transition(self.music_credits_title,
                                                     True, True, False, False)
        self.transition.setup_single_item_transition(
            self.music_credits_after_game, True, True, False, False)
        self.transition.setup_single_item_transition(
            self.music_credits_title_author, True, True, False, False)
        self.transition.setup_single_item_transition(self.music_credits_game,
                                                     True, True, False, False)
        self.transition.setup_single_item_transition(
            self.music_credits_game_author, True, True, False, False)
        self.transition.setup_single_item_transition(self.sound_effect_credits,
                                                     True, True, False, False)
        self.transition.setup_single_item_transition(
            self.sound_effect_credits_author, True, True, False, False)
        self.transition.setup_single_item_transition(
            self.more_info_and_licenses, True, True, False, False)
        self.transition.setup_single_item_transition(self.made_by_author, True,
                                                     True, False, False)
        self.transition.setup_single_item_transition(self.made_by_info, True,
                                                     True, False, False)

        # And finally, we start the gameloop!
        self.gameloop()
예제 #9
0
    def __init__(self, window_surface, main_clock):
        # Call the superconstructor.
        scene.Scene.__init__(self, window_surface, main_clock)

        # The next screen to be started when the gameloop ends.
        self.next_screen = None

        # This is a dictionary that contains information linked to certain imageitems.
        self.info = {}

        # This is a dictionary that maps transition methods to all all items.
        self.transition_method = {}

        # This contains the currently active function that displays the currently active information.
        self.active_info = None

        # This information is used to format the help texts.
        self.distance_from_screen_edge = 6 * settings.GAME_SCALE
        self.font_size = 6 * settings.GAME_SCALE
        self.max_width_of_text_line = (settings.SCREEN_WIDTH -
                                       (self.distance_from_screen_edge * 2))

        # We create a gridmenu that allows the player to choose what item they want to read more about.
        self.help_menu = gridmenu.GridMenu(13)
        self.help_menu.y = 9 * settings.GAME_SCALE
        self.menu_list.append(self.help_menu)

        # The back button, displayed in the middle-bottom of the screen.
        back_button = textitem.TextItem("Back")
        self.back_menu = listmenu.ListMenu()
        self.back_menu.x = settings.SCREEN_WIDTH / 2
        self.back_menu.y = settings.SCREEN_HEIGHT - (2 *
                                                     back_button.get_height())
        self.back_menu.add(back_button, self.back)
        self.back_menu.items[0].selected = True
        self.menu_list.append(self.back_menu)

        # We setup and add all the necessary items to the help_menu.
        root = "res/helpdata"
        for file in os.listdir(root):
            if file.endswith(".json"):
                self.setup_info(os.path.join(root, file))

        self.help_menu.x = (settings.SCREEN_WIDTH -
                            self.help_menu.get_width()) / 2

        # Register all menus with each other.
        for a_menu in self.menu_list:
            a_menu.register_other_menus(self.menu_list)

        # We setup all menu transition.
        self.transition.speed = 20 * settings.GAME_FPS * settings.GAME_SCALE
        self.transition.setup_transition(self.help_menu, True, True, True,
                                         False)
        self.transition.setup_transition(self.back_menu, True, True, False,
                                         False)

        # Set the first item as the active information.
        if len(self.help_menu.items) > 0:
            self.view_info(self.help_menu.items[0])

        # And finally, we start the gameloop!
        self.gameloop()
예제 #10
0
    def setup_menus(self):
        # This is the distance from the screen edges to the GUI elements
        item_side_padding = textitem.TextItem.font_size

        # We setup and position all the needed textitems and menus.
        self.rounds_left_text = textitem.generate_list_from_string(
            "Rounds Left")

        length_of_rounds_left_text = sum(
            letter_item.get_width() for letter_item in self.rounds_left_text)

        last_offset = 0
        for letter_item in self.rounds_left_text:
            letter_item.x = (
                (settings.SCREEN_WIDTH - length_of_rounds_left_text) /
                2.0) + last_offset
            letter_item.y = item_side_padding
            last_offset += letter_item.get_width()

            color = copy.copy(self.winner.color)
            h = color.hsla[0] + ((360 / (len(self.rounds_left_text) * 2)) *
                                 self.rounds_left_text.index(letter_item))
            h %= 360
            color.hsla = (h, color.hsla[1], color.hsla[2], color.hsla[3])
            letter_item.set_color(color)

        self.passed_time = 0

        self.rounds_left_number_text = textitem.TextItem(
            str(self.number_of_rounds - self.number_of_rounds_done),
            pygame.Color(255, 255, 255))
        self.rounds_left_number_text.set_size(18 * settings.GAME_SCALE)
        self.rounds_left_number_text.x = (
            settings.SCREEN_WIDTH -
            self.rounds_left_number_text.get_width()) / 2
        self.rounds_left_number_text.y = self.rounds_left_text[
            0].y + self.rounds_left_number_text.get_height()

        self.player_one_score_text = textitem.TextItem(
            str(self.score[self.player_one]), pygame.Color(255, 255, 255))
        self.player_one_score_text.set_size(27 * settings.GAME_SCALE)
        self.player_one_score_text.x = (settings.SCREEN_WIDTH -
                                        self.player_one_score_text.get_width()
                                        ) / 4 + 1.5 * settings.GAME_SCALE
        self.player_one_score_text.y = (
            settings.SCREEN_HEIGHT -
            self.player_one_score_text.get_height()) / 2
        self.player_one_score_text.set_color(self.player_one.color)

        self.player_one_text = textitem.TextItem(self.player_one.name,
                                                 pygame.Color(255, 255, 255))
        self.player_one_text.x = self.player_one_score_text.x + (
            (self.player_one_score_text.get_width() -
             self.player_one_text.get_width()) / 2)
        self.player_one_text.y = self.player_one_score_text.y - (
            2 * self.player_one_text.get_height())
        self.player_one_text.set_color(self.player_one.color)

        self.player_two_score_text = textitem.TextItem(
            str(self.score[self.player_two]), pygame.Color(255, 255, 255))
        self.player_two_score_text.set_size(27 * settings.GAME_SCALE)
        self.player_two_score_text.x = 3 * (
            (settings.SCREEN_WIDTH - self.player_two_score_text.get_width()) /
            4) + 1.5 * settings.GAME_SCALE
        self.player_two_score_text.y = (
            settings.SCREEN_HEIGHT -
            self.player_two_score_text.get_height()) / 2
        self.player_two_score_text.set_color(self.player_two.color)

        self.player_two_text = textitem.TextItem(self.player_two.name,
                                                 pygame.Color(255, 255, 255))
        self.player_two_text.x = self.player_two_score_text.x + (
            (self.player_two_score_text.get_width() -
             self.player_two_text.get_width()) / 2)
        self.player_two_text.y = self.player_two_score_text.y - (
            2 * self.player_two_text.get_height())
        self.player_two_text.set_color(self.player_two.color)

        quit_button = textitem.TextItem("Quit")
        self.quit_menu = listmenu.ListMenu(
            item_side_padding + (quit_button.get_width() / 2),
            settings.SCREEN_HEIGHT - item_side_padding -
            quit_button.get_height())
        self.quit_menu.add(quit_button, self.maybe_quit)
        self.menu_list.append(self.quit_menu)

        next_match_button = textitem.TextItem("Next Round")
        self.next_match_menu = listmenu.ListMenu(
            settings.SCREEN_WIDTH - item_side_padding -
            (next_match_button.get_width() / 2), settings.SCREEN_HEIGHT -
            item_side_padding - next_match_button.get_height())
        self.next_match_menu.add(next_match_button, self.next_match)
        self.next_match_menu.items[0].selected = True
        self.menu_list.append(self.next_match_menu)

        # Register all menus with each other. This is for gui.traversals sake, so it knows that there are more than one menu to traverse upon.
        for a_menu in self.menu_list:
            a_menu.register_other_menus(self.menu_list)
예제 #11
0
 def setup_menu_right(self):
     return listmenu.ListMenu(
         settings.SCREEN_WIDTH - (settings.SCREEN_WIDTH / 4),
         settings.SCREEN_HEIGHT / 2)
예제 #12
0
 def setup_menu_left(self):
     return listmenu.ListMenu(settings.SCREEN_WIDTH / 4,
                              settings.SCREEN_HEIGHT / 2)
예제 #13
0
 def setup_menu(self):
     # Returns a menu that is positioned in the center of the screen.
     return listmenu.ListMenu(settings.SCREEN_WIDTH / 2,
                              settings.SCREEN_HEIGHT / 2)