Example #1
0
def load_souces():
    global LEFT_SPRITES, RIGHT_SPRITES, UP_SPRITES, DOWN_SPRITES, LEFT_STOP_SPRITES, RIGHT_STOP_SPRITES
    LEFT_SPRITES = load_image(['1.png', '2.png', '3.png', '4.png', '5.png', '6.png', '7.png', '8.png'], alpha_channel=True)
    RIGHT_SPRITES = load_image(['1.1.png', '2.1.png', '3.1.png', '4.1.png',
                                '5.1.png', '6.1.png', '7.1.png', '8.1.png'], alpha_channel=True)
    UP_SPRITES = LEFT_SPRITES
    DOWN_SPRITES = RIGHT_SPRITES
    LEFT_STOP_SPRITES = load_image('1.png', path=IMAGE_PATH, alpha_channel=True)
    RIGHT_STOP_SPRITES = load_image('1.1.png', alpha_channel=True)
Example #2
0
 def __init__(self, x, y,  picture, height=False):
     sprite.Sprite.__init__(self)
     self.image = load_image(picture, alpha_channel=True)
     if height:
         self.rect = Rect(x, y, self.image.get_rect().width, height)
         self.area = Rect((x + 10), (y + 10), (self.image.get_rect().width + 10), (height + 10))
     else:
         self.rect = False
         self.area = Rect((x + 10), (y + 10), (self.image.get_rect().width + 10),
                          (self.image.get_rect().height + 10))
         self.pos = (x, y)
Example #3
0
 def __init__(self, x, y,  picture, height=False):
     sprite.Sprite.__init__(self)
     self.image = load_image(picture, path=IMAGE_PATH, alpha_channel=True)
     if height:
         self.type = "touchable"
         self.rect = Rect(x, y, self.image.get_rect().width, height)
         self.area = Rect((x - 10), (y - 10), (self.image.get_rect().width + 20), (height + 20))
     else:
         self.type = "untouchable"
         self.rect = self.image.get_rect()
         self.rect.x, self.rect.y = x, y
         self.area = Rect((x - 10), (y - 10), (self.rect.width + 20), (self.rect.height + 20))
Example #4
0
    def __init__(self, description, render_list):
        self.description = description
        self.render_list = render_list

        if description:
            self.obj_list = {}
            self.index = len(self.render_list) + 1
            self.image = load_image(description["image"][0], path=IMAGE_PATH)
            self.pos_rect = self.image.get_rect()
            self.rect = pygame.Rect((self.image.get_rect().x, self.image.get_rect().y),
                                    (self.image.get_rect().width, description["height"]))

            self.a = self.pos_rect.center[1] - self.rect.center[1]
        else:
            self.rect = pygame.Rect(10, 10, 0, 0)
            self.pos_rect = self.rect
Example #5
0
def map_loader(json_map, objects_descr):
    """
    :param json_map: Карта в формате json
    :param objects_descr: Описания предметов в формате json
    :return: Список словарей с объектами и функциями (если есть), бэкграунд
    и стартовую позицию персонажа (кортеж)
    """
    obj_list = []

    for dic in json_map:
        if dic["type"] == "description":
            start_pos = dic["start_player_pos"]

        if dic["type"] == "background":
            # x = y = 0
            # image = dic["image"]
            # back = StaticObject(x, y, image)
            back = {"surface": load_image(dic["image"], path=IMAGE_PATH), "address": dic["image"],
                    "pos": (0, 0)}

        if dic["type"] == "object":
            x = dic['pos'][0]
            y = dic['pos'][1]
            for obj in objects_descr[0]["objects"]:
                if dic['name'] == obj['name']:
                    image = obj['image'][0]
                    if obj['type'] == 'touchable':
                        height = obj['height']
                    else:
                        height = False

            if dic["name"] == "chest":
                new_obj = Chest(dic["argument"], x, y, image, height=height)
            else:
                new_obj = StaticObject(x, y, image, height=height)
            obj_dict = {"object": new_obj, "argument": dic["argument"],
                        "index": dic["index"], "type": dic["type"], "name": dic["name"]}

            obj_list.append(obj_dict)

    return obj_list, back, start_pos
Example #6
0
 def __init__(self):
     self.image = load_image('locker.png', path='../Pictures/', alpha_channel=True)
     self.rect = self.image.get_rect()