def __init__(self, player, space, x=0, y=0, old_bro=None, *args, **kwargs): super(Bro, self).__init__(space, x = x, y = y, mass = Bro.MASS, friction = Bro.FRICTION, collision_type = Bro.COLLISION_TYPE, width = Bro.SIZE, height = Bro.SIZE, texture = resources.box) self.player = player self.color = player.color self.dead = False self.frozen = False self.player.bros.append(self) # Model state self.moving_left = False self.moving_right = False self.collide_left = False self.collide_right = False self.shapes_below = WeakSet() self._last_tile = None # get old bro values if old_bro is not None: self.moving_left = old_bro.moving_left self.moving_right = old_bro.moving_right self.last_tile = old_bro.last_tile
def __init__(self, device_name=None): super(OpenALDriver, self).__init__() # TODO devices must be enumerated on Windows, otherwise 1.0 context is # returned. self.device = interface.OpenALDevice(device_name) self.context = self.device.create_context() self.context.make_current() self.lock = threading.Lock() self._listener = OpenALListener(self) self._players = WeakSet() # Start worker thread self.worker = PlayerWorker() self.worker.start()
def __init__(self, x, y, space, *args, **kwargs): self.space = space super(Tile, self).__init__(space, x=x * Tile.SIZE, y=y * Tile.SIZE, angle=0, width=Tile.SIZE, height=Tile.SIZE, friction=Tile.FRICTION, collision_type=Tile.COLLISION_TYPE, mass=Tile.MASS, static=True, texture=resources.box) # random colour if random.random() < Tile.WHITE_RATIO: brightness = random.random( ) % Tile.BRIGHTNESS_RANGE + Tile.BRIGHTNESS_MIN self.rgb = brightness, brightness, brightness self.orig_color = self.rgb self.tints = WeakSet()
to get a list of the attached screens; these can then be queried for their sizes and virtual positions on the desktop. The size of a screen is determined by its current mode, which can be changed by the application; see the documentation for :class:`Screen`. .. versionadded:: 1.2 """ import sys from pyglet.app import WeakSet _is_epydoc = hasattr(sys, 'is_epydoc') and sys.is_epydoc _displays = WeakSet() """Set of all open displays. Instances of :class:`pyglet.canvas.Display` are automatically added to this set upon construction. The set uses weak references, so displays are removed from the set when they are no longer referenced. :type: :class:`WeakSet` """ def get_display(): """Get the default display device. If there is already a :class`~pyglet.canvas.Display`connection, that display will be returned. Otherwise, a default :class`~pyglet.canvas.Display`is created and returned. If multiple display connections are active, an arbitrary one is returned.
def __init__(self): self._players = WeakSet()