About the shader camera... like the earthquake feature it currently pans the camera off screen, so that you can see black on the outside. I'm not sure if you want it to do that or not, but I've asked Simon if he can add me a couple entries in the data structure at some point (when he can) which will allow me to prevent the camera from going off the screen by checking the current scroll position against the game resolution & the scene background width & height.
quick example of random value using math.random function...
math.random(100) -- will generate a random value between 0 & 100
math.random(5, 20) -- generate a random value between 5 & 20 etc...
quick example of random earthquake using shaderPan() function...
local pos -- variable which will be used to store current scroll position
local tx = 0 -- variable which will store previous time value for x
local ty = 0 -- variable which will store previous time value for y
local dx = 0 -- variable which will be used to store random delay value for x pan
local dy = 0 -- variable which will be used to store random delay value for y pan
local rx, ry -- variables used to store random offset values for x & y
function loopQuake()
pos = game:getPoint(VGameScrollPosition)
-- x --
if tx == 0 or getTime() >= tx + dx then
rx = math.random(-10, 10)
dx = math.random(1000, 3000)
shaderPan(pos + rx, -1, dx, easeBounceOut)
tx = getTime()
end
-- y --
if ty == 0 or getTime() >= ty + dy then
ry = math.random(-10, 10)
dy = math.random(1000, 3000)
shaderPan(-1, pos + ry, dy, easeBounceOut)
ty = getTime()
end
end
function startQuake()
registerEventHandler("mainLoop", "loopQuake")
end
function endQuake()
unregisterEventHandler("mainLoop", "loopQuake")
end
...I've written this off the top of my head & have no clue if it will work or not. You will need to include the latest version of the shader toolkit script as I've just updated the shaderPan function.
To start earthquake, just create an execute a script action part containing...
...to end earthquake, same again but containing...
Quick explanation of the script I've written above: I've made it so that when you execute the startQuake() function it creates a loop (defined in the loopQuake function) which does all the random calculations & random delay values. You start & end the earthquake with the examples I provided above. The main script should be included as a definition script.