Пример #1
0
    def draw(self, backbuffer, interpol=0.0, time_sec=0.0):
        x = self.pos.x
        y = self.pos.y
        self.surf.draw(backbuffer, Vec2D(x, y), self.top_left)
        x += self.top_left.width
        for i in range(self.block_size.x):
            self.surf.draw(backbuffer, Vec2D(x, y), self.top_cen)
            x += self.top_cen.width
        self.surf.draw(backbuffer, Vec2D(x, y), self.top_right)

        y += self.top_left.height

        for j in range(self.block_size.y):
            x = self.pos.x
            self.surf.draw(backbuffer, Vec2D(x, y), self.mid_left)
            x += self.mid_left.width
            for i in range(self.block_size.x):
                self.surf.draw(backbuffer, Vec2D(x, y), self.mid_cen)
                x += self.mid_cen.width
            self.surf.draw(backbuffer, Vec2D(x, y), self.mid_right)

            y += self.mid_left.height

        x = self.pos.x
        self.surf.draw(backbuffer, Vec2D(x, y), self.bot_left)
        x += self.bot_left.width
        for i in range(self.block_size.x):
            self.surf.draw(backbuffer, Vec2D(x, y), self.bot_cen)
            x += self.bot_cen.width
        self.surf.draw(backbuffer, Vec2D(x, y), self.bot_right)
Пример #2
0
    def draw(self, surface, interpol, time_sec):
        val = (self.place.right - self.place.left) * self._value

        if self.button is not None:
            self.button.pos = Vec2D(self.place.left + val,
                                    self.place.top + self.place.height / 2)

        rect = Rectangle(0, 0, val, self.place.height)
        self.sprite.nr = 1
        self.sprite.draw(surface, self.place.pos, rect)

        rect = Rectangle(val, 0, self.place.width - val, self.place.height)
        self.sprite.nr = 0
        pos = self.place.pos + Vec2D(val, 0)
        self.sprite.draw(surface, pos, rect)

        Component.draw(self, surface, interpol, time_sec)
Пример #3
0
    def __init__(self, pos, sprite, button=None):
        size = sprite.get_size()
        Slider.__init__(self,
                        Rectangle.from_pos_size(pos, Vec2D(size[0], size[1])))

        self.sprite = sprite
        self.button = button

        if button is not None:
            self.add_subcomponent(button)

        self.delegate_active = self.button
Пример #4
0
    def __init__(self, sprite, pos=Vec2D(0, 0)):
        """Create a new instance

        sprite is a gfx.Sprite with 5 frames:
        normal, selected, normal-active, selected-active, disabled
        """
        Checkbox.__init__(self,
                          Rectangle(pos.x, pos.y, sprite.width, sprite.height))

        self.sprite = sprite
        self.sprite.nr = 1
        self.animTimer = PingPongTimer(20, 1, 3)
Пример #5
0
    def __init__(self, sprite, pos=Vec2D(0, 0)):
        """Create a new instance

        sprite is a gfx.Sprite with 3 frames: normal, active, disabled
        """
        Button.__init__(
            self,
            Rectangle(
                pos.x,  # - sprite.center.x,
                pos.y,  # - sprite.center.y,
                sprite.width,
                sprite.height))

        self.sprite = sprite
        self.sprite.nr = 0
        self.label = None
Пример #6
0
    def draw(self, surface, pos, rect=None):
        """Draw the sprite on the surface at pos

        pos is a Vec2D
        """
        sp_x = (self.nr % self.max_x) * self.width
        sp_y = (self.nr / self.max_x) * self.height

        sprite_rect = [sp_x, sp_y, self.width, self.height]

        if rect is not None:
            r = copy.copy(rect)
            r.pos = r.pos + Vec2D(sp_x, sp_y)
            sprite_rect = (Rectangle.from_tuple(sprite_rect) & r).get_tuple()

        self.surface.draw(surface, pos - self.center, sprite_rect)
Пример #7
0
    def draw(self, surface, pos, rect=None):
        """Draw this surface onto surface at pos

        pos is a Vec2D or (x,y) tuple
        """
        if isinstance(pos, tuple):
            pos = Vec2D(pos[0], pos[1])

        if isinstance(surface, pygame.Surface):
            if rect is not None:
                surface.blit(self.pysurf, pos.get_tuple(), rect)
            else:
                surface.blit(self.pysurf, pos.get_tuple())
        else:
            if rect is not None:
                surface.pysurf.blit(self.pysurf, pos.get_tuple(), rect)
            else:
                surface.pysurf.blit(self.pysurf, pos.get_tuple())
Пример #8
0
 def get_size(self):
     return Vec2D(self.get_width(), self.get_height())
Пример #9
0
 def set_block_size(self, x, y):
     self.block_size = Vec2D(x, y)
Пример #10
0
 def __init__(self):
     self.pos = Vec2D(0, 0)
     pass
Пример #11
0
 def __init__(self, surface, rect=None, offset=Vec2D(0, 0)):
     self.surface = surface
     self.rect = rect
     self.offset = offset
Пример #12
0
 def set_div(self, x_sprites, y_sprites):
     self.width = self.surface.get_width() / x_sprites
     self.height = self.surface.get_height() / y_sprites
     self.max_x = x_sprites
     self.center = Vec2D(self.width, self.height) / 2