@@ -26,9 +26,22 @@ def test_physics_engine(window):
2626 sprite .center_y = 32
2727 wall_list .append (sprite )
2828
29+ platform_list = arcade .SpriteList [arcade .Sprite ]()
30+ platform = arcade .Sprite (
31+ ":resources:images/tiles/boxCrate_double.png" ,
32+ scale = CHARACTER_SCALING ,
33+ center_x = 64 ,
34+ center_y = 256 ,
35+ )
36+ platform .boundary_left = 0 # 0 in particular was problematic, see #2658
37+ platform .boundary_right = 128
38+ platform .change_x = 8
39+ platform_list .append (platform )
40+
2941 physics_engine = arcade .PhysicsEnginePlatformer (
3042 character_sprite ,
31- wall_list ,
43+ walls = wall_list ,
44+ platforms = platform_list ,
3245 gravity_constant = GRAVITY ,
3346 )
3447
@@ -48,10 +61,23 @@ def update(td):
4861 assert physics_engine .can_jump () is True
4962 character_sprite .change_y = 15
5063 physics_engine .increment_jump_counter ()
51- window .test ()
64+
65+ window .test (frames = 7 )
66+
5267 assert physics_engine .can_jump () is True
68+ assert platform .center_x == 80 # it bounced against the boundary_right
69+ assert platform .change_x == - 8
5370 character_sprite .change_y = 15
5471 physics_engine .increment_jump_counter ()
55- window .test ()
72+
73+ window .test (frames = 6 )
74+
5675 assert physics_engine .can_jump () is False
76+ assert platform .center_x == 32 # right at the boundary
77+ assert platform .change_x == - 8 # still going left
5778 physics_engine .disable_multi_jump ()
79+
80+ window .test (frames = 3 )
81+
82+ assert platform .center_x == 32 + 24 # it bounced against the boundary_left
83+ assert platform .change_x == + 8
0 commit comments