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 / Collisions and BSP (two separate questions)

Author
Message
Black Hydra
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 11th Oct 2003 06:38
Well I have had DBPro for about a week now and I can't even believe how much I have learned myself.

Thanks to indi and spooky for there help with camera following I have started making a small game.

The purpose of the game is to herd sheep (currently represented by cubes) with a sheepdog into a pen. I have gotten the character movement, ability to "scare" the sheep, making my textured matrix on the ground and a pen.

Now, next on my to do list is setting up collisions. I have looked through some of the collision commands but I don't understand HOW collision works. If someone could be kind enough to explain the principals of object collision? And although a codesnippet would help I would really like it if someone could explain how it works? Please?

On an unrelated question what is a BSP? I am pretty sure it is related to world commands but I see the word thrown around alot and I feel stupid but I have absolutely no clue what it is...
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 11th Oct 2003 20:04 Edited at: 11th Oct 2003 20:09
For simple box collision,
the logic is:
if the camera z position is greater than the object z position - 30 and the z position is less than the object z position + 30 and the x pos > object x pos - 30 and the x pos < object x pos + 30
collision = 1
endif

then you would have:
if collision = 1
xcam# = oldxcam#
zcam# = oldzcam#
endif

this is for stationary square objects. it will give the object a 60 by 60 world units field, the camera cannot go within 30 units of the object's center
when you hit the object, and face a little to the right, u will not goto the right a little like in any good 3d professional game. now you need sliding collision

with sliding collision, you find which of the four faces the player is colliding with teh object, then u find his rotation. these determine how much he slides.

I use classic, not dbpro, currently, so im not sure how the code will help

note im also kinda new to coding, so this might not be the most efficient way for me to do it.
and i dont have backwords or sidestep sliding collision yet, those will be worked on later

for circular collision (with which i dont think u can get sliding collision) you use the distance formula; collision would = 1 if the distance is less than a certain amount

for collision with a box that is rotated 45* (for which i havent gotten sliding collision for yet) :


if i havent explained well enough and you need help just ask
and of course u will need to change the object numbers in the code to suit yourself
for y collision (upraised platforms and ramps) you find where the camera is in relation to the ramp or platform, and that corresponds to his height
i think this code gives a platform and three ramps around it and an ATTEMPT at the parts between the ramps
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 11th Oct 2003 20:35 Edited at: 12th Oct 2003 01:29
BSP is binary space particle i think
if you have played halflife, the halflife maps are in .bsp format
i think the battlefield1942 might be also but im not sure
quake is

you use worldcraft and zoner's tools to make a .bsp map
wally is used for its texture packs

i cannot say more as I have not used worldcraft for DB yet

i just use matrices right now, i dont load an indoor level for my current project i load a rather large world
matedit is a good matrix editor
magic world is the easiest one to use i think
Black Hydra
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location:
Posted: 13th Oct 2003 21:49
I still don't understand how collision works. Chris, I am glad for your help but I still don't have a clue on how you set collision. I think you use Set Collision On which says it records collision but how can I use this recorded data.

How can I set the data so if two objects hit I can do something accordingly. Like in a conditional statement (i.e. IF collision THEN....)
rob p
20
Years of Service
User Offline
Joined: 24th Sep 2003
Location: Philly, PA, USA
Posted: 13th Oct 2003 22:04
BSP stands for Binary Space Partitioning
qwe
21
Years of Service
User Offline
Joined: 3rd Sep 2003
Location: place
Posted: 15th Oct 2003 03:52 Edited at: 15th Oct 2003 03:54
hydra u might want to look at this, especially if you have dbpro
http://darkbasic.thegamecreators.com/?m=forum_view&b=6&t=10315&p=0

hydra i donno about the DB collision commands, I make my own
here is my collision code for a 150 by 150 box, its very simple


its logic is
if the position of the camera (xc# and zc#) is within a box area around the center of object six, collision = 1. then, later, the code says if collision = 1 then it positions you in your old position, so you didnt move. this is infinite height collision




if you dont understand this, we will go simpler.
the distance formula is distance# = sqrt( (camx#-objx#)^2 + (camz#-objz#)^2 )
before this formula ud need to do camx# = camera position x() and objx# = object position x(objnum) and the same for z... or you could just put the camera position and object position in the formula. this finds the distance
then do a statement:
"if distance# < 50
camx# = oldcamx#
camz# = oldcamz#
endif"
this gives a collision circle around the object




if you understand i will go on and try to explain sliding collision,which is not in the DB commands

or you could use Kensupen's .x collision code, which is what i am doing now. time to finally buy dbpro.. i wish the upgrade from dbc to dbp didnt cost almost as much as if i wanted to buy dbp seperate....

Login to post a reply

Server time is: 2024-09-21 04:12:31
Your offset time is: 2024-09-21 04:12:31