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 / collision help

Author
Message
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 15th Dec 2002 17:59
hi in my game that i'm currently making i can't get the collision to work i looked at the collision help in the help section but it still doesn't help and last time i asked people gave me a distance code but i can't get that to work i'm trying to get a box around the camera then hide it to help but i can't seem to do that ever so could somebody please help here are my game codes so far:

Sync On
Sync Rate 30

hide mouse

Backdrop on
Set camera range 1,5000

Color Backdrop RGB(0,0,0)
`Color Backdrop RGB(128,128,128)


Rem make matrix
Make matrix 1,10000,10000,20,20

Rem texture matrix
Load image "floor.bmp",1
Prepare matrix texture 1,1,1,1
Fill matrix 1,0,1

rem Make Gun
`Make object cylinder 1,2
load object "h-mp5-static.3ds",1
`XRotate Object 1,90
Fix object pivot 1
Scale object 1,4500,2500,3500
position object 1,0,-10,15
Lock object on 1

Rem Make bullet
Make Object Sphere 2,1
Hide Object 2

rem Crosshair
make object plain 3,21,21
load image "crosshair.bmp",2
texture object 3,2
delete image 1
move object 3,400
ghost object on 3
lock object on 3

rem health
load image "health.bmp",3
make object cylinder 4,100
`XRotate Object 4,90
Fix object pivot 4
`Scale object 4,100,100,500
Scale object 4,10,0,10
`position object 4,0,-7,15
position object 4,-8,-6,10
rotate object 4,90,0,0
texture object 4,3
ghost object on 4
Lock object on 4

rem make walls for level
load image "wall4.bmp",4
load image "ceil2.bmp",5
load image "floor.bmp",6
load image "door.bmp",7

make object box 5,25,150,1500
position object 5,-10,75,750

make object box 6,25,150,1300
position object 6,200,75,650

make object box 7,195,10,1500
position object 7,90,150,750

make object box 8,205,150,25
position object 8,95,75,1500

make object box 9,25,50,200
position object 9,195,20,1400

make object box 10,300,5,200
position object 10,320,100,1400
rotate object 10,0,0,25

make object box 11,500,5,200
position object 11,705,165,1400

make object box 12,300,100,5
position object 12,320,150,1300
rotate object 12,0,0,25

make object box 13,300,100,5
position object 13,320,150,1500
rotate object 13,0,0,25

make object box 14,290,5,200
position object 14,315,200,1400
rotate object 14,0,0,25

make object box 15,205,150,25
position object 15,95,75,10

make object box 16,500,5,200
position object 16,695,260,1400

make object box 17,520,100,5
position object 17,700,210,1300

make object box 18,520,100,5
position object 18,700,210,1500

make object box 19,120,5,200
position object 19,1010,195,1400
rotate object 19,0,0,25

texture object 5,4
texture object 6,4
texture object 7,5
texture object 8,4
texture object 9,4
texture object 10,6
texture object 11,6
texture object 12,4
texture object 13,4
texture object 14,4
texture object 15,7
texture object 16,4
texture object 17,4
texture object 18,4

rem make first weapon to pick up
load object "h-mp5-static.3ds",20
scale object 20,6500,6500,6500
position object 20,50,10,1400



Rem Main loop
Do
yrotate object 20,wrapvalue(object angle y(20)+2)

set cursor 0,0

oldcAY# = cAY#
oldcAX# = cAX#

oldX#=X#
oldY#=Y#
oldZ#=Z#

cAY# = WrapValue(cAY#+MousemoveX()*0.2)
cAX# = WrapValue(cAX#+MousemoveY()*0.2)
caZ# = Camera angle Z()

Rem Control input for camera
If Upkey()=1
XTest# = Newxvalue(X#,cAY#,15)
ZTest# = Newzvalue(Z#,cAY#,15)
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
Dec BulletLife
Move object 2,20
if BulletLife = 0 then Hide object 2
Endif

Rem Rotate camera
cTestX#=WrapValue(cAX#-180)
if cTestX# > 225 then cAX#=45
if cTestX#
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 15th Dec 2002 18:01
sorry but not all my codes are showing i'll see if i can sort it:

John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Dec 2002 19:34
Collision in DB is really screwed up. You need to save the objects coordinates and make it so if the object is inside a certain area then the object keeps its coordinates.

You need to make it so if the object is inside the selected area, then the objects position stays the same.

I hope this makes sense to you-

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 15th Dec 2002 22:46
well it doesn't quite make sense please could u explain further with a tutorial and do u know how to get an object an get the camera to stay in it.

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 15th Dec 2002 22:55
For the camera- just store an objects coordinates as x= and y= etc. then position camera at those coordinates and maybe adjust them a little bit if it is needed, like position camera x+10,y,z

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
dark coder
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 15th Dec 2002 22:58
cloud this snipp just finds the center of the 4 cords, and if the x>the point but in the box it will place the object/player at the box boundaries.

if you use the code please credit me :¬)





set camera range 1,1000000

make object cube 1,10


make object cube 2,100 : color object 2,rgb(0,255,0) : ghost object on 2

position object 1,100,0,0
position object 2,0,0,0
position camera 0,400,0
point camera 0,0,0

sync on

do

oldx#=x#
oldz#=z#

if upkey()=1 then move object 1,2
if downkey()=1 then move object 1,-2

if leftkey()=1 then turn object left 1,10
if rightkey()=1 then turn object right 1,10

x#=object position x(1)
y#=object position y(1)
z#=object position z(1)

set cursor 0,0

print "x: ",x#
print "y: ",y#
print "z: ",z#


if z#>-50 and z#<50 and x#<50 and x#>-50 : `and y#>-50 and y#<50

if abs(x#) > abs(z#)
if x# > 0
x#=50
else
x#=-50
endif
else
if z# > 0
z#=50
else
z#=-50
endif
endif

if y# > 0
y#=50
else
y#=-50
endif

endif


position object 1,x#,0,z#


sync
loop

l8er

----- dark coder -----
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 16th Dec 2002 17:34
thanks dark coder but does anyone know how to put the camera in a box on a matrix and make collision on that.

please help
cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 17th Dec 2002 13:57
?????????? camera in a box? Why?

RPGamer

PS- DCs collision works best

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 18th Dec 2002 21:01
but how do u do that?

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 19th Dec 2002 03:57
I was asking for clerification. I dont know what you mean by camera in box.

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 19th Dec 2002 21:52
i meant that in a first person shooter game u have a gun that follows u but i want a box that is around the camera so that u can't see it but u can put collision on it but if u know camera collision then that will do nicely.

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 20th Dec 2002 03:49
I posted over at RGT about this

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 21st Dec 2002 15:54
okay but can u give me the address to get this then please.

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 21st Dec 2002 23:16
http://www.realgametools.net/forums/index.php?board=3;action=display;threadid=10837

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 22nd Dec 2002 14:58
okey that didn't make any sense but the part of putting a box under the camera aint a bad idea but still how do i do that.

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 22nd Dec 2002 19:11
I posted again on the same topic. You need to position the camera above the box like.....

load object "myplayer.x",1
make object cube blah blah blah

playerposx= object position x(1)
playerposy= object position y(1)
playerposz= object position z(1)

boxx= object position x(1) + 10
boxy= object position y(1)
boxz= object position z(1) + 10

position camera boxx, boxy+30,boxz
point camera playerposx,playerposy,playerposz+10

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 22nd Dec 2002 19:13
REM make your objects
load object "myplayer.x",1
make object cube 2,50

REM this is the coordinates of the player
playerposx= object position x(1)
playerposy= object position y(1)
playerposz= object position z(1)

boxx= object position x(1)
boxy= object position y(1)
boxz= object position z(1) -10

REM this will position the object using the coordinates a little behind the object.
position object 2,boxx,boxy,boxz

REM this will always put the camera above the box
position camera boxx,boxy+30,boxz

REM now point the camera at the player
point camera playerposx,playerposy,playerposz+10

There nice and remmed for ya

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 24th Dec 2002 15:49
thanks and i know i'm getting quite anouying but when i add this stuff to my game i still can't get it to work here are my codes if this is any help to u to help me:

John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 24th Dec 2002 17:35
You should only have 2 characters. One that the camera points at, and a box that follows it.REM make your objects
load object "myplayer.x",1
make object cube 2,50

REM this is the coordinates of the player
playerposx= object position x(1)
playerposy= object position y(1)
playerposz= object position z(1)

boxx= object position x(1)
boxy= object position y(1)
boxz= object position z(1) -10

REM this will position the object using the coordinates a little behind the object.
position object 2,boxx,boxy,boxz

REM this will always put the camera above the box
position camera boxx,boxy+30,boxz

REM now point the camera at the player
point camera playerposx,playerposy,playerposz+10

Like that

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 25th Dec 2002 23:59
but y do i have to have a player if it's a first person shooter and basicly the gun in my codes is the sort of player in it so will i make the player the gun and get itr to follow but even then i still have the problem that i don't know how to use the collision codes in db cus i'm needing to get more than one collision on the objects one for the walls and different ones for the enemies so how do i do that exacly.
sorry for all the hasle, and hope u have a good x-mas and a happy new year.

cloud
John H
Retired Moderator
21
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 26th Dec 2002 01:04
Well its easier if you have no player. Just have a box for your character (trust me) and position the character at the same coordinates at the box, just a little above it. Then you can code the collision for the box

RPGamer

Current - RPG: Eternal Destiny : Help Wanted!
Upcoming- MMOFPS- Paintball Game: HELP WANTED!
Http://halbrosproductions.netfirms.com
cloud
21
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 29th Dec 2002 21:34
thanks i have sort of sorted the problem but just one more thing i've got my codes changed and i can't get the mouse to look when u move it and can u ever add another object behind the camera cus when i u move to a wall u can't move passed it but the camera stays with the object when u turn but the camera goes behind the wall and then you can't see in the room cus the wall is in the way.

here are my new codes:




please can u edit it for me to stop the problem happening and to get the mouse to look when u move it.

cloud
Red general
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2002 16:28
Here's an idea, it's taken from my space game. It means that you do not need a boxaround your camera for collision detection.



In the i, put the number of the object that is your bullet, and instead of the 1 in the obj1x#, objyx#, obj3z# lines put the number of your enemy. It then uses the function to work out the distance. If the bullet is near the enemy, the enemy is hidden (you can do other things to it.

The function is then used again to see if the camera is close to the enemy, if so it moves. You could make it so that it moves towards you if you want.
Hope this works - red general

Red general
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: United Kingdom
Posted: 30th Dec 2002 16:29
P.S. - put this in the loop

Login to post a reply

Server time is: 2024-04-27 01:50:57
Your offset time is: 2024-04-27 01:50:57