Project update #3

Done on May 7, 2017 – Camera and Map


For this third update, I took care of the following things:

  • Added a Camera following the Player
  • And a Map in the background

At this point the Map implementation is extremely basic and I’ll have to improve it in a future update. Its primary goal here is to provide some point of reference so I can demonstrate the camera movement.

The camera is an object with a position and size. Its size is the same as the one of the application window. When the player moves, the camera tries to keep up with him meaning that its position changes over time. This position is then used to render the objects in the scene.

Everything is rendered relatively to this position so that the objects that are in the camera end up in the application window. As an example, here’s what the Player’s Render method looks like:

void Player::Render()
    // Render the player based on the camera's position
    Vector2 renderingPosition = m_position - alpagosEngine::Camera::GetInstance().GetPosition();

    m_animations[m_currentState].Render((int)renderingPosition.x, (int)renderingPosition.y, (int)m_size.x, (int)m_size.y,
        m_facingRight ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL);


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s