示例#1
0
    def __init__(self, master, controller, x, y):

        TaskGUI.__init__(self, master, controller, x, y, "inventory_display")

        self.title = gui_components.Label(self.x + 9, self.y, "Inventory",
                                          False, 32, constants.BLACK)

        self.items = list(self.master.master.story_tracker.inventory.items())
        self.labels = [
            gui_components.Label(
                self.x + 45, self.y + (40 * n) + 44,
                "x{} Potion of {}".format(self.items[n][1][0],
                                          self.items[n][1][1]), False, 32,
                constants.BLACK) for n in range(len(self.items))
        ]
        image_data = lambda x: constants.item_images[self.items[x][0]]
        self.item_images = [
            gui_components.Image(
                icons.sprite_sheet.get_image(
                    image_data(n)[0],
                    image_data(n)[1],
                    image_data(n)[2],
                    image_data(n)[3]), self.x + 13, self.y + (40 * n) + 50,
                False) for n in range(len(self.items))
        ]

        self.components += [self.title] + self.labels + self.item_images
示例#2
0
    def __init__(self, master):

        self.master = master

        self.images = menu_image_loader.load_images()

        self.background = gui_components.Image("src/resources/title.png")

        self.play_button = gui_components.Button(self.images["play_button"],
                                                 11, 25,
                                                 lambda: self.callback(0))
        self.options_button = gui_components.Button(
            self.images["option_button"], 11, 136, lambda: self.callback(1))
        self.quit_button = gui_components.Button(self.images["quit_button"],
                                                 11, 249,
                                                 lambda: self.callback(2))

        self.buttons = [
            self.play_button, self.options_button, self.quit_button
        ]

        self.hud = hud.HUD(None, self)

        self.hud.save_hud("menu", [
            "save_select",
        ])
        self.hud.load_saved_hud("menu")

        self.save_select_open = False
示例#3
0
    def __init__(self, master, controller, x, y, widget_id):

        self.master = master
        self.controller = controller

        self.x = x
        self.y = y

        self.id = widget_id

        self.background = gui_components.Image(
            "src/resources/tasks_background.png", self.x, self.y)

        self.components = [
            self.background,
        ]
示例#4
0
    def refresh(self):

        self.items = [
            item for item in list(
                self.master.master.story_tracker.inventory.items())
            if item[0] in constants.healing_items
        ]

        self.labels = [
            gui_components.Label(
                self.x + 45, self.y + (40 * n) + 44,
                "x{} Potion of {}".format(self.items[n][1][0],
                                          self.items[n][1][1]), False, 32,
                constants.BLACK) for n in range(len(self.items))
        ]
        image_data = lambda x: constants.item_images[self.items[x][0]]
        self.item_images = [
            gui_components.Image(
                icons.sprite_sheet.get_image(
                    image_data(n)[0],
                    image_data(n)[1],
                    image_data(n)[2],
                    image_data(n)[3]), self.x + 13, self.y + (40 * n) + 50,
                False) for n in range(len(self.items))
        ]

        self.components = [
            self.background, self.title, self.press_space, self.pointer
        ] + self.labels + self.item_images

        if len(self.controller.player.beans) > 1:
            self.hint_arrow = gui_components.Label(self.x - 29, self.y - 138,
                                                   "<-", False, 48,
                                                   constants.BLACK)
            self.hint_text1 = gui_components.Label(self.x + 28, self.y - 150,
                                                   "Hover over the Bean",
                                                   False, 32, constants.BLACK)
            self.hint_text2 = gui_components.Label(self.x + 28, self.y - 111,
                                                   "you want to heal!", False,
                                                   32, constants.BLACK)

            self.components += [
                self.hint_arrow, self.hint_text1, self.hint_text2
            ]
示例#5
0
    def __init__(self, master, controller, x, y):

        TaskGUI.__init__(self, master, controller, x, y, "journal_display")

        self.title = gui_components.Label(self.x + 9, self.y, "Journal", False,
                                          32, constants.BLACK)

        self.quests = list(self.master.master.story_tracker.quests.items())
        self.completed_quests = list(
            self.master.master.story_tracker.completed_quests.items())

        self.labels = [
            gui_components.Label(
                self.x + 50,
                self.y + (40 * (n + len(self.completed_quests))) + 44,
                self.quests[n][1], False, 32, constants.BLACK)
            for n in range(len(self.quests))
        ]

        self.labels += [
            gui_components.Label(self.x + 50, self.y + (40 * n) + 44,
                                 self.completed_quests[n][1], False, 32,
                                 constants.HEALTH_BAR_GREEN)
            for n in range(len(self.completed_quests))
        ]

        self.quests = self.completed_quests + self.quests

        image_data = lambda x: constants.quest_images[self.quests[x][0]]
        self.quest_images = [
            gui_components.Image(
                icons.sprite_sheet.get_image(
                    image_data(n)[0],
                    image_data(n)[1],
                    image_data(n)[2],
                    image_data(n)[3]), self.x + 13, self.y + (40 * n) + 50,
                False) for n in range(len(self.quests))
        ]

        self.components += [self.title] + self.labels + self.quest_images

        self.master.master.story_tracker.set_quests_seen()
        self.master.master.story_tracker.purge_completed()
示例#6
0
    def __init__(self, master):

        self.master = master

        self.images = menu_image_loader.load_images()

        self.background = gui_components.Image("src/resources/title.png")

        self.play_button = gui_components.Button(self.images["play_button"],
                                                 374, 396,
                                                 lambda: self.callback(0))
        self.options_button = gui_components.Button(
            self.images["option_button"], 374, 496, lambda: self.callback(1))
        self.quit_button = gui_components.Button(self.images["quit_button"],
                                                 374, 596,
                                                 lambda: self.callback(2))

        self.buttons = [
            self.play_button, self.options_button, self.quit_button
        ]

        dark_screen = gui_components.Fill(0, 0, 960, 720, constants.BLACK)
        dark_screen.image.set_alpha(200)

        self.dark_background = tools.combine_images([self.background] +
                                                    self.buttons +
                                                    [dark_screen])
        self.normal_background = self.background.image

        self.hud = hud.HUD(None, self)

        self.hud.save_hud("menu", ["save_select", "options_menu"])
        self.hud.load_saved_hud("menu")

        self.save_select_open = False
        self.options_menu_open = False
        self.can_click = True
示例#7
0
    def refresh(self):

        self.items = list(self.master.master.story_tracker.inventory.items())
        self.labels = [
            gui_components.Label(
                self.x + 45, self.y + (40 * n) + 44,
                "x{} Potion of {}".format(self.items[n][1][0],
                                          self.items[n][1][1]), False, 32,
                constants.BLACK) for n in range(len(self.items))
        ]
        image_data = lambda x: constants.item_images[self.items[x][0]]
        self.item_images = [
            gui_components.Image(
                icons.sprite_sheet.get_image(
                    image_data(n)[0],
                    image_data(n)[1],
                    image_data(n)[2],
                    image_data(n)[3]), self.x + 13, self.y + (40 * n) + 50,
                False) for n in range(len(self.items))
        ]

        self.components = [
            self.background, self.title, self.press_space, self.pointer
        ] + self.labels + self.item_images
示例#8
0
    def __init__(self, master, x, y):

        self.master = master

        self.x = x
        self.y = y

        self.id = "backing"

        self.background = gui_components.Fill(self.x, self.y, 200, 277,
                                              constants.GUI_BACKING)
        self.my_beans = gui_components.Label(self.x + 5, self.y, "My Beans",
                                             False, 30, constants.WHITE)
        self.other_beans = gui_components.Label(self.x + 5, self.y + 239,
                                                "Other Beans", False, 30,
                                                constants.WHITE)
        self.open_hud_button = gui_components.Button(
            hud_image_loader.load_images("open_hud_button"), self.x,
            self.y + 225, lambda: self.callback(0))

        self.close_hud_button = gui_components.Button(
            hud_image_loader.load_images("close_hud_button"), self.x + 200,
            self.y + 225, lambda: self.callback(1))
        self.compass = gui_components.Image(
            hud_image_loader.load_images("compass")[0], 802, 10, False)

        self.open_components = [
            self.my_beans, self.other_beans, self.close_hud_button,
            self.compass
        ]

        self.close_components = [self.open_hud_button, self.compass]

        self.components = self.open_components

        self.hud_open = True
示例#9
0
    def __init__(self):

        # Initiate pygame
        pygame.mixer.pre_init(22050, -16, 1, 512)
        pygame.mixer.init()
        pygame.init()

        pygame.mixer.set_num_channels(16)

        # Create the display
        self.display = pygame.display.set_mode(constants.DISPLAY_SIZE)

        # Set the title on the window
        pygame.display.set_caption("Tim's Adventure")

        icon_img = pygame.image.load("src/resources/icon.png")

        icon = pygame.Surface([32, 32], flags=pygame.SRCALPHA)
        icon = icon.convert_alpha()
        icon.blit(icon_img, (0, 0))
        pygame.display.set_icon(icon)

        self.clock = pygame.time.Clock()

        self.load_components()
        constants.load_performance_profile(1)

        self.loading_screen = gui_components.Image(
            tools.combine_images(
                (gui_components.Fill(0, 0, 960, 720, constants.BLACK),
                 gui_components.Label(340, 322, "Loading...", False, 64))), 0,
            0, False)

        self.loading_screen.draw(self.display)
        pygame.display.update()

        self.fade_screen = gui_components.Fade()
        self.fade_screen.set_opacity(0)

        self.sound_engine = sounds.SoundEngine()
        self.particle_engine = particles.ParticleEngine()
        self.save_engine = save.SaveEngine()
        self.story_tracker = story_tracker.StoryTracker(self)

        self.game_exit = False

        self.chunk_controller = chunks.ChunkController(self)
        self.duel_controller = duel_controller.DuelController(self)
        self.dialogue_controller = dialogue.DialogueController(self)

        self.menu = menu.MainMenu(self)

        self.show_loading = False

        self.game_mode = 2
        self.full_screen = False

        self.fade = 0
        self.new_game_mode = -1
        self.loading_screen_time = constants.LOADING_SCREEN_TIME

        self.controllers = [
            self.chunk_controller, self.duel_controller, self.menu,
            self.dialogue_controller
        ]

        self.load_function = None
        self.after_load = -1

        self.current_save = ""

        self.last_song = ""