Camera movement in Super Mario World and Yoshi's Island

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Camera movement in Super Mario World and Yoshi's Island

Post by tepples »

In this post, creaothceann mentioned the article "Scroll Back: The Theory and Practice of Cameras in Side-Scrollers" by Itay Keren. It explains, among other things, how Super Mario World provides a space in front of the player when moving mostly in one direction while letting the player "move around a bit in the center of the screen with the camera stationary".
there are two anchors allowing wide forward view in whatever direction the player chooses to go. However even as the player starts heading back (which happens constantly in SMW), the camera will keep the target point until Mario hits a predefined threshold, and only then will it lock to the other anchor. This is extremely helpful with SMW’s frequent left/right motion that does not warrant a direction change.
The article has a GIF that illustrates two rules of SMW camera behavior, which I will paraphrase:
  1. When the player moves into the outer thirds of the screen, set the rear threshold to the opposite third, and set the front threshold to 16 pixels from the center of the screen on the same side as the new rear threshold. That is, when the player moves into the right third of the screen (x>171), set the rear threshold to the left third (x=85) and the front 16 pixels to the left of center (x=112), and when the player moves into the left third of the screen (x<85), set the rear threshold to the right third (x=171) and the front threshold to 16 pixels to the right of center (x=144).
  2. Each frame, move the camera toward a position that puts the center of the player between the front and rear thresholds.
Yoshi's Island, with larger gaps in terrain needing flutter-jumps to traverse, is even more aggressive at centering the camera in front of the player, showing behavior that I'd expect more from a Game Boy or Game Gear game compensating for its smaller screen. YI usually shows two-thirds of a screen in front of the player. The camera's horizontal position has two states:
  • Forward facing: Move the camera to an offset from the player, and move this offset slowly based on the facing direction until the player is at the trailing third. If the player turns around once the offset is at its limit, stay in forward facing with the new facing direction. If the player turns around while the offset is still moving, go to still with thresholds at the player's current position and 32 pixels in front of that in the new facing direction.
  • Still: Don't move the camera. If leaving the thresholds, go to forward facing.
Pinocchio and Full Quiet behave like the forward facing mode of YI, with no "still" state.

The rule for vertical scrolling in SMW, YI, FQ, and Shinobi is platform snapping. The camera seeks the player's vertical position with one exception: While in the middle of a jump (not standing or flying), the camera does not move up.

What else do these games do right camera-wise, and what could they have done better?


[Split on June 3, 2023, when I realized that all this was sort of off-topic for a discussion about an already released NES game.]
Drag
Posts: 1615
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Re: Camera movement in Super Mario World and Yoshi's Island

Post by Drag »

I spent some time of my own a few years ago picking apart the camera logic in Yoshi's Island too. The important thing to keep in mind is the intent of the player movement.

Most of the time, when you jump, it's to jump over something, and not to jump onto something higher. That's why the camera waits until you land on higher ground before scrolling upwards. Another thing is, in SMW, when you start climbing up a vine, the camera will immediately unlock and start following you upwards. That's because climbing upwards is a fairly clear indication that the player's intent is to go somewhere higher. :P Similarly, in Yoshi's Island, certain trampolines will cause the camera to immediately follow you upwards (unless I'm misremembering).

It is nauseating for the camera to constantly be swinging up and down, and side to side, which is why good camera design includes waiting until the player has sufficiently indicated enough that they actually want to go in a specific direction (and e.g., not just simply making a quick adjustment). Yoshi's Island handles this great with how it does the slow-pan when you face the opposite direction horizontally, and when it does and doesn't follow you vertically.

Something else to keep in mind is, camera behavior is part of level design, in the sense that the designer knows what they want the player to do, and can give camera cues in order to facilitate it. That includes things like guiding the camera along a rail, leading the player to go a specific direction, leaving extra margins above, below, in front, behind, etc. This also gives you the opportunity to hide secrets in places where the camera doesn't seem to be following you (until you go through a false wall like in DKC). SMW (or maybe SMB3?) in particular allows you to specify whether you want the camera to unconditionally follow you upwards, or if you want the camera to stay at the bottom until you fly or climb upwards.

That is to say, you can just keep some simple camera rules and rely on the camera's general behavior, and that'll get you 80% of the way there, but nothing compares to the level designer specifically curating the camera behavior to facilitate the level design.
SNES AYE
Posts: 201
Joined: Mon Nov 07, 2022 11:28 am

Re: Camera movement in Super Mario World and Yoshi's Island

Post by SNES AYE »

Yoshi's Island has about the best camera implementation I've seen on SNES and is a great example of compensating for the lack of horizontal screen view and always dynamically adjusting in a very smooth and non-headache-inducing way that keeps as much of the view ahead of the player as possible as often as possible while not having any negative effect on the general gameplay or player control. When it comes to well-done cameras in SNES games it really is the poster child and something that every SNES developer and programmer should be studying in my opinion. Games like Super Mario World and Donkey Kong Country are solid examples well worth looking at too.
Pokun
Posts: 2681
Joined: Tue May 28, 2013 5:49 am
Location: Hokkaido, Japan

Re: Camera movement in Super Mario World and Yoshi's Island

Post by Pokun »

I fully agree with all of you and Drag explained it in detail why these games are so good at scrolling. To further elaborate on this, we may need to pick some examples that does it wrong.

As I said in the original thread, games using the camera-window that is "pushed" by the player like Jump Bug does (as shown in the above-mentioned article) tends to have too little view-area forwards, and this is what SMW solves in the horizontal axis. Though Jump Bug seems to solve the problem of not wasting too much CPU time on screen updates, which SMW doesn't have due to the SNES having hardware scrolling, so it's maybe not a good example.

Frogger Advance seems like a good example of bad vertical scrolling, as the camera follows the player up when jumping instead of snapping to platforms when the player lands. This makes landing much harder as you loose sight of the ground until you have fallen down close enough to it, making it easy to fall into a bottomless pit, on spikes or other dangers.
Jazz Jackrabbit seems to be another good example, as it seems to just lock the camera to the player.
Jazz Jackrabbit 2 (mentioned in the article) however seems to solve this by having a larger view overall and a more forward focus mechanic then the first game. Terraria in the article does this even more as it has very large screen compared to the player character and therefore gets away with simple position-locking.

Back to what SMW does right, I think it also just have a very pleasant feel to it that fits the game, besides being highly functional.
Maybe it is because I grew up with 8-bit games, but I do think that many more modern 2D titles using lerp- and/or physics-smoothing sometimes feels a bit TOO smooth. It is kind of similar to how I dislike what many modern 2D games (especially those mimicking an 8-bit look) does with smooth rotation and other effects that breaks the rules of the pixel grid it tries to emulate (Super Mario Maker is a good example here).
Post Reply