Best 3rd person perspective view for your games by LEAF2nd Nov 2008 9:20
|
---|
Summary A simple 3rd person perspective view for your games. NOTE: This is just a camera function so you can't just put this code in DBP and compile. Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com rem make camera function x#=500 y#=500 do stage=0 if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10) : stage=1 if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10) : stage=1 if leftkey()=1 then a#=wrapvalue(a#-3.0) if rightkey()=1 then a#=wrapvalue(a#+3.0) if stage <> oldstage if stage = 0 set object frame 1,0.0 loop object 1,0,20 set object speed 1,10 endif if stage = 1 set object frame 1,105.0 loop object 1,105,125 set object speed 1,40 endif oldstage = stage endif y# = get ground height (1,x#,z#)+0.0 position object 1,x#,y#,z# yrotate object 1,a# cx# = newxvalue (x#,wrapvalue(a# + 180),300) cz# = newzvalue(z#,wrapvalue (a# + 180),300) cy# = get ground height (1,cx#,cz#) + 100.0 position camera cx#,cy#,cz# point camera x#,y#,z# sync loop y# = get ground height (1,x#,z#)+0.0 position object 1,x#,y#,z# yrotate object 1,a# cx# = newxvalue (x#,wrapvalue(a# + 180),300) cz# = newzvalue(z#,wrapvalue (a# + 180),300) cy# = get ground height (1,cx#,cz#) + 100.0 position camera cx#,cy#,cz# point camera x#,y#,z# sync |