Exemple #1
0
class WorldTests(unittest.TestCase):
    def setUp(self):
        self.world = World()

    def test_particle_collision(self):
        p1 = LinearParticle(10, 10)
        p2 = LinearParticle(12, 10)
        p2.radius = p1.radius = 10

        self.world.bind(p1)
        self.world.bind(p2)
        self.world.update(0)

        self.assertEquals(p1.position.y, p2.position.y)
        self.assertEquals(p2.position.x - p1.position.x, 20)
        self.assertEquals(p1.collisions, 1)
        self.assertEquals(p2.collisions, 1)
        self.world.update(0)
        self.assertEquals(p1.collisions, 1)
        self.assertEquals(p2.collisions, 1)