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 / A better form of 2D collision detection?

Author
Message
Ralen
22
Years of Service
User Offline
Joined: 22nd Jul 2003
Location:
Posted: 25th Jul 2003 04:31
No code just a good idea for collision detection.

I havn't really messed with DBPro enough to know how to get it all to work yet, but from the posts that I've read collision in 2D is a tough animal to tackle.

At the moment people 'pick' colors from memory and specify that that color is impassible. Instead of doing it like that how about this...

You design your 2D level, then you design a second overlay that is two colors lets say, black and pink. Black is passible areas, pink is impassible.

You would basically have two levels that are the same. one is the level that everybody sees when they play your game and the other would be...lets call it a 'collision map' You would not be able to see this collision map.

The definatly would be faster as your arn't picking bits from a complex picture.

Basically would work like transparent, not transparent sections do in Adobe photoshop.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 25th Jul 2003 04:47
Your method works well for static images but most applications require collision testing of moving imagery, specifically sprites.

Interestingly the same theory still applies.

This is a process called masking which is also used for recording the screen history when an overlayed image is placed and subsequently moved. My understanding is that DBPro uses layers and has no inherent mask, and therein lies the defficiency of it's collision detection system.

I am considering writting a masking system for DBPro but as far as I can see there are two ways to tackle the problem and I cannot decide which is best.

Option One: Have a function to create masks using DBPro commands, this would be a one-off function call performed by the programmer after loading all images and would take some time to process. This would cause a delay during loading, but the results should be fast and the code easy to write using standard DB commands.

Option Two: Work out how to access DBPro display RAM which I don't think is too hard to do, and then peek the displayed image content directly. This method might be slower in runtime but would be easier for 3rd parties to implement as it would result in a one off command to use whenever collision needs to be tested. Programming this would be more complicated, but requires no pre-processing.

Pneumatic Dryll
keeblerElf
23
Years of Service
User Offline
Joined: 11th Jun 2003
Location: United States
Posted: 25th Jul 2003 06:12
I believe that's the way they did the level collision in metroid fusion.

HZence
23
Years of Service
User Offline
Joined: 9th Mar 2003
Location:
Posted: 25th Jul 2003 07:09
Whatever you do, don't do it my way. My way is the horrible way. Basically I have an X and Y variable for my main sprite, and then for EVERY freaking level I have to go through and say:

If X# > point1# then X# = point1#
If X# < point2# then X# = point2#
If Y# > point3# then Y# = point3#
If Y# < point4# then Y# = point4#

A major pain in the rear. Through that experience I've learned that map editors are your best friend.

SW Games - www.freewebs.com/swgames

Yeah, I know, I only have one game. Yeah, I know it sucks. But I made it! Me!

Login to post a reply

Server time is: 2026-07-21 18:38:32
Your offset time is: 2026-07-21 18:38:32