def test_add_and_delete_from_collection(self):
     self.instance.add_to_collections(['another_one_collection'])
     self.assertIn(self.instance, Collector.get_collection(
         'example_collection'))
     self.assertIn(self.instance, Collector.get_collection(
         'another_one_collection'))
     self.instance.delete_from_collections(['example_collection'])
     self.assertNotIn(self.instance, Collector.get_collection(
         'example_collection'))
     self.assertIn(self.instance, Collector.get_collection(
         'another_one_collection'))
Exemple #2
0
 def update(self, *args, **kwargs):
     """Change affected objects' accelerations"""
     for affect_object in self.affect_objects:
         if affect_object in Collector.get_collection('movable'):
             affect_object.acceleration = (
                 Vector(affect_object.acceleration) +
                 self._get_acceleration(affect_object))
Exemple #3
0
    def process_collisions(self, instance):
        """Check if self collide another widget.

        Dispatch 'on_collide' event.
        """
        for widget in Collector.get_collection("collidable"):
            if (self is not widget and self.collide_widget(widget) and
                    widget.collide_widget(self)):
                self.dispatch("on_collide", widget)
    def process_collission(first, second):
        """Process collission for two elastic objects

        :param first: first widget to check collission
        :type first: parabox.behaviour.collidable.Collidable
        :param second: second widget to check collission
        :type second: parabox.behaviour.collidable.Collidable
        """
        if first in Collector.get_collection('movable'):
            base, additional = first, second
        else:
            base, additional = second, first
        ElasticCollissionProcessor.clarify_collission_point(base, additional)
        base.velocity, additional.velocity =\
            ElasticCollissionProcessor.get_velocity_after_collission(
                base, additional)
 def test_get_collections(self):
     initial_len = len(list(Collector.get_collections()))
     self.assertEqual(
         len(list(Collector.get_collections(['foo', 'bar']))), 2)
     self.assertEqual(
         len(list(Collector.get_collections())), initial_len + 2)
 def test_get_collection(self):
     self.assertEqual(
         len(Collector.get_collection('new_collection')), 0)
     self.assertEqual(
         len(Collector.get_collection('example_collection')), 1)
 def test_in_base_objects_by_default(self):
     self.assertIn(self.instance, Collector.get_collection(
         'base_objects'))
 def setUp(self):
     self.point = PointPhisics(
         gravity=1,
         affect_radius=100,
         pos=(100, 100),
         affect_objects=Collector.get_collection('base_objects'))