def create_plants(map, plant_count, size=2): for l in range(plant_count): current = map.randomTile() for i in range(size): neighbors = map.getNeighbors(current.point.x, current.point.y) if current.terrain.passable and pygsty.models.model_repository.is_vacant((current.x, current.y)): models.statics.Flower((current.x, current.y)) current = random.choice(neighbors)
def create_forest(map, forest_count, size): for l in range(forest_count): forest_type = random.choice(models.statics.tree_types) current = map.randomTile() while not current.terrain.passable: current = map.randomTile() for i in range(size): if current.terrain.passable and pygsty.models.model_repository.is_vacant((current.x, current.y)): pygsty.logger.info("Adding tree to {}".format(current)) models.statics.Tree((current.x, current.y), forest_type) neighbors = map.getNeighbors(current.point.x, current.point.y) current = random.choice(neighbors) def find_trees(test_obj): return type(test_obj) is models.statics.Tree trees = pygsty.models.model_repository.find_all(find_trees) for t in trees: t.update_sprite()