Parallaxing background elements (Stages) (Read 8096 times)

Started by Just No Point, November 02, 2015, 04:33:10 PM
Share this topic:
Parallaxing background elements (Stages)
#1  November 02, 2015, 04:33:10 PM
  • ******
Parallaxing background elements give the illusion of depth for elements that appear to face upwards or downwards. Parallaxing background elements may consist of a single sprite specified by the spriteno parameter. In Version 1.1 and higher, parallax elements may be animated by specifying actionno like in ordinary animated background elements. Animated parallax may not be used with the xscale parameter.

An example of the format is as follows:

[BG my_parallax_element]
type = parallax
spriteno = 10, 0
width = 300, 600
scalestart = 1,1
scaledelta = 0,.001
Another example:

[BG my_parallax_element]
type = parallax
spriteno = 10, 0
xscale = 1,1.5
yscalestart = 100 ;Deprecated!
yscaledelta = 1.2 ;Deprecated!
Parameter descriptions follow:

width = top_width, bottom_width ; (int, int) top_width and bottom_width respectively specify the top and bottom widths of a trapezoid that has the same height as the sprite used. The sprite will be distorted to match the shape and size of the trapezoid. The ratio of top_width to bottom_width affects the amount of shearing as the camera moves horizontally. Use width if the sprite is not preprocessed for perspective distortion. For historical reasons, the x-axis specified in the SFF is ignored. The horizontal center of the sprite is used as the x-axis instead.

xscale = top_xscale, bottom_xscale ; (float, float) top_xscale and bottom_xscale respectively scale the horizontal delta of the background element's top and bottom edge to create a horizontal shearing effect. For example, delta = .75, .75 amd xscale = 1, 2 specifies the top of the sprite would move at .75 * 1 = .75 stage units per camera unit, and the bottom would move at .75 * 2 = 1.5 stage units per camera unit. This example assumes the sprite axis is at the top of the sprite.

Either xscale or width is required, but not both at the same time. Use xscale if the sprite has already been preprocessed for perspective distortion. Hardware accelerated rendering will have visual artifacts at extreme shear angles.

Animated parallax may not be used when xscale is used.

yscalestart = yscalestart ; (float) This deprecated parameter controls the change in vertical scale of the element as the camera moves vertically. Its functionality is replaced by the general-purpose scalestart and scaledelta advanced parameters.

yscalestart is the inverse of the vertical scale of the sprite when the camera is at ground level, represented in percentage. For example, a value of 100 corresponds to a scale factor of 1, and 50 corresponds to a scale factor of 2. The value defaults to 100.

yscaledelta = yscaledelta ; (float) Specifies the amount to add from the inverted scale factor for every camera unit the camera moves down, represented in percentage. The final scale factor is calculated using the following formula:

scale = 1 / (yscalestart/100 + yscaledelta/100 * camera_y)
In the example above, if the camera moves up by one unit, the scale factor will be 1 / (1.00 + .012 * -1) = 1.012, and if it moves up another unit, the scale will be 1 / (1.00 + .012 * -2) = 1.025 and so on.

The unintuitive behavior for the yscalestart and yscaledelta parameters is the reason for deprecating these parameters in favor of the scalestart and scaledelta parameters.

1.1b and higher
scalestart = scale_x, scale_y ; (float, float) Starting scale. Defaults to 1,1.

scaledelta = scale_dx, scale_dy ; (float, float) Similar to the delta parameter, this is the amount to change the scale of the element for each unit of camera movement. Defaults to 0,0.

Other parameters for static elements are also valid for parallax elements, with the exception of tilespacing. Additionally, y_tile is ignored and forced to be 0.

The result of specifying an angle in an animated parallax element is undefined.

The software renderer does not support animated parallax.
Last Edit: August 01, 2017, 12:24:06 PM by Odb718
Re: Parallaxing background elements (Stages)
#2  June 14, 2018, 07:18:27 AM
  • *****
  • Shame on you!
    • USA
This is a method for figuring out your character's placement on a stage you're recreating. This helps if your character looks like it's sliding around when P2 moves the background.
Parallax tutorial by VIB

As I find more links that are useful figuring out how to control the Parallax scrolling I'll link them here.
If anyone has info on this, please post!
vVv Wheat Stage Released vVv