NotQuiteParadise2

Camera

class Camera(size: pygame.math.Vector2)[source]

Bases: object

Basic math for getting view of game world

zoom

positive numbers “zoom out”, negative numbers “zoom in”

  • World units are equal to pixels at zoom level of 0.0

__init__(size: pygame.math.Vector2)[source]
centre(pos: pygame.math.Vector2)[source]

Immediately centre the camera on a world point

clamp(rect: pygame.Rect)[source]

Move camera so that it is contained in the rect

Has same behaviour as pygame.Rect.clamp

get_centre() pygame.math.Vector2[source]

Get copy of the position

get_rect() pygame.Rect[source]

Return Pygame Rect representing the visible area of the camera

get_size() pygame.math.Vector2[source]

Return vector of the size after zoom is applied

move(x: int = 0, y: int = 0)[source]

Immediately move the camera by relative amount

render_offset() pygame.math.Vector2[source]

Return vector for drawing offset

reset_movement()[source]

Immediately move camera to tracked position

set_target_entity(entity: Optional[int])[source]

Smoothly track a game entity. Pass None to clear.

set_target_position(pos: Optional[pygame.math.Vector2])[source]

Move camera to position over time. Pass None to clear.

update(delta_time: float)[source]

Update camera movements