informa
2 min read
Blogs

How the camera works in Sol

Here I describe how the camera works in Sol. This is especially interesting when zooming is enabled, since the camera behavior is much more complex to compensate for the smaller viewport.

After reading the recent article on cameras in sidescrolling games I thought I may as well share how the camera works in Sol. I'm going to use some terms from that article so consider reading it first if you haven't already.

First of all, some remarks:

  • Screen coordinates are given relative to the center of the screen (not the top left corner) because of the way resolution handling works for different aspect ratios. Horizontal coordinates increment to the right, vertical coordinates increment downwards.
  • The "player origin" is 16 pixels above the ground vertically (the character is 40 pixels high, for context).

The camera works differently depending on whether zooming is enabled or not, so I'm going to describe both modes separately.

Normal mode

The game simply uses a normal camera window in this mode. The margins are -8 to 8 horizontally, and -32 to -16 vertically.

When the camera shakes (i.e. a quake effect), a vertical offset is added to its current position. This offset is calculated the moment rendering happens and is not stored, i.e. the shaking isn't accounted for the camera window.

Zoomed mode

When zooming is enabled the camera behaves completely different to account for the smaller viewport.

For starters there isn't a camera window at all, it just aims for the player position directly. Then it applies a horizontal offset, to give some extra room to see forwards. This offset changes depending on the direction the player is facing, when the player turns around the offset is shifted until it reaches its new intended position. Pressing up or down also applies a vertical offset in a similar way, allowing the player to look more vertically.

The third boss (the helicopter one) is problematic, since the helicopter would end up completely off-screen using this behavior. What happens then is that during the fight against that boss another vertical offset is applied, which puts the camera right in the middle point between the helicopter's height and the previously computed camera position. This gives enough room to see the helicopter.

Finally, shaking is disabled unconditionally when zooming is enabled, since the effect is too strong and would severely get in the way.

Latest Jobs

Treyarch

Playa Vista, California
6.20.22
Audio Engineer

Digital Extremes

London, Ontario, Canada
6.20.22
Communications Director

High Moon Studios

Carlsbad, California
6.20.22
Senior Producer

Build a Rocket Boy Games

Edinburgh, Scotland
6.20.22
Lead UI Programmer
More Jobs   

CONNECT WITH US

Register for a
Subscribe to
Follow us

Game Developer Account

Game Developer Newsletter

@gamedevdotcom

Register for a

Game Developer Account

Gain full access to resources (events, white paper, webinars, reports, etc)
Single sign-on to all Informa products

Register
Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Subscribe
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more