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.

Code Snippets / sprite collision

Author
Message
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 15th Feb 2003 12:57
wanting to write a 2d retro game for the compo i started work but soon discovered dbp sprite collision not pixel perfect. So i made my own function, it works best if you pass smallest sprite as sp1.

Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 15th Feb 2003 12:59
oh btw i wanted to make memblocks from the images not make bitmaps then make memblocks but when i made memblocks from images they weren't same as origional images??
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 15th Feb 2003 13:03
my code didn't post right??
here again:
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Feb 2003 13:31
And thats number 3 ...
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 16th Feb 2003 13:43
okay i found if u make memblocks from loaded images they not right, but if you paste image then grab it u can make memblock from that image with no probs.
so i use that to improve my collision function which now runs quicker:

CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 17th Feb 2003 08:06
http://www.darkbasicpro.com/apollo/view.php?t=4826&b=6

try this one, anysize sprites and memblocks for speed

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Feb 2003 11:14
The reason your collision doesn't work all the time without pasting to a bitmap is that you are not taking any account of the pixel depths of your images. Pasting them removes this difference. You are also using GET IMAGE which is *slow*. You are also comparing the whole sprite, not just the overlapping portions.

The one posted above is freddix's one that handles multiple pixel depths, or there's this one originally by Chipone and optimised by me.

http://www.darkbasicpro.com/apollo/view.php?t=5209&b=4

If you can ensure that all your sprites are 32 bit, then use this one as it's faster, otherwise use the one by freddix. It does sound as if freddix's is better for the images you are using.

Look out for a changed version of the 32 bit one that will work with any image bit depth at high speed - coming to a forum near you - soon!
Flashing Blade
21
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 17th Feb 2003 12:06
Sonic informed me freddix had made a pixel perfect sprite collision function when i was making my function.
I just wanted to make one on my own - which i did and it works(even though its not as fast as the others u mentioned).
I got plans to improve it by using a 3rd memblock insted of a bitmap and paste and get image. But at the minute i doing my retro compo thing
neway thnx for info.

Login to post a reply

Server time is: 2024-05-01 15:16:08
Your offset time is: 2024-05-01 15:16:08