Пример #1
0
        def get_objects(self, _map):

            for obj_name in object_list_prob['objects']:
                prop = object_list_prob['objects'][obj_name]
                for i in range(random.randint(prop['min-count'], prop['max-count'])):
                    coord = (random.randint(1, 38), random.randint(1, 10))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, 38),
                                     random.randint(1, 10))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 38),
                                         random.randint(1, 10))

                    self.objects.append(Objects.Ally(
                        prop['sprite'], prop['action'], coord))

            for obj_name in object_list_prob['ally']:
                prop = object_list_prob['ally'][obj_name]
                for i in range(random.randint(prop['min-count'], prop['max-count'])):
                    coord = (random.randint(1, 38), random.randint(1, 10))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, 38),
                                     random.randint(1, 10))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 38),
                                         random.randint(1, 10))
                    self.objects.append(Objects.Ally(
                        prop['sprite'], prop['action'], coord))

            for obj_name in object_list_prob['enemies']:
                prop = object_list_prob['enemies'][obj_name]
                for i in range(random.randint(0, 5)):
                    coord = (random.randint(1, 30), random.randint(1, 10))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, 30),
                                     random.randint(1, 10))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 30),
                                         random.randint(1, 10))

                    self.objects.append(Objects.Enemy(
                        prop['sprite'], prop, prop['experience'], coord))

            return self.objects
        def get_objects(self, _map):
            
            map_size = [len(_map[0]), len(_map)]
            for obj_name in object_list_prob['objects']:
                prop = object_list_prob['objects'][obj_name]
                for i in range(random.randint(prop['min-count'], prop['max-count'])):
                    coord = (random.randint(1, map_size[0] - 2),
                             random.randint(1, map_size[1] - 2))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, map_size[0] - 2),
                                     random.randint(1, map_size[1] - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, map_size[0] - 2),
                                         random.randint(1, map_size[1] - 2))
                    self.objects.append(Objects.Ally(
                        prop['sprite'], prop['action'], coord))

            for obj_name in object_list_prob['ally']:
                prop = object_list_prob['ally'][obj_name]
                for i in range(random.randint(prop['min-count'], prop['max-count'])):
                    coord = (random.randint(1, map_size[0] - 2),
                             random.randint(1, map_size[1] - 2))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, map_size[0] - 2),
                                     random.randint(1, map_size[1] - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, map_size[0] - 2),
                                         random.randint(1, map_size[1] - 2))
                    self.objects.append(Objects.Ally(
                        prop['sprite'], prop['action'], coord))
            
            for obj_name in self.config.keys():
                prop = object_list_prob['enemies'][obj_name]
                for i in range(self.config[obj_name]):
                    coord = (random.randint(1, map_size[0] - 2),
                             random.randint(1, map_size[1] - 2))
                    #coord = (3,3)
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, map_size[0] - 2),
                                     random.randint(1, map_size[1] - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, map_size[0] - 2),
                                         random.randint(1, map_size[1] - 2))

                    self.objects.append(Objects.Enemy(
                        prop['sprite'], prop, prop['experience'], prop['action'], coord))

            return self.objects
Пример #3
0
        def get_objects(self, _map):

            for obj_name in object_list_prob["objects"]:
                prop = object_list_prob["objects"][obj_name]
                for i in range(random.randint(prop["min-count"], prop["max-count"])):
                    coord = (random.randint(1, self.map_size - 2), random.randint(1, self.map_size - 2))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, self.map_size - 2),
                                     random.randint(1, self.map_size - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, self.map_size - 2),
                                         random.randint(1, self.map_size - 2))

                    self.objects.append(Objects.Ally(
                        obj_name, prop["sprite"], prop["action"], coord))

            for obj_name in object_list_prob["ally"]:
                prop = object_list_prob["ally"][obj_name]
                for i in range(random.randint(prop["min-count"], prop["max-count"])):
                    coord = (random.randint(1, self.map_size - 2), random.randint(1, self.map_size - 2))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, self.map_size - 2),
                                     random.randint(1, self.map_size - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, self.map_size - 2),
                                         random.randint(1, self.map_size - 2))
                    self.objects.append(Objects.Ally(
                        obj_name, prop["sprite"], prop["action"], coord))

            for obj_name in object_list_prob["enemies"]:
                prop = object_list_prob["enemies"][obj_name]
                for i in range(random.randint(1, 3)):
                    coord = (random.randint(1, self.map_size - 2),
                             random.randint(1, self.map_size - 2))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1, self.map_size - 2),
                                     random.randint(1, self.map_size - 2))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, self.map_size - 2),
                                         random.randint(1, self.map_size - 2))

                    self.objects.append(Objects.Enemy(
                        prop["sprite"], prop, prop["experience"], coord))

            return self.objects
Пример #4
0
 def get_objects(self, _map):
     prop = object_list_prob["objects"]["stairs"]
     for i in range(random.randint(prop["min-count"], prop["max-count"])):
         coord = (random.randint(1, self.map_size - 2), random.randint(1, self.map_size - 2))
         self.objects.append(Objects.Ally("stairs", prop["sprite"], prop["action"], coord))
     return self.objects
        def get_objects(self, _map):
            config = self.config

            # for obj_name in object_list_prob['objects']:
            for obj_name in set(object_list_prob['objects']) & set(
                    config.keys()):
                prop = object_list_prob['objects'][obj_name]
                for i in range(config[obj_name]):
                    coord = (random.randint(1, 39), random.randint(1, 39))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1,
                                                    39), random.randint(1, 39))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 39),
                                         random.randint(1, 39))

                    self.objects.append(
                        Objects.Ally(prop['sprite'], prop['action'], coord))

            for obj_name in set(object_list_prob['ally']) & set(config.keys()):
                prop = object_list_prob['ally'][obj_name]
                for i in range(config[obj_name]):
                    coord = (random.randint(1, 39), random.randint(1, 39))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1,
                                                    39), random.randint(1, 39))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 39),
                                         random.randint(1, 39))
                    self.objects.append(
                        Objects.Ally(prop['sprite'], prop['action'], coord))

            for obj_name in set(object_list_prob['enemies']) & set(
                    config.keys()):
                prop = object_list_prob['enemies'][obj_name]
                for i in range(config[obj_name]):
                    coord = (random.randint(1, 30), random.randint(1, 22))
                    intersect = True
                    while intersect:
                        intersect = False
                        if _map[coord[1]][coord[0]] == wall:
                            intersect = True
                            coord = (random.randint(1,
                                                    39), random.randint(1, 39))
                            continue
                        for obj in self.objects:
                            if coord == obj.position or coord == (1, 1):
                                intersect = True
                                coord = (random.randint(1, 39),
                                         random.randint(1, 39))

                    self.objects.append(
                        Objects.Enemy(prop['sprite'], prop, prop['experience'],
                                      coord))

            return self.objects