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.

Newcomers DBPro Corner / first person shooter

Author
Message
gareth
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Dec 2002 22:51
can anyway help me, i need to know how to do collisions in a fps game heres my code, please can someone help, i wanna make it collide with object 3, object 10 is the player..help!!

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
set object collision on 10
position object 10,CamX#,CamY#,CamZ#

lock object on 10
make object cube 3,200
position object 3,500,0,500
set object collision to boxes 3
set object collision on 3

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

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


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
X# = CamX#
Y# = CamY#
Z# = CamZ#
endif


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



REM REFRESH AND END OF MAIN LOOP
Sync
Loop
gareth
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Dec 2002 22:53
okay ignore code from above it pasted wrong, hav alook at this and see if u can tell me how to make it collide



Flames DB
21
Years of Service
User Offline
Joined: 10th Dec 2002
Location:
Posted: 11th Dec 2002 00:21
hi use maths collision/sliding collision available in db v1.13 in the help section under sliding collision, i think that is the best and fastest collision, much faster than db collision
ok m8

if you dont attempt to test your ideas, you'll never be sure if your program works better.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 13th Dec 2002 02:28
First try deleting set object collision on commands, you don't need both set object collision spheres and set object collision on commands. Second I found that using the vairable x#,y#,z# are default and always = 0,0,0 try something different like cpx#.

The coffee is lovely dark and deep and I have code to write before I sleep

Login to post a reply

Server time is: 2024-04-16 05:51:14
Your offset time is: 2024-04-16 05:51:14