def __init__(self, x, y, world): to = TileObject.TileObject() to.tile = self self.tileObjects = [to] self.x = x self.y = y self.world = world
def step(self): if random.uniform(0, 1) < 0.00001: self.addTileObject(TileObject.Food()) for tileObject in self.tileObjects: # Tile objects can move during their step, and then get stepped again in their # new tile. So we use a boolean flag to keep that from happening. if tileObject._stepping: continue tileObject._stepping = True tileObject.step()
def create_map(levelfolder, overview_dict=None): if not overview_dict: overview_filename = levelfolder + '/overview.txt' overview_dict = read_overview_file(overview_filename) tilefilename = levelfolder + '/TileData.png' mapfilename = levelfolder + '/MapSprite.png' weather = overview_dict['weather'].split( ',') if 'weather' in overview_dict else [] currentMap = TileObject.MapObject(mapfilename, tilefilename, levelfolder, weather) return currentMap