Hey, and welcome to a tutorial by flashing snall.
In this tut you will be shown how do achive some okay 2d motion blurring effects without using more sprites, its actually very simple.
first, you must know what the
set sprite sprite num,backsave,transparacy
command does. the set sprite command is used to decide weather or not a sprite has its previous destination recorded and its background rendered to the screen.
if you use the set sprite command to this, were n is the sprite number
set sprite n,0,1
your sprite will leave its trail behind it. so if you make a code like this, you get a box that leaves a white trail were ever it goes
box 0,0,20,20
get image 1,0,0,20,20,1
cls
sprite 1,screen width()/2,screen height()/2,1
offset sprite 1,sprite width(1)/2,sprite height(1)/2
set sprite 1,0,1
do
if upkey()=1
move sprite 1,.01
endif
if downkey()=1
move sprite 1,-.01
endif
if rightkey()=1
rotate sprite 1,sprite angle(1)+.1
endif
if leftkey()=1
rotate sprite 1,sprite angle(1)-.1
endif
loop
Now we want something like this but, that doesnt leave an annoying trail
if we add a background sprite that pastes itself over the previous destination, but not over the new destination, we may be able to achive that. However, we want the background sprite to refresh at a controlled rate so we can control the intensity of the blurring. so if we add something like this to our code...
observe.....
if sprite exist(2)
delete sprite 2
endif
if blur=10
sprite 2,0,0,1
stretch sprite 2,1000,1000
set sprite diffuse 2,255,0,0
set sprite alpha 2,200
blur=0
inc blur
endif
make sure you add that BEFORE the player controls in the other code. so it looks like this
box 0,0,20,20
get image 1,0,0,20,20,1
cls
sprite 1,screen width()/2,screen height()/2,1
offset sprite 1,sprite width(1)/2,sprite height(1)/2
set sprite 1,0,1
do
if sprite exist(2)
delete sprite 2
endif
if blur=10
sprite 2,0,0,1
stretch sprite 2,1000,1000
set sprite diffuse 2,255,0,0
set sprite alpha 2,200
blur=0
endif
if upkey()=1
move sprite 1,.01
endif
if downkey()=1
move sprite 1,-.01
endif
if rightkey()=1
rotate sprite 1,sprite angle(1)+.1
endif
if leftkey()=1
rotate sprite 1,sprite angle(1)-.1
endif
inc blur
loop
and woolah, motion blur..........
after messing with the settings, you can get some nice results, see new code and the screenie.
box 0,0,20,20
get image 1,0,0,20,20,1
cls
sprite 1,screen width()/2,screen height()/2,1
offset sprite 1,sprite width(1)/2,sprite height(1)/2
set sprite 1,0,1
do
if sprite exist(2)
delete sprite 2
endif
if blur=4
sprite 2,0,0,1
stretch sprite 2,10000,10000
set sprite diffuse 2,5,0,0
set sprite alpha 2,50
blur=0
endif
if upkey()=1
move sprite 1,.5
endif
if downkey()=1
move sprite 1,-.5
endif
if rightkey()=1
rotate sprite 1,sprite angle(1)+.1
endif
if leftkey()=1
rotate sprite 1,sprite angle(1)-.1
endif
inc blur
loop