class Game(object): FPS = 30 def __init__(self): pygame.init() pygame.display.set_caption("RPG Game") self.seed = 26281376 self.world = World(self.seed, SoundCache()) self.user = Player(self) self.view = Gameview(self.world, self.user, ImageCache(), self.debug) self.clock = pygame.time.Clock() self.renderTime = 0 self.processTime = 0 def run(self): while(True): self.clock.tick(Game.FPS) t = time.time() self.view.draw() self.renderTime = time.time() - t t = time.time() if not self.world.update(): continue if self.user.turn(): continue self.world.turn() self.user.save() self.processTime = time.time() - t def debug(self): msg = [] msg.append(['FPS: ' + str(int(self.clock.get_fps()))]) msg.append(['Mobs: ' + str(len(self.world.mobManager.mobs))]) msg.append(['Chunks: ' + str(len(self.world.chunkManager.chunkCache))]) msg.append(['Render: ' + str(int(self.renderTime * 1000)) + 'ms']) msg.append(['World: ' + str(int(self.processTime * 1000)) + 'ms']) msg.append(['Time: ' + str(self.world.time)]) return msg
''' Created on Jan 18, 2014 @author: anthony.lozano ''' from world import World if __name__ == '__main__': world = World(16,16,1, see_port="COM8") #world.carve_path() print world for i in range(20): world.communicate() input = raw_input() if input == "w": world.move(True) elif input == "a": world.turn(False) elif input == "d'": world.turn(True) elif input == "s": world.move(False)