示例#1
0
 def main_loop(self):
     while self.running:
         time.sleep(0)
         now = time.monotonic()
         self.signal(events.Idle(now - self._last_idle_time))
         self._last_idle_time = now
         while self.events:
             self.publish()
示例#2
0
 def loop_once(self):
     if not self.entered:
         raise ValueError("Cannot run before things have started",
                          self.entered)
     now = time.monotonic()
     self.signal(events.Idle(now - self._last_idle_time))
     self._last_idle_time = now
     while self.events:
         self.publish()
def test_collider_on_idle_collisions(scene: CollisionsTestSceneOne,
                                     basic_collider: Collider):
    basic_collider.running = True
    basic_collider.primed = True
    basic_collider.on_idle(events.Idle(0.01, scene), None)

    sprite: CollideCounter
    for sprite, expect in scene.expect.items():
        assert sprite.collided_count == expect["count"], repr(sprite)
        assert sprite.collided_list == expect["sprites"], repr(sprite)
示例#4
0
    def loop_once(self):
        """
        Iterate once.

        If you're embedding :mod:`ppb` in an external event loop call once per
        loop.
        """
        if not self.entered:
            raise ValueError("Cannot run before things have started",
                             self.entered)
        now = get_time()
        self.signal(events.Idle(now - self._last_idle_time))
        self._last_idle_time = now
        while self.events:
            self.publish()