Sprite Collision Statements in VB...
Box type of collision is basic but for it's far from best choise for even the simplest remake of street fighter...I was thinking of a way to get VB to check if masks overlap...any ideas?
Thanks in advance
Edited by - VBHardCoder on May 30, 2001 2:56:38 AM
Test if the sprites are overlapping. If so, find the rectangle of pixels that each overlaps, and test each pixel. If any two pixels that overlap aren''t transparent, then they''ve contacted. That only really works for 2D graphics, and takes some optimization to get fast (this is often where C/C++ shine over VB).
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/ (If my website isn''t down, it''s a miracle!)
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/ (If my website isn''t down, it''s a miracle!)
quote:
Original post by Null and Void
Test if the sprites are overlapping. If so, find the rectangle of pixels that each overlaps, and test each pixel. If any two pixels that overlap aren''t transparent, then they''ve contacted. That only really works for 2D graphics, and takes some optimization to get fast (this is often where C/C++ shine over VB).
Holy moly, did you read my code/text or did I just naturally pick up on a common sense way of doing this efficiently?
![](smile.gif)
I guess there aren''t a whole lot of ways to efficiently perform collision detection, but man, I thought I was reading my own post and I had to verify that in fact the author was "Null and Void" and not "BlueMonk"!
![](wink.gif)
"All you need to do to learn circular logic is learn circular logic"
"All you need to do to learn circular logic is learn circular logic"
That''s the way I did it in my old 2D engine, that''s why I said it . I have no idea where I originally got the idea
. My new engine uses radii for each sprite, which is a whole lot easier to get running fast and to test collision over large distances imo.
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/ (If my website isn''t down, it''s a miracle!)
![](smile.gif)
![Resist Windows XP''s Invasive Production Activation Technology!](http://druidgames.warfactory.com/Out_Source/resist.jpg)
http://druidgames.cjb.net/ (If my website isn''t down, it''s a miracle!)
Just thinking here on the spot... one way you could speed things up is having simplified masks for collision detection. These could be generated at load time from the actual masks. Let''s say your sprite is 200x100. Make a mask that''s 20x10 for each sprite and test those. If you want pixel perfect collision, then go onto the more detailed test. If (let''s say) 4 of the pixels(or array elements) in the 20x10 mask flag a collision, only test those 4 10x10 areas. Even VB should be able to handle that. I''d like some feedback on this, because I''m not sure if it would be faster or not. Any ideas anybody?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement