Here’s a little insight into the kind of hard work that goes into make an Old Testament adventure game like Ebenezer. Today’s challege: camera panning.

A typical environment might look like this (this is the first scene – Kish and Saul’s farm at Gibeah):


But this environment is much wider than the screen of an iPhone, so the player will only see a tiny segment of this at any one point in time:


The aim then is to automatically pan the camera back and forth so that the player’s character remains visible on screen at all times. Roughly speaking, you want to wait until the player enters some fixed boundary around the edge to give yourself a bit of a headstart, rather than waiting until the player actually leaves the screen. Since the player was probably walking somewhere, you probably want to scroll a fair distance too, to let them see where they’re going. If all you did was maintain a fixed distance from the edge of the screen you’d feel very claustrophobic. So, once the camera starts to pan, I make it carry on moving until the player ends up about a third of the way from the opposite edge of the screen:


So far so good. But then we hit a snag: walking isn’t the only way that the player might end up too close to the edge of the screen. It can also happily naturally when the camera begins to zoom in on the scene. The last thing you want in this situation is for the camera to suddenly whizz off to one side – in this situation you really do just want to do the bare minimum to maintain a certain distance from the edge of the screen. The key is to make the code that looks after zooming the camera a bit smarter about which point it zooms in on – rather than always zooming in on the centre of the screen, it can pan as it zooms to keep the player’s position constant. As long as this adjustment is made before the main camera panning algorithm runs you should be fine:


It turns out to be a fairly simple solution in the end, but imagine a hundred such little decisions and you begin to see why developing a game takes a long time.

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *