Here are some functions I've been using for camera shake:
type shakeT
rad as float
offsetX as float
offsetY as float
randomAngle as float
lastTime as float
endtype
global shaking as integer
global shaks as shakeT
function Shake()
if shaking=1
shaks.rad = 0.6
shaks.lastTime=timer()
shaks.randomAngle = random(0,360)
shaks.offsetX = sin(shaks.randomAngle) * shaks.rad
shaks.offsetY = cos(shaks.randomAngle) * shaks.rad //create offset 2d vector
SetViewOffset(shaks.offsetX,shaks.offsetX)
shaking=2
elseif shaking=2
if timer()-shaks.lastTime>0.1
shaks.lastTime=timer()
shaks.rad=shaks.rad*0.95 //diminish radius each frame
shaks.randomAngle=random(1,360)
shaks.offsetX = sin(shaks.randomAngle) * shaks.rad //create offset 2d vector
shaks.offsetY = cos(shaks.randomAngle) * shaks.rad //create offset 2d vector
SetViewOffset(shaks.offsetX,shaks.offsetY)
if shaks.rad<0.2 then shaking=3
endif
elseif shaking=3
SetViewOffset(0,0)
shaking=0
endif
endfunction
Just call Shake() every frame [ ie right before Sync()]. When you want to shake the screen just use 'shaking=1'.