Back

Backgrounds fill in the background to every map. You can't interact with them but you can see them. Some backgrounds are in the foreground such as clouds and they can obscure your view.

In the map

 * back
 * [id number]
 * bS - The background set that contains the background.
 * front - Whether the background is actually a foreground.
 * ani - Whether the background is animated.
 * no - Which background to load from the set.
 * f - Whether the background is flipped over the y-axis.
 * x - The x coordinate of the background.
 * y - The y coordinate of the background.
 * rx - Determines the parallex speed along the x-axis.
 * ry - Ditto for the y-axis.
 * type - Determines tiling and movement.
 * cx - Replaces the sprite's width for tiling if nonzero.
 * cy - Ditto for the height.
 * a - The alpha transparency of the background.

In the background set
1 indicates horizontal bobbing. 2 indicates vertical bobbing. 3 indicates spinning motion.
 * back - If the background is not animated.
 * [the no of the background]
 * width - The width of the sprite.
 * height - The height.
 * origin - The sprite's offset from it's coordinates.
 * x - The x offset.
 * y - The y offset.
 * z - Unused.
 * ani - If the background is animated.
 * [the no of the background]
 * width - The width of the sprite.
 * height - The height.
 * origin - The sprite's offset from it's coordinates.
 * x - The x offset.
 * y - The y offset.
 * z - Unused.
 * a0 - The alpha at the beginning of the frame. [optional]
 * a1 - The alpha at the end of the frame. [optional]
 * delay - The delay in milliseconds before the next frame is loaded. [optional]
 * moveType - The type of spinning or bobbing motion it does. [optional]
 * moveR - How fast the background spins.
 * moveP - How fast the background bobs.
 * moveW - How far the background bobs horizontally.
 * moveH - How far the background bobs vertically.

Loading Backgrounds

 * 1) Iterate through all the background data in the map.
 * 2) For each back, find by the background set by navigating to Map.wz/Back/[bS].
 * 3) If ani is true navigate into the ani section. Otherwise navigate into the back section.
 * 4) Find the background whose number is equal to the no in the map data.
 * 5) Load in all the data from both the map and the background set for that back.

Calculating Position and Stuff
Keep track of the time since the last frame (delta) and also a continuous timer which never loops (tdelta). Do this in milliseconds (or convert if you feel like it).

Dealing with Parallex
If you already account for the view then calculating the parallex offset of the background (bx, by) in relation to the view (vx, vy) is fairly simple

bx = (100+rx)/100*vx; by = (100+ry)/100*vy;

If you have to account for the view in computing the offset then you can do

bx = rx/100*vx; by = ry/100*vy;

Uh, someone needs to check that and probably fix it.

Dealing with moveType
moveType is basically bobbing or rotation allowing for smooth motion without having to animate it all.

If moveP is nonzero then that affects the speed of the bobbing.

If moveType is 1, you have horizontal bobbing

With moveP

ax = moveW*sin(tdelta*1000*2*pi/moveP);

Without moveP

ax = moveW*sin(tdelta);

If moveType is 2, you have vertical bobbing

With moveP

ay = moveH*sin(tdelta*1000*2*pi/moveP);

Without moveP

ay = moveH*sin(tdelta);

For the sin function, replace the 2*pi with 360 if your programming language uses degrees instead of radians If moveType is 3, you have rotationimage_angle = tdelta*1000/mover*360/2/pi;

Get rid of the *360/2/pi at the end if your programming language uses radians for rotation instead of degrees.