Scripts:Fake Parallax
From OHRRPGCE-Wiki
Since Alectormancy it is possible to fake parallax scrolling of map layers using plotscripting.
This example script, adapted from Wandering Hamster, requires one timer, and assumes that layer 0 of the map is 1/3 the width and 1/3 the height of the rest of the map. If you want your background layer to be some other size, you can customize the lines that set the layerw and layerh variables.
To use this script, you will also need to copy all of the scripts on the Scripts:hero will move page, including the next leader pixel x/y and next camera pixel x/y scripts, into your scripts file. The parallax script will break if you do certain things, such as use camera follows npc; see the comments on the Scripts:hero will move page.
define constant(4, troll mountain parallax timer) plotscript, troll mountain autorun, begin update troll mountain parallax end script, update troll mountain parallax, begin variable(sl, mapw, maph, screenw, screenh, layerw, layerh) if(current map <> map:troll mountain) then( stop timer(troll mountain parallax timer) #(The following is only needed if 'recreate map slices when leaving map' is off) sl := lookup slice(sl:map layer 0) set slice x(sl, 0) set slice y(sl, 0) exit script ) mapw := map width * 20 maph := map height * 20 screenw := slice width(sprite layer) screenh := slice height(sprite layer) layerw := mapw / 3 # e.g. 50 * 20 pixels layerh := maph / 3 # e.g. 20 * 20 pixels sl := lookup slice(sl:map layer 0) calculate next camera pixel xy set slice x(sl, (next camera pixel x * (mapw -- layerw) / (mapw -- screenw))) set slice y(sl, (next camera pixel y * (maph -- layerh) / (maph -- screenh))) # Set the script to run again next tick set timer(troll mountain parallax timer, 0, 1, @update troll mountain parallax) end