def __init__(self, chest_inventory, player, imageurl): super(ChestGUI, self).__init__(player, imageurl) self.chest_inventory = chest_inventory self.transfer_down_image = Images.load_imageurl("img/gui/arrow_down.png") self.transfer_up_image = Images.load_imageurl("img/gui/arrow_up.png") self.transfer_down_position = (self.left + GUI.SCALING * 5 / 8, self.top + GUI.SCALING * 5 / 8) self.transfer_up_position = (self.left + GUI.SCALING * 5 / 8, self.top + GUI.SCALING * 39 / 8)
def __init__(self, pos, text, effect, small = False): self.pos = pos self.text = text self.effect = effect self.pressed = False self.font = Game.get_font() if small: url_base = "img/gui/button_small" else: url_base = "img/gui/button" self.unpressed_image = Images.load_imageurl(url_base + "_up.png") self.hovered_image = Images.load_imageurl(url_base + "_hover.png") self.pressed_image = Images.load_imageurl(url_base + "_down.png")
def load_images_for(self, directory): img_idle_l = Images.load_imageurl("img/player/" + directory + "/idle.png") img_idle_r = Images.flip_horizontal(img_idle_l) imgs_idle = (img_idle_l, img_idle_r) img_swim_1_l = Images.load_imageurl("img/player/" + directory + "/swim1.png") img_swim_1_u = Images.rotate(img_swim_1_l, -90) img_swim_1_r = Images.flip_horizontal(img_swim_1_l) img_swim_1_d = Images.rotate(img_swim_1_l, 90) imgs_swim_1 = (img_swim_1_l, img_swim_1_u, img_swim_1_r, img_swim_1_d) img_swim_2_l = Images.load_imageurl("img/player/" + directory + "/swim2.png") img_swim_2_u = Images.rotate(img_swim_2_l, -90) img_swim_2_r = Images.flip_horizontal(img_swim_2_l) img_swim_2_d = Images.rotate(img_swim_2_l, 90) imgs_swim_2 = (img_swim_2_l, img_swim_2_u, img_swim_2_r, img_swim_2_d) return (imgs_idle, imgs_swim_1, imgs_swim_2)
def __init__(self, buttons, labels = [], background = False): self.mouse_pressed = False self.buttons = buttons self.labels = labels self.background = background if background: self.background_img = Images.load_imageurl("img/gui/menu_background.png")
def __init__(self, text, pos, small = False): self.text = text self.pos = pos if small: imgurl = "img/gui/label_small.png" else: imgurl = "img/gui/label.png" self.img = Images.load_imageurl(imgurl) self.font = Game.get_font()
def __init__(self): self.logo_image = Images.load_imageurl("img/title/logo.png") self.logo_x = Game.SCREEN_WIDTH / 2 - self.logo_image.get_width() / 2 self.logo_y = Game.SCREEN_HEIGHT * 1 // 5 self.back_image = Images.load_imageurl("img/title/back.png") self.back_width = self.back_image.get_width() self.bg_y = Game.SCREEN_HEIGHT - self.back_image.get_height() self.mid_image = Images.load_imageurl("img/title/mid.png") self.mid_width = self.mid_image.get_width() self.front_image = Images.load_imageurl("img/title/front.png") self.front_width = self.front_image.get_width() self.back_xs = [-self.back_width, 0, self.back_width] self.mid_xs = [-self.mid_width, 0, self.mid_width] self.front_xs = [-self.front_width, 0, self.front_width] play_button = Button.Button((Game.SCREEN_WIDTH / 2 - Button.WIDTH / 2, Game.SCREEN_HEIGHT * 8 // 15), "Start Game", "menu") if len(Game.get_worlds()) == 0: play_button.next_menu = WorldNameMenu(self) else: play_button.next_menu = WorldSelectMenu(self) options_button = Button.Button((Game.SCREEN_WIDTH / 2 - Button.WIDTH / 2, Game.SCREEN_HEIGHT * 10 // 15), "Options", "options") quit_button = Button.Button((Game.SCREEN_WIDTH / 2 - Button.WIDTH / 2, Game.SCREEN_HEIGHT * 12 // 15), "Quit", "quit") super().__init__([play_button, options_button, quit_button])
def load_items(): items_file = open("items.json", "r") global items items = json.load(items_file) items_file.close() for itemname in items.keys(): item = items[itemname] item["can_place"] = False if "class" not in item.keys(): item["class"] = "ItemStack" if isinstance(item["description"], str): item["description"] = [item["description"]] img = Images.load_imageurl(item["image"]) img_rotated = Images.rotate(img, 90) item_images[itemname] = [img, Images.flip_horizontal(img), img_rotated, Images.flip_horizontal(img_rotated), Images.flip_completely(img)]
def __init__(self, player, imageurl): super(HotbarGUI, self).__init__(imageurl) self.player = player self.img_heart_full = Images.load_imageurl("img/gui/heart.png") self.img_heart_empty = Images.load_imageurl("img/gui/heart_empty.png")
def __init__(self, imageurl): self.img = Images.load_imageurl(imageurl) self.width = self.img.get_width() self.height = self.img.get_height()
def load_image(self): img = Images.load_imageurl(self.imageurl) self.img = pygame.Surface((Game.BLOCK_SIZE * Game.SCALE, Game.BLOCK_SIZE * Game.SCALE), pygame.SRCALPHA, 32).convert_alpha() self.img.blit(img, (0, 0))
def load_image(self): self.img = Images.load_imageurl(self.imageurl)