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]
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
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
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
def __init__(self, master, controller, x, y): self.master = master self.controller = controller self.x = x self.y = y self.id = "options_menu" self.selected_button = 0 self.images = menu_image_loader.load_images() self.background = gui_components.Fill(self.x, self.y, 260, 500, constants.GUI_BACKING) self.background_fill = gui_components.Fill(self.x + 5, self.y + 5, 250, 490, constants.GUI_FILL) self.smoothest_button = gui_components.Button( self.images["smoothest_button"], self.x + 21, self.y + (97 * 0) + 10, lambda: self.callback(0)) self.smooth_button = gui_components.Button( self.images["smooth_button"], self.x + 21, self.y + (97 * 1) + 10, lambda: self.callback(1)) self.fast_button = gui_components.Button(self.images["fast_button"], self.x + 21, self.y + (97 * 2) + 10, lambda: self.callback(2)) self.fastest_button = gui_components.Button( self.images["fastest_button"], self.x + 21, self.y + (97 * 3) + 10, lambda: self.callback(3)) self.close_button = gui_components.Button(self.images["close_button"], self.x + 21, self.y + (97 * 4) + 10, lambda: self.callback(4)) self.buttons = [ self.smoothest_button, self.smooth_button, self.fast_button, self.fastest_button, self.close_button ] self.components = [self.background, self.background_fill ] + self.buttons
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
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
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
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
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 = ""