Making 2D fx for 3D by Asirius Belendor4th Jul 2006 13:22
|
---|
Summary Making aliasing, motion blur, and other fx... Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com REM ASIRIUS BELENDOR 2006 (C) motion_blur=255 REM Temp values if check display mode(1024,768,32)=1 then set display mode 1024,768,32,1 `=================================================================================== REM setup sync rate 60 hide mouse draw sprites first autocam off `=================================================================================== make object box 1,1,1,1 move object 1,2 do sync on rotate object 1,wrapvalue(temp*yro),wrapvalue(temp*yro),wrapvalue(temp*yro) if inkey$()="1" then motion_blur=120 if inkey$()="2" then motion_blur=255 if inkey$()="3" then yro=1 if inkey$()="4" then yro=5 if inkey$()="5" then bloom_on=1 if inkey$()="6" then bloom_on=0 if inkey$()="7" then spec=1 if inkey$()="8" then spec=2 if inkey$()="9" then spec=3 if inkey$()="0" then spec=0 update_fx(motion_blur,bloom_on,spec,temp) `fx ink rgb(255,255,255), 0 text 10,10,"Polygons: "+str$(statistic(1)) `statistic text 10,25,"FPS: "+str$(screen fps()) text 10,40,"Use 1/2 to make on/off motion blur" text 10,55,"Use 3/4 to rotate box" text 10,70,"Use 5/6 to make on/off soft" text 10,85,"Use 7/8/9/0 to make on/off misc fx" inc temp sync off loop `=================================================================================== function update_fx(alpha,bloom_on,spec,temp) `fx REM Prepare color backdrop 0 set camera to image 0,100000,1024,1024 sprite 100000,0,0,100000 set sprite 100000,0,1 size sprite 100000,screen width(),screen height() REM Motion blur set sprite alpha 100000,alpha REM Soft if bloom_on=1 if sprite exist(100001)=0 sprite 100001,screen width()/2,screen height()/2,100000 set sprite 100001,0,1 offset sprite 100001,screen width()/2,screen height()/2 set sprite alpha 100001,35 clone sprite 100001,100002:clone sprite 100001,100003 clone sprite 100001,100004:clone sprite 100001,100005 size sprite 100001,screen width()+10,screen height()+10 size sprite 100002,screen width()+5,screen height() size sprite 100003,screen width()+10,screen height() size sprite 100004,screen width(),screen height()+5 size sprite 100005,screen width(),screen height()+10 endif set ambient light 25 show sprite 100001:show sprite 100002 show sprite 100003:show sprite 100004 show sprite 100005 else if sprite exist(100001)=1 hide sprite 100001:hide sprite 100002 hide sprite 100003:hide sprite 100004 hide sprite 100005 endif set ambient light 20 endif REM Misc fx REM Quake if spec=1 paste sprite 100000,0+rnd(2)-rnd(2),0+rnd(2)-rnd(2) endif REM Unnormal if spec=2 if sprite exist(100006)=0 sprite 100006,screen width()/2,screen height()/2,100000 offset sprite 100006,screen width()/2,screen height()/2 set sprite 100006,0,1 size sprite 100006,screen width(),screen height() set sprite alpha 100006,25 clone sprite 100006,100007:clone sprite 100006,100008 clone sprite 100006,100009 endif rotate sprite 100006,wrapvalue(temp) rotate sprite 100007,360-wrapvalue(temp) rotate sprite 100008,wrapvalue(180+temp) rotate sprite 100009,wrapvalue(180-temp) show sprite 100006:show sprite 100007 show sprite 100008:show sprite 100009 else if sprite exist(100006)=1 hide sprite 100006:hide sprite 100007 hide sprite 100008:hide sprite 100009 endif endif REM Lines if spec=3 for t=1 to 100 sprite 100010+(t-1),0,(t-1)*(screen height()/100),100000 size sprite 100010+(t-1),screen width(),screen height()/100 set sprite alpha 100010+(t-1),10 show sprite 100010+(t-1) next t else if sprite exist(100010)=1 for t=1 to 100 hide sprite 100010+(t-1) next t endif endif endfunction |