def __init__(self, **kwargs): super(Client, self).__init__() self.listener = pyglet.media.listener # create window try: # try and create a window with multisampling (antialiasing) config = Config(sample_buffers=1, samples=4, depth_size=16, double_buffer=True) self.window = pyglet.window.Window(resizable=True, config=config, width=SCREEN_WIDTH, height=SCREEN_HEIGHT) except pyglet.window.NoSuchConfigException: # fall back to no multisampling for old hardware print "window configuration failed" self.window = pyglet.window.Window(resizable=True, width=SCREEN_WIDTH, height=SCREEN_HEIGHT) # register window events self.window.set_exclusive_mouse(True) self.on_draw = self.window.event(self.on_draw) self.on_key_press = self.window.event(self.on_key_press) self.on_key_release = self.window.event(self.on_key_release) self.on_mouse_press = self.window.event(self.on_mouse_press) self.on_mouse_release = self.window.event(self.on_mouse_release) self.on_resize = self.window.event(self.on_resize) self.keyboard = pyglet.window.key.KeyStateHandler() self.window.push_handlers(self.keyboard) # init graphics setup_opengl() # init misc? if self.hud is None: self.hud = Hud() #if self.sound is None: self.sound = Sound() # self.fps = FPSDisplay() # self.room.elements.append(self.fps) # self.fps_display = pyglet.clock.ClockDisplay() # see programming guide pg 48 # network must be last to avoid race condition with the initialization callback self.network = NetClient(callbacks={ "player_init": self.init_callback, "packed_room": self.packed_room_callback, "sound_play": self.sound_play_callback, "explosion": self.explosion_callback, "laser": self.laser_callback, "puff": self.puff_callback, "game_event": self.game_event }, **kwargs) # start game pyglet.clock.set_fps_limit(60) pyglet.clock.schedule(self.update) pyglet.app.run()