コード例 #1
0
    def get_inventory_surface(self):
        wrapper = rectangle_surface(512, 64, color=(171, 176, 186), border_width=2)
        item_container = [rectangle_surface(48, 48, color=(121, 125, 132), border_width=3 if i == self.selected_slot else 1) for i in range(9)]
        dummy_item = ItemEntity(self.game)
        dummy_item.set_position(0,0)
        dummy_item.absolute = True
        for item in self.inventory:
            dummy_item.draw_on(item_container[0])

        for i in range(9):
            wrapper.blit(item_container[i], (8*(i+1) + i * 48, wrapper.get_height()/2 - item_container[i].get_height()/2))
        return wrapper
コード例 #2
0
 def resize(self, w, h):
     self.height = int(h)
     self.width = int(w)
     if self.parent is None:
         self.debug_surface = rectangle_surface(self.width,
                                                self.height,
                                                color=(255, 255, 255, 128))
     elif self.parent.has_property(Property.COLLISION_WALL):
         self.debug_surface = rectangle_surface(self.width,
                                                self.height,
                                                color=(0, 255, 0, 128))
     else:
         self.debug_surface = rectangle_surface(self.width,
                                                self.height,
                                                color=(255, 255, 255, 128))
コード例 #3
0
    def __init__(self, x, y, w, h):
        Rectangle.__init__(self, x, y, w, h)
        CollisionBody.__init__(self)

        self.debug_surface = rectangle_surface(self.width,
                                               self.height,
                                               color=(255, 255, 255, 128))
コード例 #4
0
ファイル: GUI.py プロジェクト: yyyair/framework3
 def draw_on(self, surface):
     if self.update_cache or self.container is None:
         self.container = rectangle_surface(self.width,
                                            self.height,
                                            border_width=1)
         self.update_cache = False
     container = rectangle_surface(self.width, self.height, border_width=1)
     for component in self.components:
         component_surface = rectangle_surface(component.width,
                                               component.height,
                                               border_width=2,
                                               color=(255, 0, 0))
         #container.blit(component_surface, (component.x - self.x, component.y - self.y))
         component.set_position(component.x - self.x, component.y - self.y)
         component.draw_on(container)
         component.set_position(component.x + self.x, component.y + self.y)
     surface.blit(container, (self.x, self.y))
コード例 #5
0
ファイル: GUI.py プロジェクト: yyyair/framework3
    def draw_on(self, surface):
        background_surface = None

        if self.cache and (self.update_cache or self.cached_container is None):
            self.cached_container = rectangle_surface(self.width,
                                                      self.height,
                                                      border_width=3)
            self.update_cache = False

        background_surface = self.cached_container.copy(
        ) if self.cache else rectangle_surface(
            self.width, self.height, border_width=3)
        lines = self.value.split("\n")
        render_lines = [
            self.font.render(line, 1, self.color) for line in lines
        ]
        x = self.get_x_offset(render_lines[0])
        y = self.get_y_offset(render_lines[0])
        #background_surface = rectangle_surface(self.width, self.height, border_width=3)
        line_space = 16
        # Determine when to draw pointer
        ptr_count = self.pointer
        for line_id in range(len(lines)):
            rendered_line = render_lines[line_id]
            raw_line = lines[line_id]

            background_surface.blit(rendered_line, (x, y))

            if self.active and self.show_pointer and len(
                    raw_line) >= ptr_count >= 0:

                before_ptr = raw_line[0:ptr_count]

                before_render = self.font.render(before_ptr, 1, (0, 0, 0))

                ptr_surface = pygame.Surface((1, before_render.get_height()),
                                             pygame.SRCALPHA)
                ptr_surface.fill((0, 0, 0))

                ptr_x = x + before_render.get_width()
                ptr_y = y

                background_surface.blit(ptr_surface, (ptr_x, ptr_y))
            y += line_space
            ptr_count -= len(raw_line) + 1
        surface.blit(background_surface, (self.x, self.y))
コード例 #6
0
ファイル: GUI.py プロジェクト: yyyair/framework3
    def draw_on(self, surface):
        container = rectangle_surface(self.width,
                                      self.height,
                                      border_width=0,
                                      color=(255, 0, 0))

        old_x, old_y = self.x, self.y
        self.set_position(0, 0)
        GUIBundle.draw_on(self, container)
        self.set_position(old_x, old_y)
        s_width, s_height = surface.get_size()
        x, y = s_width / 2 - self.width / 2, s_height / 2 - self.height / 2
        surface.blit(container, (self.x, self.y))
コード例 #7
0
ファイル: GUI.py プロジェクト: yyyair/framework3
    def create_surface(self):
        #text = self.game.resources.load_font("default")
        font = self.font
        dummy_surface = pygame.Surface((self.width, self.height),
                                       pygame.SRCALPHA)
        text = font.render(self.get_value(), 1, self.color)

        # Vertical alignement (y)
        y = self.get_y_offset(text)

        # Horizontal alignment (x)
        x = self.get_x_offset(text)

        if self.show_frame:
            dummy_surface.blit(
                rectangle_surface(self.width, self.height, border_width=2),
                (0, 0))
        dummy_surface.blit(text, (x, y))
        return dummy_surface
コード例 #8
0
ファイル: GUI.py プロジェクト: yyyair/framework3
    def draw_on(self, surface):
        container = None
        scroller = None
        # Update cache
        if self.cache and (self.container_surface is None
                           or self.update_cache):
            self.container_surface = self.create_container()
            self.update_cache = False

        container = self.container_surface.copy(
        ) if self.cache else self.create_container()
        scroller = rectangle_surface(self.width - 2,
                                     max(self.min_height,
                                         self.height / (self.max_index + 1)),
                                     border_width=self.bar_border,
                                     color=self.bar_color)
        y = self.height * self.current_index / (self.max_index + 1)
        scroller_y = (y + 1 if
                      ((self.y + 1 + self.height) - y) > self.min_height else
                      self.y + self.height - self.min_height - 1)
        container.blit(scroller, (1, scroller_y))
        surface.blit(container, (self.x, self.y))
コード例 #9
0
ファイル: GUI.py プロジェクト: yyyair/framework3
 def create_container(self):
     return rectangle_surface(self.width,
                              self.height,
                              border_width=self.container_border,
                              color=self.container_color)
コード例 #10
0
ファイル: GUI.py プロジェクト: yyyair/framework3
 def draw_on(self, surface):
     box = pygame.Surface((self.width, self.height), pygame.SRCALPHA)
     box.fill((0 if self.active else 255, 0, 255))
     color = (0 if self.active else 255, 0, 255)
     box = rectangle_surface(self.height, self.width, color, border_width=3)
     surface.blit(box, (self.x, self.y))