Here are some examples of
parallax distances. For this example, i have a wall which will be near the player, trees a few yards behind that, ruins 100's of yards behind that, and mountains several miles beyond that.
Here are 3 ways to look at the distances.
The clouds scroll only because they actually move; You don't have to apply
parallax to clouds. In the end, the sky is sea of blue that effectively stops our vision in the daytime, with such a tiny amount of arc at that distance so as to be virtually 0.
This picture illustrates the question: Which of the 3 important slices will you draw? obviously a random slice of grass between ruins and mountains does not help our cinema and isn't drawn. the slice containing the ruins however, does help our cinema and is drawn.
An objects 'scroll ratio' is the ratio of distance to 0 and distance to 100%.
Thus an object roughly the same size as the viewer, locate halfway between the sky and viewer, probably has a ratio of only 10 %.
Remember of course, anything above 95% is right in the viewer's face and blocking the view.
Anything under 5 percent is practically on the mountains, and will not show signifigant difference from them.
You can then use this ratio inversely to player.x, as in
mountain.x=player.x*.99;
and a 10% object is ruins.x=player.x*.90;
this is assuming, of course, that view is following player. It also assumes that player is at 100%, which usually he isn't. In my ninja demo, however, there is no player, only you, the viewer, at 100%.
So you can use this bell curve to designate the size and speed of a layer based off of the distance;
Next step is calculating the amount of ambient lighting and the y position of everything. These will still follow the curve, but with modifiers; the light is modified by the position of the source (sun) and then height is modified by the actual height of the objects.
The light is additionally modified by other factors, such as air refraction or reflection(if there's a pool of water in front of the castle).
This is about the point where some people are going to go reaching for raytracing and 3d software; but I'm not, and i have no plans to, and i'll tell you why:
3d and lighting engines are based on real physics; getting the angles accurate is job one.
2d engines are based on cinematic physics; looking good is job one.
in 2d art and animation, the numbers are determined by what has the most impact on the viewer with the least amount of work by the creator. The faster something can be achieved, the more time can be spent on polishing the important aspects of the game (this is prime in cartoon animation as well). Also, the simpler something can be achieved, the more focused the viewer will be on those things; its much easier to listen to someone if you're not in a busy crowd.
I often find myself mistaking a powerup for an enemy or vice versa in a 3d shooter, when it was off in the distance.
The purpose of this brainstorm is to determine how much realism is needed in order to get the desired result: a successful game. In the end, that's the goal: a successful game. You can break all the rules and still get there.
Parallax doesn't have to be
accurate. It only has to be
believable!