core.py 558 B

1234567891011121314151617181920212223
  1. import yaml
  2. import _thread
  3. from . import server
  4. import time
  5. def main_loop():
  6. for player in list(server.players.values()):
  7. player.update(config, time.time() - main_loop.last_tick)
  8. main_loop.last_tick = time.time()
  9. time.sleep(1)
  10. main_loop.last_tick = time.time()
  11. if __name__ == '__main__':
  12. global config
  13. config = yaml.load(open("config/game.yaml"))['game']
  14. def run(*args):
  15. server.run_server(config)
  16. print("Websocket thread terminated.")
  17. _thread.start_new_thread(run, ())
  18. while 1:
  19. main_loop()