Ben's Journal

Find me @btsherratt or on itch.io

Game Cameras

Tuesday, July 4th, 2023

Looking for some camera stuff, came across this banger of a post about game cameras.


The camera tries to move to focus on the character

For Scared Little Ghost two changes have been affecting the camera; firstly moving from Pico-8 to C means that the screen is now widescreen, and secondly I needed to change some of the ways the camera in the original prototype worked to show the game map better.

Because the game is pixel-based and I don't want to use sub-pixel scrolling, moving the camera just attached to the character made the camera 'wobble' on X & Y when moving diagonally, and it looked awful. So instead, the camera does the double frame thing (move when the character is in the yellow box, stay still when in the green box) which looks OK for most of the time, so that's cool. There's still a fun edge case though, because diagonal movement makes the camera move faster than the character it's currently possible to make the camera overtake you and bounce to rest. It does this because I keep the camera moving in the same direction as the character (if you start doing every-other-frame style movement then it does the visual wobble thing) and so it's slower on the diagonals. Obviously I could increase the character speed, and then everything changes....... 😂

Bug showing the camera bounce when it overtakes the character

So many edge cases, camera code is fun but also 😫