def __init__(self, display):
        self.display = display
        self.state = "load_game"
        self.game_reference = None

        # Background Setup
        self.background = pygame_gui.Image(
            paths.imagePath + "background-load.png", 0, 0)

        # GUI Setup
        self.back_button = pygame_gui.Button(
            paths.uiPath + "backwhite.png",
            paths.uiPath + "backwhite-hover.png", 5, 5)
        self.title = pygame_gui.Text("Select Level: ",
                                     constants.FONTS["sizes"]["large"],
                                     constants.FONTS["colour"],
                                     constants.FONTS["main"], 275, 55)

        self.file_selector = FileSelector(self, [275, 100])
        self.try_delete = None  # if True, displays delete_message, try's to delete file in to_delete if ok pressed
        self.to_delete = None

        self.page_back_button = pygame_gui.Button(
            paths.uiPath + "pageback.png", paths.uiPath + "pageback-hover.png",
            670, 53)
        self.page_forward_button = pygame_gui.Button(
            paths.uiPath + "pageforward.png",
            paths.uiPath + "pageforward-hover.png", 710, 53)

        self.run()
Example #2
0
    def __init__(self, display):
        self.display = display
        self.state = "load_game"
        self.game_reference = None

        # Background Setup
        self.background = pygame_gui.Image(paths.uiMenuPath + "background.png",
                                           0, 0)
        self.back_panel = pygame_gui.Panel([100, 100, 800, 500], 150,
                                           constants.COLOURS["panel"])

        # GUI Setup
        self.back_button = pygame_gui.Button(
            paths.uiPath + "backwhite.png",
            paths.uiPath + "backwhite-hover.png", 5, 5)
        self.title = pygame_gui.Text("Select Game: ",
                                     constants.FONTS["sizes"]["large"],
                                     constants.FONTS["colour"],
                                     constants.FONTS["main"], 110, 110)

        self.file_selector = FileSelector(self, [250, 150])
        self.try_delete = None  # if True, displays delete_message, try's to delete file in to_delete if ok pressed
        self.to_delete = None
        self.delete_message = GUI.CheckMessage(self, "Are You Sure?", [
            "The game will be permanently deleted,", "and can't be recovered!"
        ])

        self.page_back_button = pygame_gui.Button(
            paths.uiPath + "pageback.png", paths.uiPath + "pageback-hover.png",
            820, 550)
        self.page_forward_button = pygame_gui.Button(
            paths.uiPath + "pageforward.png",
            paths.uiPath + "pageforward-hover.png", 860, 550)

        self.run()
Example #3
0
    def __init__(self, display):
        self.display = display
        self.state = "menu"
        self.game_reference = None

        # Background Setup
        self.background = pygame_gui.Image(paths.uiMenuPath + "background.png", 0, 0)

        # Title / Header setup
        self.title = pygame_gui.Text(
            constants.DISPLAY_NAME,
            50, constants.FONTS["colour"], constants.FONTS["main"],
            250, 150)

        # Making panel around text, with padding.
        title_rect = pygame.Rect(self.title.get_rect())
        title_padding = 5
        title_rect.x -= title_padding
        title_rect.width += title_padding*2
        self.title_panel = pygame_gui.Panel(title_rect, 150, constants.COLOURS["panel"])

        self.title_logo = pygame.image.load(paths.uiMenuPath + "logo-big.png")
        self.logo_panel = pygame_gui.Panel([title_rect.right, title_rect.y, title_rect.height, title_rect.height],
                                           150, (0, 0, 0))

        # Menu location (New, Load and Leaderboard)
        self.menux = 425
        self.menuy = 370

        # GUI Menu Setup
        self.newgame_button = pygame_gui.TextButton(
            [self.menux, self.menuy, 150, 40],
            220, 200,
            "new game",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"], constants.FONTS["main"])

        self.continue_button = pygame_gui.TextButton(
            [self.menux, self.menuy + 40, 150, 40],
            220, 200,
            "continue",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"], constants.FONTS["main"])

        self.leaderboard_button = pygame_gui.TextButton(
            [self.menux, self.menuy + 80, 150, 40],
            220, 200,
            "leaderboard",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"], constants.FONTS["main"])

        self.about_button = pygame_gui.TextButton(
            [5, self.display.get_height() - 45, 80, 40],
            220, 200,
            "about",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"], constants.FONTS["main"])

        self.show_about = False
        self.about = About(self)

        self.run()
Example #4
0
    def __init__(self, display):
        self.display = display
        self.state = "menu"

        # Background Setup
        self.background = pygame_gui.Image(
            paths.imagePath + "background-menu.png", 0, 0)

        # Title / Header setup
        self.title = pygame_gui.Text(constants.DISPLAY_NAME, 45,
                                     constants.FONTS["colour"],
                                     constants.FONTS["main"], 430, 180)

        # Making panel around text, with padding.
        title_rect = pygame.Rect(self.title.get_rect())
        title_padding = 5
        title_rect.x -= title_padding
        title_rect.width += title_padding * 2
        self.title_panel = pygame_gui.Panel(title_rect, 150,
                                            constants.COLOURS["panel"])

        # Menu location (New, Load and Leaderboard)
        self.menux = 420
        self.menuy = 300

        # GUI Menu Setup
        self.continue_button = pygame_gui.TextButton(
            [self.menux, self.menuy + 40, 150, 40], constants.COLOURS["panel"],
            constants.COLOURS["panel-hover"], "select level",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"],
            constants.FONTS["main"])

        self.editor_button = pygame_gui.TextButton(
            [self.menux, self.menuy + 90, 150, 40], constants.COLOURS["panel"],
            constants.COLOURS["panel-hover"], "editor",
            constants.FONTS["sizes"]["large"], constants.FONTS["colour"],
            constants.FONTS["main"])

        self.version = pygame_gui.Text(constants.version,
                                       constants.FONTS["sizes"]["medium"],
                                       constants.FONTS["colour"],
                                       constants.FONTS["main"], 3,
                                       constants.DISPLAY_SIZE[1] - 20)

        self.project_github = WebLink("GitHub Page",
                                      "https://github.com/Ben-Ryder/Escape",
                                      470, constants.DISPLAY_SIZE[1] - 20)

        self.personal_site = WebLink("By Ben Ryder",
                                     "https://github.com/Ben-Ryder",
                                     constants.DISPLAY_SIZE[0] - 87,
                                     constants.DISPLAY_SIZE[1] - 20)

        self.run()
    def __init__(self, display):
        self.display = display
        self.state = "leaderboard"

        # Background Setup
        self.background = pygame_gui.Image(paths.uiMenuPath + "background.png",
                                           0, 0)
        self.back_panel = pygame_gui.Panel([100, 100, 800, 500], 150,
                                           constants.COLOURS["panel"])

        # GUI Setup
        self.back = pygame_gui.Button(paths.uiPath + "backwhite.png",
                                      paths.uiPath + "backwhite-hover.png", 5,
                                      5)
        self.title = pygame_gui.Text("Leaderboard: ",
                                     constants.FONTS["sizes"]["large"],
                                     constants.FONTS["colour"],
                                     constants.FONTS["main"], 110, 110)

        self.top_ten = pygame_gui.Text("(top 10)",
                                       constants.FONTS["sizes"]["large"],
                                       constants.FONTS["colour"],
                                       constants.FONTS["main"], 825, 110)

        self.rank_text = pygame_gui.Text("rank",
                                         constants.FONTS["sizes"]["medium"],
                                         constants.FONTS["colour"],
                                         constants.FONTS["main"], 310, 150)

        self.name_text = pygame_gui.Text("name",
                                         constants.FONTS["sizes"]["medium"],
                                         constants.FONTS["colour"],
                                         constants.FONTS["main"], 380, 150)

        self.score_text = pygame_gui.Text("score",
                                          constants.FONTS["sizes"]["medium"],
                                          constants.FONTS["colour"],
                                          constants.FONTS["main"], 605, 150)

        self.leaderboard_reader = LeaderboardEditor()
        self.slots = []
        x, y = [300, 170]
        padding = 40  # between player slots
        rank = 1
        for player in self.leaderboard_reader.get_high_scores(10):
            self.slots.append(LeaderboardSlot(player[0], player[1], rank, x,
                                              y))
            y += padding
            rank += 1

        self.run()
    def __init__(self, display):
        self.display = display
        self.state = "new_game"
        self.game_reference = None

        # Background Setup
        self.background = pygame_gui.Image(paths.uiMenuPath + "background.png",
                                           0, 0)
        self.back_panel = pygame_gui.Panel([100, 100, 800, 500], 150,
                                           constants.COLOURS["panel"])

        # GUI Setup
        self.origin = [150, 30]
        # General
        self.back_button = pygame_gui.Button(
            paths.uiPath + "backwhite.png",
            paths.uiPath + "backwhite-hover.png", 5, 5)

        self.title_text = pygame_gui.Text("Create Game:",
                                          constants.FONTS["sizes"]["large"],
                                          constants.FONTS["colour"],
                                          constants.FONTS["main"], 110, 110)

        self.play_button = pygame_gui.Button(
            paths.uiPath + "forwardwhite.png",
            paths.uiPath + "forwardwhite-hover.png", self.origin[0] + 700,
            self.origin[1] + 525)

        # Game Input Setup
        self.game_name_prompt = pygame_gui.Text(
            "Game Name:", constants.FONTS["sizes"]["medium"],
            constants.FONTS["colour"], constants.FONTS["main"],
            self.origin[0] + 100, self.origin[1] + 150)

        self.game_name_input = pygame_gui.Entry(
            paths.uiMenuPath + "input-large.png",
            paths.uiMenuPath + "input-large-hover.png",
            paths.uiMenuPath + "input-large-focused.png",
            paths.uiMenuPath + "input-large-hover-focused.png", "",
            constants.FONTS["sizes"]["medium"], constants.FONTS["colour"],
            constants.FONTS["main"], 10, 5, True, self.origin[0] + 250,
            self.origin[1] + 145)

        self.game_name_error_text = pygame_gui.Text(
            "", constants.FONTS["sizes"]["small"], constants.COLOURS["red"],
            constants.FONTS["main-bold-italic"], self.origin[0] + 250,
            self.origin[1] + 180)

        # Map Input Setup
        self.map_select_prompt = pygame_gui.Text(
            "Select Map:", constants.FONTS["sizes"]["medium"],
            constants.FONTS["colour"], constants.FONTS["main"],
            self.origin[0] + 100, self.origin[1] + 200)

        self.map_selector = MapSelector(self.origin[0] + 250,
                                        self.origin[1] + 200)

        # Player Input Setup
        self.players_prompt = pygame_gui.Text(
            "Players:", constants.FONTS["sizes"]["medium"],
            constants.FONTS["colour"], constants.FONTS["main"],
            self.origin[0] + 100, self.origin[1] + 250)

        self.player_slots_error = pygame_gui.Text(
            "", constants.FONTS["sizes"]["small"], constants.COLOURS["red"],
            constants.FONTS["main-bold-italic"], self.origin[0] + 200,
            self.origin[1] + 255)

        self.player_manager = PlayerManager(
            4, [self.origin[0] + 100, self.origin[1] + 290])

        self.run()