2n2u

Untitled

Jan 26th, 2016
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. #!/usr/bin/python
  2. #----------------------------------------------------------------------#
  3.  
  4. ## IMPORTS ##
  5. import time
  6. from time import time
  7.  
  8. ### PANDA Imports ###
  9.  
  10. ## Server Imports ##
  11.  
  12. ########################################################################
  13.  
  14.  
  15. class GameManager():
  16.  
  17.     def __init__(self, _serverManager):
  18.         # Holder for clients
  19.         self.serverManager = _serverManager
  20.  
  21.         # Loop break?
  22.         self.gameRunning = True
  23.  
  24.     def start(self):
  25.         self.gameMainLoop()
  26.  
  27.     def stop(self):
  28.         pass # remove task
  29.  
  30.  
  31.     # make this a task and get rid of the 1st while
  32.     def gameMainLoop(self):
  33.  
  34.         timeRate = 1000 / 60
  35.         lastTime = 0
  36.        
  37.         '''
  38.        while( true )
  39.            check for client commands
  40.            sanity check client commands
  41.            run AI
  42.            move all entities
  43.            resolve collisions
  44.            sanity check world data
  45.            send updates about the game to the clients
  46.            handle client disconnects
  47.        end
  48.        '''
  49.         # while(True):
  50.         #     print ('server running')
  51.  
  52.         while (self.gameRunning):
  53.             time = time()
  54.  
  55.             self.gameSimulationTick(time, lastTime, timeRate)
  56.             self.gameNetworkUpdateTick()
  57.  
  58.     # This should run at 60Hz
  59.     def gameSimulationTick(self, _time, _lastTime, _timeRate):
  60.         while(_time > _lastTime):
  61.                
  62.                 _lastTime += _timeRate
  63.  
  64.         '''
  65.        game logic here?
  66.        '''
  67.  
  68.     # This should run at anything between 10Hz - 15Hz
  69.     def gameNetworkUpdateTick(self):
  70.         pass
Advertisement
Add Comment
Please, Sign In to add comment