Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- __version__ = "0.1.0"
- class GameCore(object):
- def __init__(self,conf=None): # initialize game
- self.conf = conf
- self.version = __version__
- self.running = True
- self.last_loop_time = time.time()
- def receive_updates(self): # get updates from the server connection thread
- pass
- def update_game(self,delta_time): # update the game's object states
- pass
- def user_input(self): # handle user input
- pass
- def send_updates(self): # pass relevant updates to the server connection thread
- pass
- def render(self): # render the current state of the game
- pass
- def run(self):
- delta_time = 0
- while running:
- # update everything
- self.receive_updates()
- self.update_game(delta_time)
- self.user_input()
- self.send_updates()
- self.render()
- # update delta_time (this keeps track of how much time has passed so that update_game() can be framerate independent)
- delta_time = time.time() - self.last_loop_time
- self.last_loop_time = time.time()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement