..NAV

retrogamelib.camera

The camera module includes a Camera class which can aid in scrolling games. The Camera can follow any object with a rect, and must be used when drawing objects as well in order to handle the scrolling properly.
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. If xwindow and ywindow 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 that object is blocking the camera's movement. Useful for a boss or a cutscene.
Camera.unfreeze(object)
Tells the camera that object 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.



Copyright © 2009, pymike and saluk