Building Game Engines
Camera Class Reference

Provides functions to control the camera's perspective and its location. More...

#include <Camera.h>

Inheritance diagram for Camera:
Inheritance graph
Collaboration diagram for Camera:
Collaboration graph

Public Member Functions

 Camera (int x, int y)
 Constructor. More...
 
 ~Camera ()=default
 Default destructor. More...
 
bool inCamera (int x, int y)
 given a point, determine if the point is within camera sight. Used for drawing optimization More...
 
void setCameraPos (int x, int y)
 Set camera's position. More...
 
int getPosX ()
 Get x location of camera. More...
 
int getPosY ()
 Get y location of camera. More...
 
int getViewPortWidth ()
 Get width of camera's viewport. More...
 
void setViewPortWidth (int width)
 Set width of camera's viewport. More...
 
int getViewPortHeight ()
 Get height of camera's viewport. More...
 
void setViewPortHeight (int height)
 Set height of camera's viewport. More...
 
int getXOffset ()
 Get camera's offset on horizontal direction. More...
 
void setXOffset (int offset)
 Set camera's offset on horizontal direction. More...
 
int getYOffset ()
 Get camera's offset on vertical direction. More...
 
void setYOffset (int offset)
 Set camera's offset on vertical direction. More...
 
- Public Member Functions inherited from Component
 Component ()
 
 ~Component ()
 

Detailed Description

Provides functions to control the camera's perspective and its location.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( int  x,
int  y 
)

Constructor.

Parameters
xThe x location of camera.
yThe y location of camera.

◆ ~Camera()

Camera::~Camera ( )
default

Default destructor.

Member Function Documentation

◆ getPosX()

int Camera::getPosX ( )

Get x location of camera.

Returns
An int value of the x location.

◆ getPosY()

int Camera::getPosY ( )

Get y location of camera.

Returns
An int value of the y location.

◆ getViewPortHeight()

int Camera::getViewPortHeight ( )

Get height of camera's viewport.

Returns
An int value of height of camera's viewport.

◆ getViewPortWidth()

int Camera::getViewPortWidth ( )

Get width of camera's viewport.

Returns
An int value of width of camera's viewport.

◆ getXOffset()

int Camera::getXOffset ( )

Get camera's offset on horizontal direction.

This function is used in tilemap editor whenever the screen was divided into left girds and right grids.

Returns
An int value of offset on horizontal direction.

◆ getYOffset()

int Camera::getYOffset ( )

Get camera's offset on vertical direction.

Returns
An int value of offset on vertical direction.

◆ inCamera()

bool Camera::inCamera ( int  x,
int  y 
)

given a point, determine if the point is within camera sight. Used for drawing optimization

◆ setCameraPos()

void Camera::setCameraPos ( int  x,
int  y 
)

Set camera's position.

◆ setViewPortHeight()

void Camera::setViewPortHeight ( int  height)

Set height of camera's viewport.

Parameters
heightThe height of camera's viewport.

◆ setViewPortWidth()

void Camera::setViewPortWidth ( int  width)

Set width of camera's viewport.

Parameters
widthThe width of camera's viewport.

◆ setXOffset()

void Camera::setXOffset ( int  offset)

Set camera's offset on horizontal direction.

◆ setYOffset()

void Camera::setYOffset ( int  offset)

Set camera's offset on vertical direction.