Hello!, I'm making an 3rd person perspectiv adventure game with DBP and I need help with the Collision function.
Here's my code:
rem fix resolution for best performance
sync on : hide mouse : sync rate 120 : set global collision on : autocam off : sync
if check display mode(1024,768,32)=1 then set display mode 1024,768,32
sync
rem fix light and fog
set ambient light 100
fog on
fog distance 10000
fog color rgb(255,255,255)
set normalization on
color backdrop rgb(255,255,255)
rem add colours
blue = RGB(0,128,255)
white = RGB(255,255,255)
rem make loading screen
ink blue,0
center text screen width()/2,screen height()/2,"Loading..."
sync : sync
rem make skybox
load image "D:LEAFDarkbasictexturesky.bmp",3
load object "D:LEAFDarkbasicmodelsskybox.x",3
scale object 3,5000,5000,5000
texture object 3,3
position object 3,900,200,1000
sync
rem make matrix
mapsize=3000
make matrix 1,mapsize,mapsize,4,4
load image "D:LEAFDarkbasictexturegrasss.bmp",1
load image "D:LEAFDarkbasictexturewood.bmp",2
prepare matrix texture 1,1,1,1
randomize matrix 1,50.0
update matrix 1
sync
rem load character
load object "D:LEAFDarkbasicmodelsidle.x",1
append object "D:LEAFDarkbasicmodelswalk.x",1,21
set object smoothing 1,100
yrotate object 1,180 : fix object pivot 1
loop object 1,0,20 : set object speed 1,10
scale object 1,100,100,100
texture object 1,2
sync
rem load house
load object "D:LEAFDarkbasicmodelshouse.3ds",2
position object 2,500,0,500
yrotate object 2,180 : fix object pivot 2
scale object 2,250,250,250
texture object 2,2
sync
rem load second house
load object "D:LEAFDarkbasicmodelshouse.3ds",4
position object 4,900,0,1200
yrotate object 4,180 : fix object pivot 4
scale object 4,250,250,250
texture object 4,2
sync
rem load mountains
load image "D:LEAFDarkbasictextureMountain Stone.bmp",4
load object "D:LEAFDarkbasicmodelsmountains.x",5
position object 5,2800,0,2000
yrotate object 5,180 : fix object pivot 5
scale object 5,700,500,540
texture object 5,4
sync
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
If you could fix my code so it has a Collision thing I would be very thankful.
I've another code that I want in my game but can't seem to get it in right can you fix it to?
rem make advance mouse camera
do
if camera angle x()<90 and camera angle x()>270
yrotate camera wrapvalue(camera angle y()+mousemovex())
xrotate camera wrapvalue(camera angle x()+mousemovey())
else
yrotate camera wrapvalue(camera angle y()-mousemovex())
xrotate camera wrapvalue(camera angle x()+mousemovey())
endif
loop
This code should make a camera so you can look around with the mouse.
If you could fix both things the game would be so much better.
And one more thing. I was wondering if it's possible to make 2 cameras, because in my game when you're in a house I want it to be 1st person perspective and when you'r out it's going to be 3rd person perspectiv is that possible?