How to use the classes.image_cache.ImageCache.add function in classes

To help you get started, we’ve selected a few classes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SodaCookie / rpeg / engine / loot_menu.py View on Github external
tmp_surface = Surface((77, 115), SRCALPHA)
        tmp_surface.fill((255,255,255,0))
        displacement = 0

        if self.gold:
            gold_back = ImageCache.add("images/ui/loot_gold.png", True)
            tmp_surface.blit(gold_back, (0, displacement))
            displacement += gold_back.get_height()

        if self.items:
            if self.gold:
                displacement -= 1
            loot_top = ImageCache.add("images/ui/loot_top.png", True)
            tmp_surface.blit(loot_top, (0, displacement))
            displacement += loot_top.get_height()
            loot_middle = ImageCache.add("images/ui/loot_middle.png")
            tmp_surface.blit(loot_middle, (0,displacement), (0, 0, loot_middle.get_width(),round(len(self.items)*loot_middle.get_height()/4)))
            displacement += round(len(self.items)*loot_middle.get_height()/4)
            loot_bottom = ImageCache.add("images/ui/loot_bottom.png", True)
            tmp_surface.blit(loot_bottom, (0, displacement))
            displacement += loot_top.get_height()

        chosen_back = tmp_surface
        back_position = (0, 10*view.SCALE)
        title_position = (0, 10*view.SCALE)
        button_position = (0, (displacement+13)*view.SCALE)

        self.add(Image(
            pos = back_position,
            surface = scale(chosen_back, tuple([z * view.SCALE for z in chosen_back.get_size()])),
            h_anchor = 0,
            v_anchor = 1,
github SodaCookie / rpeg / engine / main_menu.py View on Github external
def render(self):
        button = ImageCache.add("images/menu/button500x120.png")
        button_h = ImageCache.add("images/menu/button_h500x120.png")
        button_p = ImageCache.add("images/menu/button_p500x120.png")
        button_d = ImageCache.add("images/menu/button_d500x120.png")

        text_style = TextInfo(fontcolor=(255, 255, 255),
                              fontsize=50,
                              h_anchor=0,
                              v_anchor=0,
                              alignment=0)
        button_style = ButtonInfo(width=500, height=120,
                                  text_color=(255, 255, 255),
                                  h_text_color=(255, 255, 0),
                                  p_text_color=(0, 128, 0),
                                  d_text_color=(0, 0, 0),
                                  img=button,
                                  hovered_img=button_h,
                                  pressed_img=button_p,
                                  disabled_img=button_d,
                                  h_anchor=0,
github SodaCookie / rpeg / engine / monster_menu.py View on Github external
def __init__(self, game, render_info):
        Menu.__init__(self, "monster", (0, 0), game, render_info)
        controller.MouseController.__init__(self)
        controller.BattleController.__init__(self)

        self.health = scale(ImageCache.add("images/ui/health.png"), (128, 8))
        self.speed = scale(ImageCache.add("images/ui/speed.png"), (128, 8))
        self.text_style = TextInfo(fontcolor=(255,255,255),
                                   fontsize=16,
                                   alignment=-1,
                                   h_anchor=1,
                                   v_anchor=1,
                                   wrap=True,
                                   width=149*view.SCALE)

        self.monster_infos = []
        self.rendering_monsters = [] # for convenience
github SodaCookie / rpeg / engine / main_menu.py View on Github external
def render(self):
        button = ImageCache.add("images/menu/button500x120.png")
        button_h = ImageCache.add("images/menu/button_h500x120.png")
        button_p = ImageCache.add("images/menu/button_p500x120.png")
        button_d = ImageCache.add("images/menu/button_d500x120.png")

        text_style = TextInfo(fontcolor=(255, 255, 255),
                              fontsize=50,
                              h_anchor=0,
                              v_anchor=0,
                              alignment=0)
        button_style = ButtonInfo(width=500, height=120,
                                  text_color=(255, 255, 255),
                                  h_text_color=(255, 255, 0),
                                  p_text_color=(0, 128, 0),
                                  d_text_color=(0, 0, 0),
                                  img=button,
                                  hovered_img=button_h,
                                  pressed_img=button_p,
                                  disabled_img=button_d,
github SodaCookie / rpeg / engine / battle_info_menu.py View on Github external
def render(self):
        self.clear()

        if self.game.current_character:
            abilities = ImageCache.add("images/ui/abilities.png", True)
            abilities = scale(abilities, (abilities.get_width()*view.SCALE,
                abilities.get_height()*view.SCALE))
            portrait = ImageCache.add(self.game.current_character.portrait, True)
            portrait = scale(portrait, (portrait.get_width()*view.SCALE,
                portrait.get_height()*view.SCALE))

            self.add(Image((37*view.SCALE, 0),
                surface = portrait,
                h_anchor = 1,
                v_anchor = 1))

            self.add(Image((0, 0),
                surface = abilities,
                alpha = True,
                h_anchor = 1,
                v_anchor = 1))
github SodaCookie / rpeg / engine / travel_menu.py View on Github external
def __init__(self, game, render_info):
        super().__init__("travel", (6*view.SCALE, 10*view.SCALE), game, render_info)
        self.event_bg = ImageCache.add("images/ui/text_back1.png", True)
        self.current = None
        self.title_style = TextInfo(fontcolor=(255,255,255),
                                   fontsize=30,
                                   alignment=-1,
                                   h_anchor=1,
                                   v_anchor=-1,
                                   wrap=True,
                                   width=149*view.SCALE)

        self.text_style = TextInfo(fontcolor=(255,255,255),
                                   fontsize=16,
                                   alignment=-1,
                                   h_anchor=1,
                                   v_anchor=1,
                                   wrap=True,
                                   width=149*view.SCALE)