98 void shake(
float strength);
2D camera that follows a target, stays inside the world and shakes.
void snap_to(const Vec2< float > &target)
Move straight to a target and stop any shake.
void follow(const Vec2< float > &target, float dt)
Ease towards a target. Call once per update.
Vec2< float > shake_offset
Vec2< float > world_to_screen(const Vec2< float > &world) const
Convert a world position to screen space.
Camera()=default
Create a camera with no view size. Call set_view_size before use.
void set_shake_decay(float decay)
Set how quickly screen shake fades.
Vec2< float > get_position() const
Get the top left of the view in world space, without shake.
void shake(float strength)
Start a screen shake. A weaker shake does not cut short a stronger one already running.
void set_position(const Vec2< float > &position)
Set the top left of the view in world space.
Vec2< float > screen_to_world(const Vec2< float > &screen) const
Convert a screen position, such as the mouse, to world space.
void set_follow_speed(float speed)
Set how quickly follow catches up with its target.
void update(float dt)
Advance screen shake. Call once per update.
void clear_bounds()
Let the view move anywhere.
void set_bounds(const Quad< float > &bounds)
Keep the view inside an area of the world. If the area is smaller than the view, the view is centred ...
Quad< float > get_view() const
Get the visible world area, including shake.
void clear_anchor()
Keep the followed target in the middle of the view again.
void set_anchor(const Vec2< float > &anchor)
Set the point in the view where the followed target is kept. Defaults to the middle of the view.
void set_view_size(const Vec2< float > &view_size)
Set the size of the area the camera shows.