Exemplo n.º 1
0
    def __init__(self, entity, x, y):

        self.x = x
        self.y = y

        self.id = "enemy_stats"

        self.enemy_meta = entity.meta

        self.background = gui_components.Fill(self.x, self.y, 190, 60,
                                              constants.GUI_FILL)

        self.health_bar = gui_components.ProgressBar(
            self.x + 4, self.y + 24, 182, 5,
            (constants.HEALTH_BAR_RED, constants.HEALTH_BAR_GREEN))
        self.xp_bar = gui_components.ProgressBar(
            self.x + 4, self.y + 32, 182, 5,
            (constants.XP_BAR_BLUE, constants.XP_BAR_CYAN))
        self.bean_name = gui_components.Label(self.x + 4, self.y - 2,
                                              self.enemy_meta.display_name,
                                              False, 20, constants.BLACK)
        self.bean_level = gui_components.Label(
            self.x + 152, self.y + 36,
            "Level {}".format(self.enemy_meta.level), False, 20,
            constants.BLACK)
        self.bean_level.rect.topright = [self.x + 188, self.y + 36]

        self.components = [
            self.background, self.health_bar, self.xp_bar, self.bean_name,
            self.bean_level
        ]

        self.on = True
Exemplo n.º 2
0
    def __init__(self, player, master, controller, x=0, y=0):

        self.player = player
        self.master = master
        self.controller = controller

        self.active_bean_stat = 0

        self.x = x
        self.y = y

        self.id = "health_display"

        self.background = gui_components.Fill(self.x, self.y, 200, 209, constants.GUI_BACKING)

        self.bean_stats = [gui_components.Fill(self.x+5, self.y+5+35*n, 190, 30, constants.GUI_FILL)
                           for n in range(len(self.player.beans))]
        self.health_bars = [gui_components.ProgressBar(self.x+9, self.y+27+36*n, 182, 5,
                                                       (constants.HEALTH_BAR_RED, constants.HEALTH_BAR_GREEN))
                            for n in range(len(self.player.beans))]
        self.bean_labels = [gui_components.Label(self.x+9, self.y+3+40*n, "{}{} Bean".format(
            self.player.beans[n].bean[0].upper(), self.player.beans[n].bean[1:]),
                                                 False, 20, constants.BLACK)
                            for n in range(len(self.player.beans))]

        self.xp_bar = gui_components.ProgressBar(self.x+9, self.y+37+34*self.active_bean_stat, 182, 5,
                                                 (constants.XP_BAR_BLUE, constants.XP_BAR_CYAN))

        self.level_label = gui_components.Label(self.x, self.y+41+35*self.active_bean_stat, "Level {}".format(
            self.player.beans[self.active_bean_stat].meta.level), False, 20, constants.BLACK)

        self.components = [self.background] + self.bean_stats + self.health_bars + self.bean_labels +\
                          [self.xp_bar, self.level_label]
Exemplo n.º 3
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
Exemplo n.º 4
0
    def begin_duel(self, player, enemy):

        try:
            self.text.remove(self.attack_main_label)
            self.text.remove(self.attack_alt_label)

            self.text.remove(self.player_name_label)
            self.text.remove(self.enemy_name_label)
        except ValueError:
            pass

        self.player = DuelPlayer(player, "R")
        self.enemy = DuelPlayer(enemy, "L")

        self.attack_main_label = gui_components.Label(
            607, 603, moves[self.player.meta.moves[0]]["name"], True)
        self.attack_alt_label = gui_components.Label(
            831, 603, moves[self.player.meta.moves[1]]["name"], True)

        self.player_name_label = gui_components.Label(
            507, 312, "{} BEAN STATS".format(self.player.meta.bean.upper()))
        self.enemy_name_label = gui_components.Label(
            28, 137, "{} BEAN STATS".format(self.enemy.meta.bean.upper()))

        self.text.append(self.attack_main_label)
        self.text.append(self.attack_alt_label)

        self.text.append(self.player_name_label)
        self.text.append(self.enemy_name_label)

        self.reset()
Exemplo n.º 5
0
    def __init__(self, master, controller, x, y):

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

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

        self.text = gui_components.Label(self.x + 18, self.y + 44,
                                         "Coming Soon!", False, 32,
                                         constants.BLACK)

        self.components += [self.title, self.text]
Exemplo n.º 6
0
    def __init__(self, player, master, controller, x, y):

        self.player = player
        self.master = master
        self.controller = controller

        self.x = x
        self.y = y

        self.id = "bean_select"

        self.selected_option = 0

        self.background = gui_components.Fill(self.x, self.y, 366, 176,
                                              constants.GUI_BACKING)
        self.background_fill = gui_components.Fill(self.x + 5, self.y + 5, 356,
                                                   166, constants.GUI_FILL)

        self.title = [
            gui_components.Label(self.x + 9, self.y + 3,
                                 "You have been challenged to fight!", False,
                                 20, constants.BLACK),
            gui_components.Label(self.x + 9, self.y + 21,
                                 "Which bean accepts the challenge?", False,
                                 20, constants.BLACK)
        ]

        self.options = [
            gui_components.Label(self.x + 35, self.y + 39 + 18 * n,
                                 self.player.beans[n].meta.display_name, False,
                                 20, constants.BLACK)
            for n in range(len(self.player.beans))
        ]
        self.options.append(
            gui_components.Label(self.x + 35,
                                 self.y + 39 + 18 * len(self.options),
                                 "I decline the challenge", False, 20,
                                 constants.BLACK))

        self.space_label = gui_components.Label(self.background.rect.centerx,
                                                self.y + 159,
                                                "<Space to Select>", True, 20,
                                                (79, 80, 68))

        self.arrow = icons.ArrowPointer(
            self.x + 23, self.y + 44 + 18 * self.selected_option)

        self.components = [
            self.background, self.background_fill, self.space_label, self.arrow
        ] + self.title + self.options
Exemplo n.º 7
0
    def __init__(self, player, master, controller, x, y):

        self.player = player
        self.master = master
        self.controller = controller

        self.active_bean_stat = 0

        self.x = x
        self.y = y

        self.id = "health_display"

        self.bean_stats = [
            gui_components.Fill(self.x + 5, self.y + 5 + 35 * n, 190, 30,
                                constants.GUI_FILL)
            for n in range(len(self.player.beans))
        ]
        self.health_bars = [
            gui_components.ProgressBar(
                self.x + 9, self.y + 27 + 36 * n, 182, 5,
                (constants.HEALTH_BAR_RED, constants.HEALTH_BAR_GREEN))
            for n in range(len(self.player.beans))
        ]
        self.bean_labels = [
            gui_components.Label(self.x + 9, self.y + 3 + 40 * n,
                                 self.player.beans[n].meta.display_name, False,
                                 20, constants.BLACK)
            for n in range(len(self.player.beans))
        ]

        self.xp_bar = gui_components.ProgressBar(
            self.x + 9, self.y + 37 + 34 * self.active_bean_stat, 182, 5,
            (constants.XP_BAR_BLUE, constants.XP_BAR_CYAN))

        self.level_label = gui_components.Label(
            self.x, self.y + 41 + 35 * self.active_bean_stat,
            "Level {}".format(
                self.player.beans[self.active_bean_stat].meta.level), False,
            20, constants.BLACK)

        self.components = self.bean_stats + self.health_bars + self.bean_labels + [
            self.xp_bar, self.level_label
        ]

        self.update_required = True
Exemplo n.º 8
0
    def __init__(self, master, controller, x, y):

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

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

        self.components.append(self.title)
Exemplo n.º 9
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
            ]
Exemplo n.º 10
0
    def render_next(self):

        current_dialogue, speaker = self.current_scene[self.scene_progress]

        if speaker:
            self.text_x = self.other_text_x
            self.text_y = self.other_text_y
        else:
            self.text_x = self.player_text_x
            self.text_y = self.player_text_y

        self.text_box_background.rect.topleft = [self.text_x, self.text_y]
        self.text_box_fill.rect.topleft = [self.text_x + 10, self.text_y + 10]
        self.press_space.rect.topleft = [self.text_x + 51, self.text_y + 199]
        self.press_left.rect.topleft = [self.text_x + 63, self.text_y + 223]

        dialogue_in_words = current_dialogue.split(" ")

        sorted_lines = []

        n = len(dialogue_in_words)
        while n > 0:
            if self.body_font.size(" ".join(dialogue_in_words[0:n]))[0] < 310:

                sorted_lines.append(" ".join(dialogue_in_words[0:n]))
                dialogue_in_words = dialogue_in_words[n:len(dialogue_in_words)]

                n = len(dialogue_in_words) + 1

            n -= 1

        bean = self.other_bean.meta.display_name if speaker else self.player.meta.display_name

        self.text = [
            gui_components.Label(
                self.text_x + 20,
                n * self.body_font.get_linesize() + self.text_y + 49,
                sorted_lines[n], False, 20, constants.BLACK)
            for n in range(len(sorted_lines))
        ] + [
            gui_components.Label(self.text_x + 20, self.text_y + 10, bean,
                                 False, 32, constants.BLACK)
        ]
Exemplo n.º 11
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()
Exemplo n.º 12
0
    def __init__(self, master, controller, x, y):

        InventoryDisplay.__init__(self, master, controller, x, y)

        self.id = "item_select"

        self.selected_item = 0

        self.pointer = icons.ArrowPointer(
            self.x + 10, self.y + 59 + (40 * self.selected_item))

        self.title = gui_components.Label(self.x + 9, self.y, "Item Select",
                                          False, 32, constants.BLACK)
        self.press_space = gui_components.Label(self.x + 211, self.y,
                                                "<Space to Select>", False, 32,
                                                constants.BLACK)

        self.components = [
            self.background, self.title, self.press_space, self.pointer
        ] + self.labels + self.item_images
Exemplo n.º 13
0
    def __init__(self, master, controller, x, y):

        self.master = master
        self.controller = controller

        self.save_engine = self.master.master.save_engine

        self.x = x
        self.y = y

        self.id = "save_select"

        self.selected_save = 0

        self.images = menu_image_loader.load_images()

        self.saves = self.save_engine.saves

        self.background = gui_components.Fill(self.x, self.y, 482, 362,
                                              constants.GUI_BACKING)
        self.background_fill = gui_components.Fill(self.x + 212, self.y + 6,
                                                   264, 350,
                                                   constants.GUI_FILL)

        self.save_labels = [
            gui_components.Label(self.x + 235, self.y + 2 + (44 * n),
                                 self.saves[n], False, 36, constants.BLACK)
            for n in range(len(self.saves))
        ]

        self.arrow = icons.ArrowPointer(
            self.x + 222, self.y + 18 + (44 * self.selected_save))

        self.new_save_button = gui_components.Button(
            self.images["new_save_button"], self.x + 7, self.y + 7,
            lambda: self.callback(0))
        self.load_save_button = gui_components.Button(
            self.images["load_save_button"], self.x + 7, self.y + 95,
            lambda: self.callback(1))
        self.delete_save_button = gui_components.Button(
            self.images["delete_save_button"], self.x + 7, self.y + 183,
            lambda: self.callback(2))
        self.cancel_button = gui_components.Button(
            self.images["cancel_save_button"], self.x + 7, self.y + 271,
            lambda: self.callback(3))

        self.buttons = [
            self.new_save_button, self.load_save_button,
            self.delete_save_button, self.cancel_button
        ]

        self.components = [self.background, self.background_fill, self.arrow
                           ] + self.save_labels + self.buttons
Exemplo n.º 14
0
    def refresh(self):

        self.save_engine.refresh()
        self.saves = self.save_engine.saves

        self.save_labels = [
            gui_components.Label(self.x + 235, self.y + 2 + (44 * n),
                                 self.saves[n], False, 36, constants.BLACK)
            for n in range(len(self.saves))
        ]

        self.components = [self.background, self.background_fill, self.arrow
                           ] + self.save_labels + self.buttons
Exemplo n.º 15
0
    def __init__(self, master, controller, player, x, y):

        ItemSelect.__init__(self, master, controller, x, y)

        self.id = "healing_display"
        self.player_ref = player
        self.player = player.beans[self.controller.get_component(
            "health_display").active_bean_stat]

        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]

        self.refresh()
        self.master.stop_moving()
Exemplo n.º 16
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
Exemplo n.º 17
0
    def __init__(self):

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

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

        # Set the title on the window
        pygame.display.set_caption("Bean RPG")

        self.clock = pygame.time.Clock()

        self.load_components()

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

        self.game_exit = False

        self.chunk_controller = chunks.ChunkController(self, 16320, 66240)
        self.duel_controller = duel_controller.DuelController(self)

        self.menu = menu.MainMenu(self)

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

        self.loading_screen = gui_components.Fade()
        self.loading_screen.image = tools.combine_images(
            (self.loading_screen,
             gui_components.Label(340, 322, "Loading...", False, 64)))
        self.loading_screen.set_opacity(0)

        self.game_mode = 2
        self.full_screen = False

        self.fade = 0
        self.new_game_mode = -1

        self.controllers = [
            self.chunk_controller, self.duel_controller, self.menu
        ]
Exemplo n.º 18
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
Exemplo n.º 19
0
    def update(self):

        for event in pygame.event.get():
            if event.type == QUIT:

                self.master.close_save()

                self.master.game_exit = True

            elif event.type == constants.MUSIC_START_EVENT:

                if not self.master.sound_engine.playing_sound("music"):

                    new_music = random.choice(self.master.sound_engine.music)

                    while new_music == self.master.last_song:
                        new_music = random.choice(self.master.sound_engine.music)

                    self.master.last_song = new_music

                    self.master.sound_engine.queue_sound((new_music, 0))

            elif event.type == KEYUP:

                if event.key == K_ESCAPE:
                    self.master.game_exit = True

                elif event.key == K_F11:
                    self.master.set_full_screen()

            if self.hud_open:
                self.hud.get_component("item_select").handle_event(event)

        if self.game_won:
            if self.game_won_counter > 0:
                self.game_won_counter -= 1
            else:
                if not self.shown_win:

                    self.shown_win = True
                    self.game_won_counter = 120

                    if not self.retreat:
                        self.winner_label = gui_components.Label(480, 280, "{} won!".format(self.winner),
                                                                 True, 72, constants.BLACK)
                    else:
                        if self.winner == "Player":
                            self.winner_label = gui_components.Label(480, 280, "The Opponent Retreated!",
                                                                     True, 72, constants.BLACK)
                        else:
                            self.winner_label = gui_components.Label(480, 280, "You Retreated!",
                                                                     True, 72, constants.BLACK)

                    self.text.append(self.winner_label)
                else:
                    self.master.switch_to(0)

        [button.set_on() for button in self.buttons]

        if self.hud_open:
            self.hud.update()

            self.attack_main_button.set_off()
            self.attack_alt_button.set_off()
            self.retreat_button.set_off()
        else:
            if self.player.energy - moves[self.player.meta.moves[0]]["energy"] < 0:
                self.attack_main_button.set_off()
            else:
                self.attack_main_button.set_on()
            if self.player.energy - moves[self.player.meta.moves[1]]["energy"] < 0:
                self.attack_alt_button.set_off()
            else:
                self.attack_alt_button.set_on()
            if not len(list(self.master.story_tracker.inventory.items())):
                self.item_button.set_off()
            else:
                self.item_button.set_on()

        [button.update(not self.turn and not self.turn_cool_down) for button in self.buttons]

        if self.turn_cool_down > 0:
            self.turn_cool_down -= 1

        if self.turn == 1 and not self.turn_cool_down and not self.game_won:

            possible_moves = [0, 1]

            if self.enemy.energy - moves[self.enemy.meta.moves[0]]["energy"] < 0:
                possible_moves.remove(0)
            if self.enemy.energy - moves[self.enemy.meta.moves[1]]["energy"] < 0:
                possible_moves.remove(1)

            if not len(possible_moves):
                self.end_duel("Player", True)
            else:

                move_no = random.choice([0, 1])

                self.player.meta.damage(self.enemy.meta.get_attack_damage(move_no))
                self.enemy.energy -= moves[self.enemy.meta.moves[move_no]]["energy"]

                if self.player.meta.hp <= 0:
                    self.player.meta.hp = 0

                    self.end_duel("Opponent", False)

                self.enemy.meta.xp_gain(moves[self.enemy.meta.moves[move_no]]["xp"])

                move = moves[self.enemy.meta.moves[move_no]]["effects"]

                if moves[self.enemy.meta.moves[move_no]]["name"] in constants.shake_moves:
                    move = move.format("-")
                elif moves[self.enemy.meta.moves[move_no]]["name"] in constants.positional_moves:
                    move = move.format(220, 520)
                elif moves[self.enemy.meta.moves[move_no]]["name"] in constants.both_moves:
                    move = move.format(750, 170, "-")
                exec(move)

                self.turn = 0
                self.turn_cool_down = constants.turn_cool_down

        self.shake_players()

        self.player.shadow.update()
        self.enemy.shadow.update()

        self.update_gui_components()
Exemplo n.º 20
0
    def __init__(self, master):

        self.master = master

        self.scenes = story_data.scenes

        self.scene_updates = {
            "old_man": self.update_fisherman,
            "fisherman2": self.update_duel_fisherman,
            "fisherman_duel1": self.update_duel_fisherman,
            "villager1": self.set_unimportant,
            "villager2": self.set_unimportant,
            "villager3": self.set_unimportant,
            "villager4": self.set_unimportant,
            "villager5": self.set_unimportant,
            "villager6": self.set_unimportant,
            "villager7": self.set_unimportant,
            "villager8": self.set_unimportant,
            "old_man2": self.update_north,
            "north_bean": self.update_village_attack,
            "help_village_bean": self.update_evil_beans_village,
            "dan": self.add_dan_to_team,
            "hermit": self.update_hermit,
            "lake_warning": self.update_lake_warning,
            "wizard": self.update_wizard
        }

        self.background = pygame.image.load(
            "src/resources/dialogue_background.png").convert()

        self.body_font = constants.load_font(20, False)

        self.player = None
        self.other_bean = None

        self.player_ref = None
        self.other_bean_ref = None

        self.other_text_x = 197
        self.other_text_y = 48

        self.player_text_x = 429
        self.player_text_y = 392

        self.text_x = self.other_text_x
        self.text_y = self.other_text_y

        self.text_box_background = gui_components.Fill(self.text_x,
                                                       self.text_y, 350, 262,
                                                       constants.GUI_BACKING)
        self.text_box_fill = gui_components.Fill(self.text_x + 10,
                                                 self.text_y + 10, 330, 242,
                                                 constants.GUI_FILL)

        self.press_space = gui_components.Label(self.text_x + 51,
                                                self.text_y + 199,
                                                "Press Space to Continue",
                                                False, 20, constants.BLACK)
        self.press_left = gui_components.Label(self.text_x + 63,
                                               self.text_y + 223,
                                               "Left Arrow to go Back", False,
                                               20, constants.BLACK)

        self.components = [
            self.text_box_background, self.text_box_fill, self.press_space,
            self.press_left
        ]

        self.text = []

        self.scene = ""
        self.current_scene = []
        self.scene_progress = 0

        self.exit_func = None
        self.after_controller = -1

        self.first = True
Exemplo n.º 21
0
    def __init__(self, master):

        self.master = master

        self.brain = brain.Brain(12, 4)
        self.particle_engine = self.master.particle_engine

        self.images = load_images()

        self.background = self.images["background"]

        self.attack_main_button = gui_components.Button(
            self.images["attack_main_button"], 508, 584,
            lambda: self.callback(0))
        self.attack_alt_button = gui_components.Button(
            self.images["attack_alt_button"], 730, 584,
            lambda: self.callback(1))
        self.item_button = gui_components.Button(self.images["item_button"],
                                                 508, 645,
                                                 lambda: self.callback(2))
        self.retreat_button = gui_components.Button(
            self.images["retreat_button"], 730, 645, lambda: self.callback(3))

        self.buttons = [
            self.attack_main_button, self.attack_alt_button, self.item_button,
            self.retreat_button
        ]

        self.player = None
        self.enemy = None

        self.player_hp_bar = gui_components.ProgressBar(
            563, 379, 282, 30,
            [constants.HEALTH_BAR_RED, constants.HEALTH_BAR_GREEN])
        self.enemy_hp_bar = gui_components.ProgressBar(
            81, 38, 282, 30,
            [constants.HEALTH_BAR_RED, constants.HEALTH_BAR_GREEN])

        self.player_xp_bar = gui_components.ProgressBar(
            563, 519, 282, 30, [constants.XP_BAR_BLUE, constants.XP_BAR_CYAN])
        self.enemy_xp_bar = gui_components.ProgressBar(
            81, 108, 282, 30, [constants.XP_BAR_BLUE, constants.XP_BAR_CYAN])

        self.player_energy_bar = gui_components.ProgressBar(
            563, 449, 282, 30,
            [constants.ENERGY_BAR_ORANGE, constants.ENERGY_BAR_YELLOW])

        self.progress_bars = [
            self.player_hp_bar, self.enemy_hp_bar, self.player_xp_bar,
            self.enemy_xp_bar, self.player_energy_bar
        ]

        self.player_hp_label = gui_components.Label(857, 359, "")
        self.enemy_hp_label = gui_components.Label(373, 18, "")

        self.player_xp_label = gui_components.Label(857, 500, "")
        self.enemy_xp_label = gui_components.Label(373, 89, "")
        self.player_energy_label = gui_components.Label(857, 429, "")

        self.player_level_label = gui_components.Label(649, 499, "")
        self.enemy_level_label = gui_components.Label(160, 88, "")

        self.attack_main_label = None
        self.attack_alt_label = None

        self.player_name_label = None
        self.enemy_name_label = None

        self.winner_label = None

        self.text = [
            self.player_hp_label, self.enemy_hp_label, self.player_xp_label,
            self.enemy_xp_label, self.player_energy_label,
            self.player_level_label, self.enemy_level_label
        ]

        self.turn = 0
        self.turn_cool_down = 50

        self.game_won = False
        self.game_won_counter = 0
        self.winner = ""
        self.shown_win = False
Exemplo n.º 22
0
    def update(self):

        for event in pygame.event.get():
            if event.type == QUIT:
                self.master.game_exit = True

            if event.type == KEYUP:

                if event.key == K_F11:
                    self.master.set_full_screen()

        if self.game_won:
            if self.game_won_counter > 0:
                self.game_won_counter -= 1
            else:
                if not self.shown_win:

                    self.shown_win = True
                    self.game_won_counter = 120

                    self.winner_label = gui_components.Label(
                        480, 280, "{} won!".format(self.winner), True, 128,
                        constants.BLACK)
                    self.text.append(self.winner_label)
                else:
                    self.master.switch_to(0)

        if self.player.energy - moves[self.player.meta.moves[0]]["energy"] < 0:
            self.attack_main_button.set_off()
        else:
            self.attack_main_button.set_on()
        if self.player.energy - moves[self.player.meta.moves[1]]["energy"] < 0:
            self.attack_alt_button.set_off()
        else:
            self.attack_alt_button.set_on()

        [
            button.update(not self.turn and not self.turn_cool_down)
            for button in self.buttons
        ]

        if self.turn_cool_down > 0:
            self.turn_cool_down -= 1

        if self.turn == 1 and not self.turn_cool_down and not self.game_won:

            possible_moves = [0, 1, 2, 3]

            if self.enemy.energy - moves[
                    self.enemy.meta.moves[0]]["energy"] < 0:
                possible_moves.remove(0)
            if self.enemy.energy - moves[
                    self.enemy.meta.moves[1]]["energy"] < 0:
                possible_moves.remove(1)

            move_no = self.get_opponent_move()

            while move_no not in possible_moves:
                move_no = self.get_opponent_move()

            if move_no < 2:
                self.player.meta.damage(
                    int(self.enemy.meta.attack *
                        moves[self.enemy.meta.moves[move_no]]["str_mod"]))
                self.enemy.energy -= moves[
                    self.enemy.meta.moves[move_no]]["energy"]

                if self.player.meta.hp <= 0:
                    self.player.meta.hp = 0

                    self.end_duel("Opponent")

                self.enemy.meta.xp_gain(
                    moves[self.enemy.meta.moves[move_no]]["xp"])

                move = moves[self.enemy.meta.moves[move_no]]["effects"]

                if moves[self.enemy.meta.
                         moves[move_no]]["name"] in constants.shake_moves:
                    move = move.format("-")
                elif moves[self.enemy.meta.moves[move_no]][
                        "name"] in constants.positional_moves:
                    move = move.format(220, 520)
                exec(move)

            elif move_no < 3:

                pass

            else:

                self.end_duel("Player")

            self.turn = 0
            self.turn_cool_down = constants.turn_cool_down

        self.shake_players()

        self.player.shadow.update()
        self.enemy.shadow.update()

        self.update_gui_components()
Exemplo n.º 23
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 = ""