Ejemplo n.º 1
0
    def show_image(self, image, screen, pos, angle=0, center=False,
                   new_size=None, center_image=False,flip=False):
        if image is None:
            return
        try:
            sprite = image
            origin_pos = engine.get_origin_pos()
            screen_diff_ratio = engine.get_ratio()

            if new_size:
                text_size = None

                if isinstance(sprite, sfml.Sprite):
                    text_size = Vector2(sprite.texture.size)
                else:
                    text_size = new_size
                sprite.ratio = (new_size * screen_diff_ratio / text_size).get_tuple()
            if angle != 0:
                sprite.rotation = angle

            if isinstance(sprite, sfml.Sprite):
                if flip:
                    sprite.texture_rectangle = (sfml.Rectangle(sfml.Vector2(sprite.texture.width, 0), sfml.Vector2(-sprite.texture.width, sprite.texture.height)))
                else:
                    sprite.texture_rectangle = (sfml.Rectangle(sfml.Vector2(0, 0), sfml.Vector2(sprite.texture.width, sprite.texture.height)))
            sprite.position = (origin_pos+pos * screen_diff_ratio).get_int_tuple()
            screen.draw(sprite)

        except KeyError:
            pass
Ejemplo n.º 2
0
    def draw_rect(self, screen, screen_pos, rect, color, angle=0):
        drawing_rect = sfml.RectangleShape()
        origin_pos = engine.get_origin_pos()
        screen_diff_ratio = engine.get_ratio()
        drawing_rect.position = (origin_pos + ( rect.pos - screen_pos) * screen_diff_ratio).get_tuple()

        drawing_rect.rotation = angle
        drawing_rect.size = (rect.size * screen_diff_ratio).get_tuple()
        if len(color) == 4:
            drawing_rect.fill_color = sfml.Color(color[0], color[1], color[2], color[3])
        elif len(color) == 3:
            drawing_rect.fill_color = sfml.Color(color[0], color[1], color[2])
        self.buffer.draw(drawing_rect)
Ejemplo n.º 3
0
def get_mouse():
    """
    Return mouse state as
    position, (left, right,middle)
    """
    if CONST.render == 'sfml':
        mouse_pos = Vector2(sfml.Mouse.get_position())/engine.screen_diff_ratio+engine.get_origin_pos()
        return mouse_pos,\
               [sfml.Mouse.is_button_pressed(sfml.Mouse.LEFT),
                sfml.Mouse.is_button_pressed(sfml.Mouse.RIGHT),
                sfml.Mouse.is_button_pressed(sfml.Mouse.MIDDLE)]
    elif CONST.render == 'pookoo':
        return Vector2(pookoo.input.mouse.position()), [
            False,False,False
            ]
    elif CONST.render == 'kivy':
        return Vector2(), [False,False,False]