Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / help with FPS collision

Author
Message
gareth
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Dec 2002 20:48
can anyone help, me, can u tell me why you it wont collide with the cube (object 3) object 10 is the object placed as the collsion detector
heres the code:

REM SET UP SYNC
sync on
sync rate 30
hide mouse

REM LOAD IMAGES
load image "creep02.bmp",1

REM CREATE MATRIX
make matrix 1,2000,2000,50,50
prepare matrix texture 1,1,2,2
randomize matrix 1,10

REM PLACE THE TEXTURE TILES ONTO THE MATRIX
for x = 0 to 19
for z = 0 to 19
t = rnd(3) +1
set matrix tile 1,x,z,t
next z
next x

REM UPDATE CHANGES TO THE MATRIX
update matrix 1

REM LOAD COL OBJECT
make object sphere 10,10
set object collision to spheres 10
position object 10,CamX#,0,CamZ#
lock object on 10
make object cube 3,200
position object 3,500,0,500
set object collision to boxes 3

rem Make Gun
Make object cylinder 1,2
XRotate Object 1,90
Fix object pivot 1
Scale object 1,100,100,500
position object 1,0,-7,15
Lock object on 1



REM MAIN LOOP////////////////////////////////////////////////////////
Do

CamX# = Camera position X()
CamZ# = Camera position Z()

OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#

CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)

REM CONTROL INPUT FOR CAMERA

If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 and XTest#0 and ZTest#0 then position camera CamX#,0,CamZ#

REM REFRESH AND END OF MAIN LOOP
Sync
Loop
QuothTheRaven
21
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 8th Dec 2002 22:17
what the hell is

that's your problem. You only have one operator ">". With each variable you need an operator, like < > <> <= >= etc etc. With that it just tests if each variable exists (is not 0)
gareth
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Dec 2002 23:02
one sec, thats sorta mixed up, it's put everything on one line, can.

REM MAIN LOOP////////////////////////////////////////////////////////
Do

CamX# = Camera position X()
CamZ# = Camera position Z()

OldCamAngleY# = CameraAngleY#
OldCamAngleX# = CameraAngleX#

CameraAngleY# = WrapValue(CameraAngleY#+MousemoveX()*0.2)
CameraAngleX# = WrapValue(CameraAngleX#+MousemoveY()*0.2)

REM CONTROL INPUT FOR CAMERA

If Upkey()=1
XTest# = Newxvalue(X#,CameraAngleY#,10)
ZTest# = Newzvalue(Z#,CameraAngleY#,10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif

If Downkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#-180),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-180),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif

If Leftkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#-90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#-90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif

If Rightkey()=1
XTest# = Newxvalue(X#,Wrapvalue(CameraAngleY#+90),10)
ZTest# = Newzvalue(Z#,Wrapvalue(CameraAngleY#+90),10)
If XTest#>0 and XTest#<10000 and ZTest#>0 and ZTest#<10000
X#=XTest#
Z#=ZTest#
Endif
Endif

Yrotate camera CurveAngle(CameraAngleY#,OldCamAngleY#,24)
Xrotate camera CurveAngle(CameraAngleX#,OldCamAngleX#,24)

Y# = Get ground height(1,X#,Z#)
Position Camera X#,Y#+50,Z#

if object collision(10,0)>0 then position camera CamX#,0,CamZ#

REM REFRESH AND END OF MAIN LOOP
Sync
Loop

gareth
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 8th Dec 2002 23:03
yer thats what it should look like, now whats wrong with it? why wont it collide? please help!

Shadow
21
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 9th Dec 2002 13:16
you need to use commands like

or

to activate collision detection

Login to post a reply

Server time is: 2024-04-26 16:17:41
Your offset time is: 2024-04-26 16:17:41