1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def manage_camera(view, player, deadzone=100):
    """"fixed camera with a deadzone."""
    if player.is_moving():
        delta = view.center - player.center_position
        delta = Vector(delta.x, delta.y)
        if delta.length > deadzone:
            while True:
                delta = view.center - player.center_position
                delta = Vector(delta.x, delta.y)
                if delta.length < deadzone:
                    break
                delta.length = 1
                view.center = view.center - (delta.x, delta.y)


def manage_camera2(view, player):
    """fixed camera."""
    # manages view scrolling by locking on to player's center point.
    view.center = player.center_position