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 Professional Discussion / Can you set a range for OBJECT COLLISION()?

Author
Message
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Nov 2003 17:38
Hello.

I know that setting the final parameter in OBJECT COLLISION to zero will check all collisions and return the number of the object that is in contact with the collision object but what if there is more than one object there?

For example; a spaceship is damaged and on fire. Particle objects are used to show the fire but now when using OBJECT COLLISION(obj,0) the object number of the fire particle is always returned even if the spaceship continues to take hits and should therefore be in collision with bullet objects.

There are two ways around this that I can see but neither of them are suitable for my needs:

1) Move the fire particles so that they are outside the spaceships collision sphere.

2) Put a number in the final parameter of the OBJECT COLLISION command to check for specific collisions.

The first idea is not praticle because it looks crappy and the second idea involves using a large FOR...NEXT loop to check for all the objects that are not fire particles.

So, is there any way to set a range for OBJECT COLLISION so that it could ingore cartain object numbers and only check for objects within its range?

Thanks.

My latest project has no name - feel free to suggest one. Think 'Lunar Lander' with multiplayer, guns and bombs!

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Nov 2003 17:55
Turn off collision flag on the fire particles with

set object collision off

Boo!
Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 17th Nov 2003 18:04
Of course!!!

It's so obvious, why didn't I think of it?

Thanks Spooky

My latest project has no name - feel free to suggest one. Think 'Lunar Lander' with multiplayer, guns and bombs!

spooky
23
Years of Service
User Offline
Joined: 30th Aug 2002
Location: United Kingdom
Posted: 17th Nov 2003 18:25
Simplest ways are usually the best.

You should always turn collision off on ALL objects that don't need it as it REALLY slows the game down if you are doing lots of collisions. If you are doing any fancy object hiding for stuff out of range you should also turn off collision on those objects until they are reshown.

My alien compo game does a lot of this and only leaving collision on objects that you can possibly collide with within a certain range has improved frame rate dramatically.

Turning off collision on your fire particles should have increased game speed a fair a bit!

Boo!

Login to post a reply

Server time is: 2026-07-26 20:17:02
Your offset time is: 2026-07-26 20:17:02