This here post will be my first real devblag. Short for development web log. From time to time, I’ll be describing the development process for the games I’m making.
I read this article, which someone tweeted, can’t remember who. (By the way, follow me on twitter. I swear, eventually I’ll figure out what I’m supposed to do with it.) It’s a cool article, and if you’re into game development, specifically 2D sidescrollers, you should really check it out. It’s convinced me to redo the camera for AVGN:TitNES (which really needs a shorter initialism)
Old Camera Movement
Previously the camera worked by always centering the character horizontally. except when you reach the edges of the map. (The game doesn’t scroll vertically… yet.) It works well enough, as the Nerd moves pretty slowly. I’m going for a slow and careful NES Castlevania style of movement.
New Camera Movement
The new camera works a bit more dynamically. First, it speeds up the camera to show maximum of 64 more pixels, or two more blocks (the distance is adjustable) in the direction the player is headed. This allows you to see a bit further along, and makes the unwieldly sprinting mechanic I recently added a bit more useful.
The camera only moves when the player is moving. I’m hoping this will prevent camera movements from becoming distracting, or having the camera move in ways the player doesn’t want. Nothing is worse to me than the sliding camera that catches up to the player after he stops moving, especially when it eases in slowly and takes a second and a half to stop moving after you do. It feels like the player doesn’t have control of the camera.
This worked pretty well, but when you turned around rapidly back and forth the camera moved around a bit too much when I had the camera speed high (much faster than the player). And when the speed was low (a bit faster than the player) it took too long to recenter after backtracking a bit.
The solution was to have the camera move at a different speed depending on how close you were to the limit and which direction you’re facing. So, when the player is moving right, relative to the frame the character moves to the left. The further left the player appears, the slower the camera is relative to his movement, until eventually they travel at the same speed. Turning around reverses this and recenters the player much faster than it took to get to the limit. So while it takes 20 block lengths to get the camera completely to the limit of two blocks ahead of the character, travelling just four block lengths back centers it again. I hope that made sense, as it’s hard to explain in writing.
It took me a while to get the math right for this relative camera speed part, but I think it was worth it. The limit and factor to which the camera is faster are both adjustable, so they can easily be tweaked if necessary. And the motion’s pretty smooth, so most players won’t even notice it. I barely notice when I play (as long as those pink and green bars are off)
Conclusion
I’m glad I did it. It’s a little bit of polish that really helps the game look a touch more professional. Pretty good for a few hours work.
Any questions or comments? About this feature or the devblag in general. Fire away.
P.S. I’m thinking of doing some more revisions to AKR2 (don’t get too excited, it’s mostly technical, with no real content additions) and I might add a camera like this. Possibly optional, or even adjustable. It would require a butt-ton of beta testing though.