Camera
Each scene has a single camera at scene.camera. It clears the frame, transforms world coordinates, and blits to the screen.
Basics
class MyScene(bf.Scene):
def do_when_added(self):
self.set_clear_color((30, 30, 40)) # delegates to camera
self.camera.set_center(0, 0)
Useful methods:
set_clear_color(color)/get_clear_color()set_center(x, y)/set_position(x, y)/move_by(dx, dy)zoom(factor)/zoom_by(delta)set_rotation(degrees)/rotate_by(degrees)world_to_screen(rect_or_point)/screen_to_world(point)get_mouse_pos()— mouse in world spaceintersects(rect)— whether a rect is in view
Following a target
self.camera.set_follow_point_func(lambda: player.rect.center)
self.camera.set_follow_damping(8)
self.camera.set_dead_zone_radius(40)
The camera updates every frame inside the scene update loop.