![]() |
Calamity Engine 1.0.0
A cross-platform 2D game engine written in C++ and SDL3.
|
#include <components.hpp>
Public Member Functions | |
| void | setActive () |
| void | update (float deltaTime) override |
| void | initialize () override |
| Vector2 | getGlobalPosition () |
| Transform | getCameraTransform () const |
| Vector2 | screenToWorld (Vector2 screen) const |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Member Functions inherited from Component | |
| virtual | ~Component ()=default |
| virtual void | render (std::shared_ptr< Window > window) |
| virtual void | physicsUpdate () |
| virtual void | input (InputEvent &event) |
| virtual void | postLoad () |
| virtual void | exit () |
| Node * | getNode () const |
| void | setNode (Node *n) |
| template<class Archive > | |
| void | save (Archive &ar) const |
| template<class Archive > | |
| void | load (Archive &ar) |
Public Attributes | |
| bool | active = true |
| Vector2 | origin = {0.5f, 0.5f} |
| float | smoothing = 0.0f |
The camera component it a virtual camera that defines the positions and scale/rotation of everything rendered on screen. Just like how cameras work in real life and in every other game engine!
Example usage:
The Camera component has an origin attribute, which allows you to render the camera offset depending on the position of its parent node:
The Camera component also exposes a smoothing attribute, which allows you to smooth the cameras position.
| Transform Camera::getCameraTransform | ( | ) | const |
| Vector2 Camera::getGlobalPosition | ( | ) |
|
overridevirtual |
Reimplemented from Component.
|
inline |
|
inline |
| void Camera::setActive | ( | ) |
|
overridevirtual |
Reimplemented from Component.
| bool Camera::active = true |
| Vector2 Camera::origin = {0.5f, 0.5f} |
| float Camera::smoothing = 0.0f |