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 q's

Author
Message
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 30th Jun 2004 15:06
ive been trying to make it so when i shoot my bullts at an object it gets destryed. i just don t get it. i have bullets and everything just havent figured out collision.

also i have made two weapons and i know how to switch them . on one gun i have figured out how to bring it up so you can look down the sights but i have to use a completely different button for the other one and thats no good. do i make it some how the guns a variable?

and also the two guns run off the same ammo. i was thinking if i could make each gun a variable i coud have it so if i shoot one gun it runs off this ammo and the other gun runs off another.i have figured out how to reaload so how would i make it one button to reload whatever gun im using.

and finally one more quickie...wait i forget ill think of it later...

if you could point me in the right direction to figure this stuff out it would be great!!! thx

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 1st Jul 2004 02:12
Well, the guns and their ammo can be handled by different variables and a control variable like;

whichgun = 0 : rem for gun 1
whichgun = 1 : rem for gun 2

if whichgun = 0 then (fire gun one)
if whichgun = 1 then (fire gun 2)

and so on....

As for the bullets hitting things, there are two ways; position and collision.

Position assumes you test the location of the bullet versus the target, and when they match (or get really close) you declare a hit and then destroy the bullet and object hit in an explosions. (And remove them from the screen.)

if object position z(bullet) >= object position z(target) then (hit!)

And so on...

Collision does the same thing as position, but it does it by having the objects themselves tell you when they hit.

if object collision(bullet, target) = 1 then (they've hit!)

check the monster hunt example if you have it...

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 1st Jul 2004 09:03
thx for not giving me the total answer i can only learn if i figure it out my self.
i remebeered my q,

is there a difference if i use a .3ds model or a .x model?



mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 1st Jul 2004 11:27
ya i tried both of ur collision things but it says object doesnt exist a line 146.. the line of the collision thing. i no both exist and i know that i made the objects before this code so wht could this be because?

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 2nd Jul 2004 02:46
Hmm.. that's a good question....

Sadly, it's a poor answer.

Heh-heh-heh. No seriously...

Did you remember to turn collision on?

commands;
set object collision on bullet
set object collision on target

S.

Any truly great code should be indisguishable from magic.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 2nd Jul 2004 04:20
Oh yes!

You also asked about the 3DS and X file format thing. I know that DBC at least does best with .X objects, and actually converts the 3DS objects to X when they get loaded. (Or so my informers have told me.) So the X is the native form, since that's what Direct-X likes.

Now when it comes to collisions you have a few options here;

set object collision to boxes
set object collision to spheres
set object collision to polygons

Box is probably the fastest of the collection, because it has less computation. Polygons is the most complex, because it uses the object shape itself. (And thus is the slowest.) Sphere is a "trade-off" between boxes and polygons, which falls into that "or very close" category of detecting positions.

Which you decide to use is up to the game you're building, and you can optionally "make object collision box <object>" for the things that collide.

You should also try; if oject hit(object1, object2)=1 then (hit) in your code, after you've selected the above options.

Again, good luck... and I hope this helps.
S.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 2nd Jul 2004 10:15
there must be something wrong with my code cuz once i put in all of what you said i get the same error. "object does not exist at line 146" that is the line with "set object collision to spheres b" in it.

without this new code the game works fines.

dbpro

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 2nd Jul 2004 10:16
maybe be its something with the "b"

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 2nd Jul 2004 10:16
here is what im using


set object collision to spheres b
set object collision to boxes 104

if object hit(b,104)=1 then print "Hit!"

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 2nd Jul 2004 19:17
oh no-no-no-no....

the set object collision to spheres or boxes needs no parameters. Them are global commands. The problem is, if you use those, it sets the collision aspect for ALL OBJECTS, so it can slow down your frame rate by a huge amount.

You are actually better off in deciding which objects are likely to collide, and using a "make object collision box" for that that object. (That's make ....box <obj#>, x1, y1, z1, x2, y2, z2, flag. Flag=0 if non-rotating.)

Frankly, from my experience, I find position detection is enough for my own programming, for the direct collision system seems to slow things too much imho.

(perhaps it's time for you get the dll add-on?)

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 05:59
i was thinking to get that my self.....


so would a command of "set...box 104,10,10,10,10,10,10,1"
cover a "make object cube 104,10"?

mulletman47@aol.com
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 06:18
i put in

make object collision box b,.2,.2,.2,.2,.2,.2,1

but it says that object dosent exist. but it does...

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 12:35
Well, then I'm likely to agree with you as well, it's the "b" in the code. While B is a variable if you're getting an "object doesn't exist" then it must incorrectly set, so is referring an object that you didn't make. I can tell it's not zero -- because DB will say "object number must be 1 to 65535" in that event, so I'd search through the code to see what value B is, and make sure it has not changed when you hit the collision detection stuff.

Perhaps you used B somewhere as a temporary value?

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 12:49
`dims
dim active(100,2)
maxwait=60



`make bullets
for b=1 to 100
make object sphere b,10
hide object b
next b


this is where i put it so i dont no..dark basic pro .sry i didnt mention that.this is before the collision gosub.maybe ill just order NG and forget about it.but man it annoys me not undersanding something. hehe

i'll keep messing around with it.

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 13:26
Ok. Then B is equal to 100 at the end of that loop. What about when you do the detection?

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 13:33
make object collision box 104,10,10,10,10,10,10,1
make object collision box b,10,10,10,10,10,10,1
if object collision(104,b)
position object 104,rnd(10000),50,rnd(10000)
inc score#,1
set cursor 320,240
print "Hit!"
endif


is that what ur talking about?

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 3rd Jul 2004 13:42
Well, yes... and no. What I was asking was -- where is B getting set at this time? And is that object on the sceen at the time?

The set up command makes a whole collection of objects but also hides them all, and I don't believe a hidden object can collide with anything. (I might be wrong in that, but I wouldn't think they would.) So you have to have a place where the object becomes visible so it can appear to move, and thus B must be set to something before you can detect hits.

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 3rd Jul 2004 13:47
for b=1 to 100

`shoot
if mouseclick()=1 and ammo#>0 and active(b,1)=0 and (timer()-lasttime)>maxwait
position object b,gunx#,guny#,gunz#
set object to camera orientation b
active(b,1)=1
active(b,2)=200
show object b
rem show sprite 2
rem play sound 1
ammo#=ammo#-1
lasttime=timer()
endif



`move bullet
if active(b,1)=1
move object b,100
active(b,2)=active(b,2)-1
endif

`stop when bullet run out
if active(b,2)<0
active(b,1)=0
active(b,2)=0
hide object b
endif
next b
here is were it is set i think

mulletman47@aol.com
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 4th Jul 2004 05:16
Hi again!

Well, I have had a lot of time now to look over the complete code, and the changes we've made to it in following the other thread. I DO NOTE THIS HOWEVER, the value of B used in the collision section is NOT BEING SET to anything, but instead remains what it LAST WAS from the enemyshoot code. (That is to say, either 300 or 301 when it exited the FOR-NEXT loop.) For collision detection, you going to need another FOR-NEXT or include a call to collision in the enemeyshoot subroutine, not in the main loop as you have it now.

Good luck!
S.

(See other thread too.)

Any truly great code should be indisguishable from magic.
aks74u
20
Years of Service
User Offline
Joined: 2nd Jun 2004
Location: arizona
Posted: 4th Jul 2004 10:13
thx for sticking with me through all this. i'm hoping to write a tutorial onuce i get the hang of this so others dont have to go through all this to get to collision. im trying out the stuff you told me and ill get back to you as quick as i can.

mulletman47@aol.com

Login to post a reply

Server time is: 2024-09-22 15:40:38
Your offset time is: 2024-09-22 15:40:38