Camera - VictorAlvizo/Ventura GitHub Wiki

Camera()

Default constructer, should not be used. Only there for the camera is a local variable and not a pointer to avoid errors

Camera(glm::vec2 pos, glm::vec2 windowSize, Entity * entity = nullptr)

Provide the initial position of the camera and the size of the window the camera is in. If there is an entity that the camera must follow right off the bat provide it in the constructer, otherwise leave it as nullptr

Example: Camera * cam = new Camera(glm::vec2(100.0f, 200.0f), glm::vec2(m_Width, m_Height), player); //Make a camera at (100, 200) that follows the player entity

~Camera()

Deconstructer, if the camera was following any entities will set it the pointer to nullptr

void Move(glm::vec2 pos)

Move the camera to the wanted position

void Translate(glm::vec2 transPos, float deltaTime)

Translate the camera gradually. The transpos is the direction vector (the path) to follow. DeltaTime gradually moves it towards that position in accordance to the program's framerate.

Example: cam->Translate(glm::vec2(300.0f, -500.0f), deltaTime); //Move the camera 583.0f @ 57° (remember that in Ventura, the y axis is flipped (down is positive y, up is negative y)) in accordance to the game's framerate

void SetEntity(Entity * entity)

Set the entity to follow

void Disconnect()

If the camera is following an entity, stop following the entity

glm::mat4 UpdateView()

Returns the view matrix to be used by the shaders

glm::vec2 getPos()

Returns the camera position

glm::vec2 getWindowSize()

Returns the width and height of the window (in vector form (width, height))