The Game Engine  1
Camera Class Reference

This class is to represent a camera. More...

#include <Camera.h>

+ Collaboration diagram for Camera:

Public Member Functions

 Camera ()
 
void follow (WorldObject *o, Point2D padding=Point2D())
 Follows the given world object with padding amount of leeway. More...
 
void stopFollow ()
 Stops following of world object. More...
 
void move (Point2D p)
 Moves camera to given position. More...
 
void updatePos ()
 Updates the camera's position if following. More...
 
void zoom (double zoom)
 Set the current zoom amount. More...
 
void zoomIn (double zoom)
 Allows the camera to zoom in a given amount. More...
 
void zoomOut (double zoom)
 Allows the camera to zoom out a given amount. More...
 

Public Attributes

Point2D pos
 Camera's position. More...
 

Protected Attributes

WorldObjectmObject
 Object to follow. More...
 
Point2D mPadding
 Padding amount before box starts moving. More...
 
double mZoom
 Amount of zoom. More...
 

Detailed Description

This class is to represent a camera.

  • Contains camera's position
  • Can scale the view
  • Can Move
  • Can follow a given WorldObject

Definition at line 13 of file Camera.h.

Constructor & Destructor Documentation

Camera::Camera ( )
inline

Definition at line 16 of file Camera.h.

Member Function Documentation

void Camera::follow ( WorldObject o,
Point2D  padding = Point2D() 
)

Follows the given world object with padding amount of leeway.

Parameters
oThe WorldObject to follow
paddingThe amount of padding in the x and y that the sprite can move without moving the camera

Definition at line 4 of file Camera.cpp.

+ Here is the caller graph for this function:

void Camera::move ( Point2D  p)

Moves camera to given position.

Parameters
pPosition to move the camera

Definition at line 13 of file Camera.cpp.

void Camera::stopFollow ( )

Stops following of world object.

Definition at line 9 of file Camera.cpp.

void Camera::updatePos ( )

Updates the camera's position if following.

Todo:
implement edge stopping. I.E. if screen hits the edge of the map stop following the sprite in that direction.

Definition at line 17 of file Camera.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Camera::zoom ( double  zoom)

Set the current zoom amount.

Parameters
zoomAmount to zoom where 1 == 100%

Definition at line 30 of file Camera.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Camera::zoomIn ( double  zoom)

Allows the camera to zoom in a given amount.

Parameters
zoomAmount to zoom in relative to currentZoom where 1 == 100%

Definition at line 45 of file Camera.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Camera::zoomOut ( double  zoom)

Allows the camera to zoom out a given amount.

Parameters
zoomAmount to zoom where 1 == 100%

Definition at line 49 of file Camera.cpp.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

WorldObject* Camera::mObject
protected

Object to follow.

Definition at line 64 of file Camera.h.

Point2D Camera::mPadding
protected

Padding amount before box starts moving.

Definition at line 66 of file Camera.h.

double Camera::mZoom
protected

Amount of zoom.

Definition at line 68 of file Camera.h.

Point2D Camera::pos

Camera's position.

Definition at line 19 of file Camera.h.


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