LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Camera Class Reference

A camera to draw the scene in. More...

#include <camera.h>

Public Member Functions

void SetFocus (std::shared_ptr< Entity > obj)
 
void Update ()
 Update the camera's position to keep the object centered.
 
bool InCamera (Rectf box) const
 
void Move (Vector2f v)
 
void Move (float deltaT)
 
void Pan (std::string name)
 
std::string Scene ()
 
void SetBox (Rectf box)
 
Rectf Box () const
 Returns the camera's box.
 
void SetSceneBox (Rectf box)
 
Rectf SceneBox () const
 Get the scene box.
 
Vector2f Offset () const
 
Vector2f Centering () const
 
Json::Value Save ()
 
void Load (Json::Value val)
 
bool operator== (const Camera &c) const
 Operators.
 
bool operator!= (const Camera &c) const
 

Detailed Description

A camera to draw the scene in.

A simple camera that can be given a gameobject to focus on and follow, or can be moved manually

Member Function Documentation

Vector2f Camera::Centering ( ) const

Get the offset needed to center the scene in the window

Returns
a Vector2f containing the offset to apply
bool Camera::InCamera ( Rectf  box) const

Check if an Rect is in the camera

Parameters
boxThe box to check if it's in the camera
Returns
True if object is in camera
void Camera::Load ( Json::Value  val)

Load the camera configuration from a Json::Value

Parameters
valThe Json::Value to load from
void Camera::Move ( Vector2f  v)

Move the camera by some Vector2 This is used for dragging the camera with the mouse

Parameters
vThe distance to move the camera
void Camera::Move ( float  deltaT)

Move the camera taking into account some elapsed time deltaT This is used for pan animations

Parameters
deltaTThe elapsed time
Vector2f Camera::Offset ( ) const

Get the offset needed to apply to objects in the camera, this offset includes the centering offset and any offset added from moving the camera

Returns
a Vector2f that is the offset to apply
void Camera::Pan ( std::string  name)

Instruct the camera to play some pre-defined panning

Parameters
nameThe name of the animation to play, if name not found nothing will happen
Json::Value Camera::Save ( )

Save the camera information to file

Returns
Json::Value containing the camera's information
std::string Camera::Scene ( )

Get the active scene

Returns
The name of the scene, "busy" means the camera is panning
void Camera::SetBox ( Rectf  box)

Set the camera box equal to the Rect passed, a check is performed to make sure that the camera box isn't bigger than the scene box if no scene box is set no problem, the check is also done when setting a scene box

Parameters
boxThe rect to set the camera box too
void Camera::SetFocus ( std::shared_ptr< Entity obj)

Register the gameobject to focus on with the camera

Parameters
objThe object for the camera to follow/center on
void Camera::SetSceneBox ( Rectf  box)

Set the scene's box, a check is done to make sure the camera box isn't bigger than the scene's box

Parameters
boxThe box to set the scene box too

The documentation for this class was generated from the following files: