TXG/MNX Posted February 2, 2005 Share Posted February 2, 2005 Hi, How easy is it to detect a collision between two objects ? TXG/MNX Quote Link to comment Share on other sites More sharing options...
Starcat Posted February 2, 2005 Share Posted February 2, 2005 Hi TXG/MNX ! Quite easy actually. A simple software routine is enough. Of course it depends on how accurate you want it to be. You can probably find tons of general tutorials on collision somewhere on the net. The basic idea is to check if the X position of the first object + its width is lower than the xpos of the second object, and to check if the X position of the first object is greater than the X position of the second object + its width. If one of these cases are true, there is no collision. Otherwise there is. You need to do the same with Y position as well of course. I hope I am not confusing things now. Regards, Lars. Quote Link to comment Share on other sites More sharing options...
TXG/MNX Posted February 2, 2005 Author Share Posted February 2, 2005 Hmm okay I did figure that out already but I though there where maybe some hardware registers that could help thanx for the info... Quote Link to comment Share on other sites More sharing options...
Atari_Owl Posted February 2, 2005 Share Posted February 2, 2005 There is, but it relies on trapping an inner loop write inhibit from the blitter based on colours or Z buffering Look up BCOMPEN,DCOMPEN,ZMODE & B_STOP i.e. colour about to be written, written over, or of relevent z position theoretically, you can check when the blitter has stopped, if the blit has been completed if so - no collision if not - collision I'm not sure if this was what youmeant Quote Link to comment Share on other sites More sharing options...
justclaws Posted February 2, 2005 Share Posted February 2, 2005 Hello, Hmm okay I did figure that out already but I though there where maybe some hardware registers that could help thanx for the info... If you are using objects, there is no collision support, you can only use your X1-X2 and Y1-Y2 checks, with a bounding box slightly small than the size of the objects to allow more assured collisions for the user. However, if you use the blitter, the blitter can determine when your blit hits another non zero colour. This is useful only if you blit twice I think, one blit to the collision buffer (every object a different colour, so you know which object it hid. Then if OK, you blit the actual object to the real screen buffer. If there was a collision, then blit an explosion. The order of the objects is important then. You can blit all enemies without collision detection, then blit the bullets and check if the blit hit something. You can put the player ship on another layer, or treat it like a bullet, but bullets don't get stored on the collision buffer unless you want to be able to shoot bullets. Make the collision buffer only 8-bit "colour". I believe that this provides pixel perfect collision detection. However, I have no implemented it completely on the Jaguar, at this time. I've actually got bounding box collisions for the most part, they're OK. I'd be asking on UGD-JAG too, because most of the guys there don't have the time these days to read the AA or JS-II, so won't see this. Cheers, Richard / JustClaws. Quote Link to comment Share on other sites More sharing options...
Starcat Posted February 2, 2005 Share Posted February 2, 2005 Hi ! While this blitter based approach might work, I think it's very hardware intense compared to the normal bounding box solution. So far I've always used bounding box and I think it's the ideal one for 2D games. You don't really need pixel exact collision usually I think. If your game needs a lot of performance, the bounding box solution is definately the better choice, as it's much faster and doesn't require a collsion buffer as Justclaws mentioned. Regards, Lars. Quote Link to comment Share on other sites More sharing options...
TXG/MNX Posted February 3, 2005 Author Share Posted February 3, 2005 Thanx for the info Quote Link to comment Share on other sites More sharing options...
Symmetry of TNG Posted February 3, 2005 Share Posted February 3, 2005 Yo! ...I would LoVe! to see the src of a blitter "pixel perfect collision" thing... this is what i have been talking of for so long but nerver got down to code, or even try (since i have no need for 2D collision atm). Bounding box ...might be ok... but i think the blitter version os more effective... especially if you use the 68K for all box calculations. (semi "proof" of this se STE remark below. Probably not if you keep all boxes in GPU & use it..). A blitter code would also give pixel perfect detection.. which is a MUST for that StreetFighter game someone spoke of... you need to test for collisions with the Foot, and not just the bigger "box" caused by an extending foot. The blitter would do this much easier than the 68K. You could even draw different "HotSpots" in the collision map to have different (or rather correct) damage assessed to different areas of the attack... (would for sure give a nice/accurate/FAST! 2D figher!). Though... (digging in old memories) ..iirc there isnt that much info on how to do this with the blitter... so it would be much like the bit2pixel expansion thing (just tougher So... I thought of yet another way to do this.. it is based on, or similar to, an STE demo by Patrice Mandin (iirc!!) and it uses the STE blitter to give pixel precise detection and is realy fast.. Its in essence anding 2 colisionmaps tigether using the blitter and then do a manual "check/search" for 1'es ...if there is it was a collision... The search is crude i know... when this could be done with the blitter... but if nothing else would work... =) ----- BTW ..depending on what you whant to test against there exists offcourse different methods to do detection... (like 2D polygon detection) ...but its all math and No HW register what so ever ...so... ahh well... someday perhapps.. I´ll see the light of blitter pixel perfect detection.. =) cheers! Quote Link to comment Share on other sites More sharing options...
justclaws Posted February 4, 2005 Share Posted February 4, 2005 Hello, ...I would LoVe! to see the src of a blitter "pixel perfect collision" thing... this is what i have been talking of for so long but nerver got down to code, or even try (since i have no need for 2D collision atm).Indeed, if ever I had the dedication, I'd progress this further... So... I thought of yet another way to do this.. it is based on, or similar to, an STE demo by Patrice Mandin (iirc!!) and it uses the STE blitter to give pixel precise detection and is realy fast..Its in essence anding 2 colisionmaps tigether using the blitter and then do a manual "check/search" for 1'es ...if there is it was a collision... This was the way old games used to work - even way back in Spectrumdays, the commercial shooters used collision buffers/maps too, but the question is, do you need to know if your ship or bullet hit and enemy or not. Not necessarily. If it hits anything, you can then calculate the proximity of all objects with bounding boxes, and then destroy all the ones which come within the boundaries of the explosion bounding box. So that way you get pixel perfect detection with bounding box effects. Fast. Regarding the demo and article, I was intrigued, so went looking. I think this is the page with the necessary links to his (French) demo? http://membres.lycos.fr/pmandin/ More specifically... http://membres.lycos.fr/pmandin/en/howto/blitter.html and his ports... http://membres.lycos.fr/pmandin/en/ports.html Cheers, JustClaws. Quote Link to comment Share on other sites More sharing options...
Symmetry of TNG Posted February 5, 2005 Share Posted February 5, 2005 Hi JustClaws! Yes there are always ways to optimize removing collision objects, giving shi-e in enemy collision (amongst themself) and a lot more.. Spectrum eayh... =) ..well... point beeing the it with the ST could be done with the blitter & hence be darn fast! ...I thought the same might be done with the jaguars blitter... ...But... I'd then rather experiment with its "eledged" built in cillision detect... (by that Not! saying that i will in any near future =) PM: Yes that is the code! ....tested it years ago on my falcon... works fine in any language cheers Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.