11import unittest
22
33from pygorithm .geometry import (
4- collision_detection
4+ rect_broad_phase
55 )
66
77
88class TestCollisionDetection (unittest .TestCase ):
99 def setUp (self ):
1010 # first pair of objects
11- self .coord1 = collision_detection .Coord (1 , 1 )
12- self .coord2 = collision_detection .Coord (6 , 8 )
13- self .body1 = collision_detection . Body (self .coord1 , self .coord2 )
14- self .coord3 = collision_detection .Coord (4 , 0 )
15- self .coord4 = collision_detection .Coord (7 , 4 )
16- self .body2 = collision_detection . Body (self .coord3 , self .coord4 )
11+ self .coord1 = rect_broad_phase .Coord (1 , 1 )
12+ self .coord2 = rect_broad_phase .Coord (6 , 8 )
13+ self .simpleRect1 = rect_broad_phase . SimpleRectangle (self .coord1 , self .coord2 )
14+ self .coord3 = rect_broad_phase .Coord (4 , 0 )
15+ self .coord4 = rect_broad_phase .Coord (7 , 4 )
16+ self .simpleRect2 = rect_broad_phase . SimpleRectangle (self .coord3 , self .coord4 )
1717 # second pair
18- self .coord1 = collision_detection .Coord (1 , 1 )
19- self .coord2 = collision_detection .Coord (2 , 3 )
20- self .body3 = collision_detection . Body (self .coord1 , self .coord2 )
21- self .coord3 = collision_detection .Coord (4 , 3 )
22- self .coord4 = collision_detection .Coord (7 , 8 )
23- self .body4 = collision_detection . Body (self .coord3 , self .coord4 )
18+ self .coord1 = rect_broad_phase .Coord (1 , 1 )
19+ self .coord2 = rect_broad_phase .Coord (2 , 3 )
20+ self .simpleRect3 = rect_broad_phase . SimpleRectangle (self .coord1 , self .coord2 )
21+ self .coord3 = rect_broad_phase .Coord (4 , 3 )
22+ self .coord4 = rect_broad_phase .Coord (7 , 8 )
23+ self .simpleRect4 = rect_broad_phase . SimpleRectangle (self .coord3 , self .coord4 )
2424
2525
2626class TestBroadPhase (TestCollisionDetection ):
2727 def test_collision_detect (self ):
28- self .assertTrue (collision_detection .broad_phase (self .body1 , self .body2 ))
29- self .assertFalse (collision_detection .broad_phase (self .body3 , self .body4 ))
28+ self .assertTrue (rect_broad_phase .broad_phase (self .simpleRect1 , self .simpleRect2 ))
29+ self .assertFalse (rect_broad_phase .broad_phase (self .simpleRect3 , self .simpleRect4 ))
3030
3131if __name__ == '__main__' :
3232 unittest .main ()
0 commit comments