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 / Collison question

Author
Message
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 13th Jan 2006 13:13 Edited at: 13th Jan 2006 13:14
Hey guys,

I just got DBPro yesterday and worked through the tuts here last night:

http://forum.thegamecreators.com/?m=forum_view&t=63411&b=7

Which are so incredibly helful, I was blown away with how much I was learning so quickly - as I didnt copy and paste them, I printed them out and followed them through step by step.

Zotoaster's second FPS tutorial just got me started so well with arrays and the basics of coding.

The only things missing were player health / lives and a scoring system (which I succesfully added ) and collison - which I tried to add unsuccesfully.

I then tried just using the dist. command to DEC plrhealth#. Then when the plrhealth was <=0 then it reduced the plrlives and reset the health.

Is this a bad way of doing it? It worked nicely, but I felt I was merely 'working round' the problem as opposed to challenging it.

My question is more of where do I call the collision? Do I add this to the top of the code where I am calling my variables and setting the enemy stats, or in the DO loop?

Dont I have to tell the code that;

A) The player (object 1) has collision and what type it is.
B) The enemies (arrays, enemy(e).) have collison and what type it is. &
C) When the collision occurs, what to do next.

Am I right in thinking this?

I tried looking at some other tuts on this subject, but couldnt quite figure how to work them into my code.

Im at work at the mo, so can repost with the code if necessary, although it is merely a slightly modded version of Zotoasters tutorial code (below)

Many thanks - Im looking forward to getting my head down and these basics nailed before I even think of making any games! Any help muchos appreciasios.

Mabuggi.

DAB Studios
SirFire
19
Years of Service
User Offline
Joined: 4th Apr 2005
Location: North America
Posted: 13th Jan 2006 13:47 Edited at: 13th Jan 2006 13:50
Basic box collision for all objects is on by default when you load them. You place the collision detection commands either inside your DO/LOOP or in a function that is called somewhere in the loop. You can change the type of collision for an object by saying SET OBJECT COLLISION TO BOXES 100, SET OBJECT COLLISION TO SHERES 100, or SET OBJECT COLLISION TO POLYGONS 100 (where 100 is the object number). Setting the collision type should be done only once when you load the objects, unless you intend to change the collision type in-game. Boxes offer fast collision detection, but you sacrifice accuracy. Spheres can sometimes be more appropriate depending on the shape of your object, but a little more cpu time is needed. Polygon detection is the most accurate type of detection (using dbp native commands) and takes the most cpu time, especially for high-poly models.

In your main loop is where you'll check to see if there are any collisions and take action. You might use something like:
IF OBJECT COLLISION (100,191) THEN EXPLODE(100)
where 100 and 191 are two objects you want to check, and explode() being a user-made function that takes appropriate action on object 100 by passing the object number to the function.
You could also use:
IF OBJECT COLLISION (100,0) THEN EXPLODE(OBJECT COLLISION (100,0))
this will check to see if object 100 has collided with ANY objects, and call the user function explode() with the object number that was hit by 100. I'm not sure but I believe using OBJECT COLLISION command this way uses a lot of cpu.

Hope this helps.

Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 13th Jan 2006 15:01
Thats fantastic SirFire,

Shall try out this afternoon.

many thanks for your speedy response.

mab.

DAB Studios
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 19th Jan 2006 08:44 Edited at: 19th Jan 2006 08:48
Wow, lol I actually followed that and I may just implement something along those lines in my programs... Thanks Sirfire. Mabuggi, I envy you, I got dbpro and I never learned anything that fast, especially not as much as you did. Then again, I never went through the tutorials... But hey, whats past is past, I congratulate you on your being better than me at programming

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 19th Jan 2006 12:22 Edited at: 19th Jan 2006 16:09
Hehehehe

Thank you Shadowed Lightening.... Im not jumping for joy just yet, Ive got a hell of a long way to go, but thank you for your kind words

I got my arrayed enemies attacking me, I got melee coded in - just having major probbies now when my player "dies" (he doesnt actually die, he just loses a life and respawns on the matrix) he can no longer "shoot" the enemies...



But this is for a different forum thread and I digress.

thanks again man - I think its a case of I just really, really, really wanna learn it and get good!

PS - I very much doubt Im better than you at programming.

DAB Studios
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 19th Jan 2006 18:20
No, trust me, I just looked at your code and viewed the game, you are much better than me and I've been programming for 2 years now. Well, not a full two years, more like 10 months of active programing and 14 months of doing absolutely nothing Here is my latest work, I didn't make the terrain loading function, but I made the terrain and collision and stuff. Its kinda big so you dont ahve to DL if you don't want to...
Its an .exe because it self extracts so don't worry. 5.6 MB zipped, 16 MB unzipped...

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM

Attachments

Login to view attachments
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 19th Jan 2006 18:49 Edited at: 19th Jan 2006 18:53
WOAH WOAH WOAH -

I didnt write that man.

Thats Zotoasters Tutorial!!!!!!!!!

Please dont think I did that!

I dont want to get into trouble! - I was modding it, and thats why I posted it up.

So ALL Props to Zotoaster.

What I was doing was taking the tutorial and re-writing parts of it and adding things in etc. Merely modding what already existed. Thats where my question came from, so I thought Id put his code up to show everyone what I meant.

Apologies for the confusion. (Im DL'ing your code now - see told ya your a better programmer )

DAB Studios

Support your local Riker 9 Chapter.
Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 19th Jan 2006 20:34
Makes me all warm and fuzzy inside to see a modest programmer tell me im better than him lol, well, let me know what you think of my crap programs

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Mabuggi
18
Years of Service
User Offline
Joined: 11th Dec 2005
Location: UK - Universal Kingdom
Posted: 20th Jan 2006 12:23 Edited at: 20th Jan 2006 12:44
My god!

Thats awesome! I thought it was a `tech demo` until I realised I could move my plr about! Thats v v v impressive mate.

EDIT - Ive printed out your code too, Im very impressed, and thank you for putting such good comments on .

My floor is flat

Oh - And i solved my problem above ^^^, about the 'not shooting' enemies when respawning. I dont know why - but I think the bullet intersection limb is getting set too high on the y axis when the plr respawns...I cant for the life of me figure out why - but I figured it out when I couldnt shoot them unless I jumped at the same time......weird. Just changed the y variable in the intersect command and all is good!!

I love DBPRo

DAB Studios

Login to post a reply

Server time is: 2024-09-24 15:35:08
Your offset time is: 2024-09-24 15:35:08