Pacman Torben Petré
Loading...
Searching...
No Matches
Camera Class Reference

#include <Camera.h>

Public Member Functions

 Camera (Camera &other)=delete
void operator= (const Camera &)=delete
void setScaling (float mapWidth, float mapHeight)
 Update the Camera scaling factors based on the current world.
void resized ()
 Update the Camera scaling factors based on the current window size.
float xToPixel (float normalizedX) const
float yToPixel (float normalizedY) const
float getTileWidth () const
 Returns the width of a tile according to the current scaling factors.
float getTileHeight () const
 Returns the height of a tile according to the current scaling factors.

Static Public Member Functions

static CameragetInstance ()
 Returns an instance of the Camera class.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( Camera & other)
delete

Singletons should not be cloneable or assignable.

Member Function Documentation

◆ getInstance()

Camera & Camera::getInstance ( )
staticnodiscard

Returns an instance of the Camera class.

Returns
Camera instance

◆ getTileHeight()

float Camera::getTileHeight ( ) const
nodiscard

Returns the height of a tile according to the current scaling factors.

Returns
Height of a tile

◆ getTileWidth()

float Camera::getTileWidth ( ) const
nodiscard

Returns the width of a tile according to the current scaling factors.

Returns
Width of a tile

◆ operator=()

void Camera::operator= ( const Camera & )
delete

◆ resized()

void Camera::resized ( )

Update the Camera scaling factors based on the current window size.

When the window is resized it is important that this is properly reflected by the Camera. Will call setScaling afterward.

◆ setScaling()

void Camera::setScaling ( float mapWidth,
float mapHeight )

Update the Camera scaling factors based on the current world.

This must be done to assure that the whole world will always fit on screen. Regardless of map or window size.

Parameters
mapWidthThe loaded world map width in tiles
mapHeightThe loaded world map height in tiles

◆ xToPixel()

float Camera::xToPixel ( float normalizedX) const
nodiscard
Parameters
normalizedXNormalized world X coordinate.
Returns
X coordinate scaled appropriately for the current window width.

◆ yToPixel()

float Camera::yToPixel ( float normalizedY) const
nodiscard
Parameters
normalizedYNormalized world Y coordinate.
Returns
Y coordinate scaled appropriately for the current window height.

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