Actions

SPG:Camera

From Sonic Retro

Revision as of 05:12, 18 July 2009 by Mercury (talk | contribs) (Created page with ''''Note:''' Applies to Sonic 1, 2, 3 & K, and CD except where otherwise noted. ===View Borders=== The Sonic games have a screen size of '''320x224''' pixels during normal Zone …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Note: Applies to Sonic 1, 2, 3 & K, and CD except where otherwise noted.

View Borders

The Sonic games have a screen size of 320x224 pixels during normal Zone play. Sonic isn't always locked in the centre of the screen, but has some freedom of movement within the view borders before it begins to scroll.

Horizontal Border

  • Left border: 144
  • Right border: 160

If you exceed the border, the camera will move by how much you've exceeded, up to 16. So if Sonic moves faster than this, the camera will lag behind.

I'm actually not sure why the developers made the view off-centre like this. It makes it harder to see where you're going when moving left rather than right. If you so choose, you can change the borders to 152 and 168 instead, to even things out a bit.

Sonic CD, though, effectively has both borders set to 160 so that Sonic is always at dead centre and the view scrolls immediately when he begins moving.

Vertical Border

In the Air
  • Top border: 64
  • Bottom border: 128

If you exceed the border, the camera will move by how much you've exceeded, up to 16. So if Sonic moves faster than this, the camera will lag behind.

Note: Knuckles uses the same vertical borders while gliding and climbing. He's considered back on the ground when he starts to clamber over the corner of a wall, or stands up after sliding from a glide (i.e. when sliding, even though he is in contact with the ground, it still considers him to be in the air).

On the Ground

If Sonic's X is not equal to 96, the camera will move by the difference, up to 6 (if Sonic's Y speed is less than or equal to 6), or 16 (if Sonic's Y speed is more than 6). This makes the camera catch up slowly right after landing, but otherwise stay centred.

Looking Up and Down

  • Looking Up: Scrolls up by 104 pixels, at a rate of 2 per step.
  • Looking Down: Scrolls down by 88 pixels, at a rate of 2 per step.

In Sonic 1, the camera begins to scroll immediately when you press up or down. Obviously, this is annoying if there is to be a spindash or super peel out in your engine. In Sonic 2, 3 & K, the solution is to simply wait 120 steps after you begin to hold the button before it starts scrolling. In Sonic CD, though, another (IMO inferior) method is employed. After you press the up or down button, you have 16 steps to press it again, upon which the screen begins to scroll. The lame thing about this is that it will freeze the scrolling if you press the up or down button while the screen is already scrolling. For instance, look up by double-tapping, let go, and then press down. The screen will freeze, and stay there until you let go. Even initiating a spindash doesn't return things to normal.

In all the games, once you let go of up or down (also in Sonic 2, 3, & K, once you initiate a spindash), the camera scrolls back to the neutral position by 2 pixels per step.

Spindash/Airdash Lag

...not finished yet...

(Not in Sonic CD)

Sonic has a previous position table in memory. The game knows where he's been over the last several seconds with great precision. This is called upon for the spindash lag.

When the spindash is launched, a timer (t) is set to 32 (minus the rev variable, which can be between 0 and 8 - see spindash for more details). t then decreases by 1 every step.

While the timer is non-zero, the camera stops behaving normally and begins to move, not based on Sonic's current position, but his position t-1 steps ago. Once t runs out, the camera returns to business as usual.

The trouble with this lag is that if you initiate and release a spindash quickly enough after moving, the camera will actually move backward to follow where you've been.

The same lag routine happens when Sonic does the airdash as Hyper Sonic, or with the Flame Shield. However, the trick is when he launches, the entire previous position table is blanked out with his current position, so that the camera can't scroll backward. In your engine, if you do the same thing for the launch of a spindash, you won't have to worry about backward scrolling at all.

You can achieve an almost identical effect without a previous position table by simply disallowing the camera to move for about 16 steps after launching. This is somewhat easier to do.

Note: I actually don't care for the spindash/airdash lag all that much. You can live without it, as Sonic CD shows, and it can cause some pretty ugly camera movements when you spindash into a wall, or worse a red spring. You may consider leaving it out of your engine altogether.

Forward Shift (Sonic CD)

In Sonic CD only, when Sonic reaches an X speed of 6 (or is 16 steps into charging up a spindash or super peel out), the camera's X position begins to shift forward. It moves 64 pixels in total, 2 per step. When his X speed drops back below 6, it moves back. For some reason, it doesn't bother to check his X speed in order to activate or deactivate this shift while he is in the air, though. This can lead to an off-centre view. If you use this shift effect in your engine, I suggest doing the check while airborne as well.