def test_sprite_in_viewport(): cam = Camera(viewport=(0, 0, 800, 600)) class Thing(BaseSprite): def __init__(self, position=Vector(2, 2)): super().__init__() self.game_unit_size = 2 self.position = position sprite_in = Thing(Vector(-3, -1)) sprite_half_in = Thing(Vector(5, -2)) sprite_out = Thing(Vector(2, 5)) assert not cam.in_frame(sprite_out) assert cam.in_frame(sprite_in) assert cam.in_frame(sprite_half_in)
def test_sprite_in_viewport(): # Added the expected pixel ratio due to change in default breaking this test. # 80 is the legacy value. cam = Camera(viewport=(0, 0, 800, 600), pixel_ratio=80) class Thing(BaseSprite): def __init__(self, position=Vector(2, 2)): super().__init__() self.size = 2 self.position = position sprite_in = Thing(Vector(-3, -1)) sprite_half_in = Thing(Vector(5, -2)) sprite_out = Thing(Vector(2, 5)) assert not cam.in_frame(sprite_out) assert cam.in_frame(sprite_in) assert cam.in_frame(sprite_half_in)