def test_tick_increments_world_time(self): from bGrease import World world = World(clock_factory=TestClock) self.assertEqual(world.time, 0) self.assertEqual(world.clock.ticks, 0) self.assertEqual(world.clock.time_func(), world.time) dt = 1.0/30.0 world.tick(dt) self.assertAlmostEqual(world.time, dt) self.assertEqual(world.clock.time_func(), world.time) self.assertEqual(world.clock.ticks, 1) world.tick(dt) self.assertAlmostEqual(world.time, dt*2) self.assertEqual(world.clock.time_func(), world.time) self.assertEqual(world.clock.ticks, 2)
def test_running(self): from bGrease import World world = World() self.assertTrue(world.running) self.assertEqual(world.time, 0) dt = 1.0/30.0 world.tick(dt) self.assertAlmostEqual(world.time, dt) world.running = False world.tick(dt) world.tick(dt) self.assertAlmostEqual(world.time, dt) world.running = True world.tick(dt) self.assertAlmostEqual(world.time, dt*2)