def tmpDebugWorldRemoveMe(): # THIS IS FOR DEBUG ONLY!! w = World(platformClock=reactor) w.time = 13500.0 w.name = "Debug" w.width = 800 w.height = 600 w.spawn = (100, 199) w.isDay = True w.worldSurface = 200 w.rockLayer = 400 topLeftTs = TileSection() for y in range(4): w.tileSections.append([]) for x in range(6): ts = TileSection() ts.x = x ts.y = y for ty in range(50, SECTION_HEIGHT): for tx in range(SECTION_WIDTH): ts.setTile(tx, ty, ironTile) w.tileSections[y].append(ts) return w
def readWorld(self): w = World() self.fileHandle = open(self.worldFilePath, 'rb') w.version = self.readInt32() worldNameLen = self.readUChar() w.name = self.fileHandle.read(worldNameLen) w.worldId = self.readInt32() w.leftWorld = self.readInt32() w.rightWorld = self.readInt32() w.topWorld = self.readInt32() w.bottomWorld = self.readInt32() w.height = self.readInt32() w.width = self.readInt32() spawnX = self.readInt32() spawnY = self.readInt32() w.spawn = (spawnX, spawnY) w.worldSurface = self.readDouble() w.rockLayer = self.readDouble() w.time = self.readDouble() w.isDay = self.readBoolean() w.moonPhase = self.readInt32() w.isBloodMoon = self.readBoolean() w.dungeonX = self.readInt32() w.dungeonY = self.readInt32() w.bossOneDowned = self.readBoolean() w.bossTwoDowned = self.readBoolean() w.bossThreeDowned = self.readBoolean() w.shadowOrbSmashed = self.readBoolean() w.spawnMeteor = self.readBoolean() w.shadowOrbCount = self.readUChar() w.invasionDelay = self.readInt32() w.invasionSize = self.readInt32() w.invasionType = self.readInt32() w.invasionX = self.readDouble() self.fileHandle.close() return w
def clear(): os.system( [ 'clear', 'cls' ][ os.name == 'nt' ] ) world = World(); plants.generate_at_random(world, PLANTS) if PRECALC > 0: print "Precalculating %i moves..." % PRECALC for x in range(PRECALC): world.iterate() world.turn = 0 for x in range(ANIMALS): world.spawn(Animal, randrange(world.WIDTH), randrange(world.HEIGHT), RandomBrain()) x = '' while True: print world print "Turn", world.turn, "Animals", len([actor for actor in world.actors.values() if actor.DESCRIPTION == "animal"]) if AUTO: pass #time.sleep(0.05) else: x = raw_input("press enter to continue, ctrl-c to quit") if PROFILE: clear() cProfile.run("for i in range(10): world.iterate()") else: world.iterate()