The Table Engine
Camera Class Reference

Manages the camera's view in a game, handling its position in the world space. More...

#include <camera.h>

+ Inheritance diagram for Camera:
+ Collaboration diagram for Camera:

Public Member Functions

 Camera ()
 
 ~Camera ()
 
void update ()
 
Vec2 getWorldPosition ()
 
void setWorldPosition (float x, float y)
 
- Public Member Functions inherited from Component
 Component ()
 Default constructor for the Component. More...
 
 Component (std::string name)
 Constructs a Component with a specified name. More...
 
virtual ~Component ()
 Virtual destructor for safe polymorphic use. More...
 
std::string getName ()
 Retrieves the name of the component. More...
 
GameObjectgetOwner ()
 Retrieves the GameObject that owns this component. More...
 
void setName (std::string name)
 Sets the name of the component. More...
 
void setOwner (GameObject *owner)
 Sets the GameObject owner of this component. More...
 
virtual void input ()
 Virtual method for handling input, intended to be overridden by derived components. More...
 
virtual void render ()
 Virtual method for rendering, intended to be overridden by derived components. More...
 

Private Attributes

Vec2 m_worldPosition
 Stores the world position of the camera. More...
 

Additional Inherited Members

- Protected Attributes inherited from Component
std::string m_name
 Name of the component, useful for identification or debugging. More...
 
GameObjectm_owner
 Pointer to the GameObject that owns this component. More...
 

Detailed Description

Manages the camera's view in a game, handling its position in the world space.

The Camera class extends Component, allowing it to be attached to game objects and manage the view based on the game object's transformations or other logic.

Definition at line 14 of file camera.h.

Constructor & Destructor Documentation

◆ Camera()

Camera::Camera ( )

Constructor for the Camera class.

Definition at line 9 of file camera.cpp.

◆ ~Camera()

Camera::~Camera ( )

Destructor for the Camera class.

Definition at line 13 of file camera.cpp.

Member Function Documentation

◆ getWorldPosition()

Vec2 Camera::getWorldPosition ( )

Gets the current world position of the camera.

Returns
The current world position as a Vec2.

Definition at line 62 of file camera.cpp.

◆ setWorldPosition()

void Camera::setWorldPosition ( float  x,
float  y 
)

Sets the world position of the camera.

Parameters
xThe x-coordinate of the new world position.
yThe y-coordinate of the new world position.

Definition at line 66 of file camera.cpp.

◆ update()

void Camera::update ( )
virtual

Updates the camera's position and behavior. This should be called each frame.

Reimplemented from Component.

Definition at line 17 of file camera.cpp.

Member Data Documentation

◆ m_worldPosition

Vec2 Camera::m_worldPosition
private

Stores the world position of the camera.

Definition at line 45 of file camera.h.


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