..NAV
camera.Camera(object)Camera(xwindow = 80, ywindow = 80, speed = 0.05)
Initialise a new Camera object.
xwindow, ywindow
The number of pixels away from the tracking object the camera should stay within. Ifxwindow
andywindow
are equal to zero, the camera will always keep the character in the center of the screen.
speed
This is the speed at which the camera catches up to it's target.Camera.follow(target)
Sets the target which the camera will follow.
target
The target to track. Must have a rect attribute.Camera.update()
Should be called once per frame to update where the camera is pointing.Camera.translate(rect) -> return pygame.rect.Rect
Returns a new rect that is translated into the cameras viewports. Should be used when drawing objects as the final position an object is drawn.Camera.freeze(object)
Tells the camera thatobject
is blocking the camera's movement. Useful for a boss or a cutscene.Camera.unfreeze(object)
Tells the camera thatobject
is no longer blocking the camera's movement.Camera.center_at(pos)
Points the camera at a specific point. If the camera is following a target, the target is cleared.