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 / Sprite Collision Algorithm

Author
Message
Amd Silver
20
Years of Service
User Offline
Joined: 18th Feb 2006
Location: /bin/null
Posted: 5th Oct 2011 18:57 Edited at: 5th Oct 2011 19:12
Searching around the forums I saw that over the years many people have had issues with DBP's sprite collision system.

I was wondering if anyone happens to have a bounding box collision algorithm that works a bit more often than the one used by DBP?

The code below only seems to work 1 in a few hundred times, which is unacceptable for a bullet hell game.



Originally I was going to use sprite collision(), but after that didn't seem to work well, I switched to sprite hit(). After reading up on the differences between the two and looking for an algorithm on the forums for better sprite collision, I decided that I don't need pixel perfect collision, bounding box will do. It is a bullet hell game, there is going to be so much going on they probably won't notice that I am using bounding boxes.

EDIT:
For those who may wonder, 2000 to 2250 is the valid range of sprite numbers for the enemies and 1000 to 1250 is the valid range of sprite numbers for the missiles.

Love,
Zell Faze
CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 7th Oct 2011 15:37
One thing to take into account is that with SPRITE HIT and SPRITE COLLISION, when you use the parameter of '0' it returns the lowest unique sprite identifier being hit. So, if the sprite in question is touching 10 other sprites, the SPRITE HIT and SPRITE COLLISION commands will only return the LOWEST numbered sprite that is being hit, and ignore any others.

Malevolence: The Sword of Ahkranox
www.msoa-game.com
www.facebook.com/malevolencegame
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Oct 2011 16:17 Edited at: 7th Oct 2011 16:46
@Amd Silver

Assuming sprite one's corners are
x1,y1..............x2,y1
x1,y2..............x2,y2

and sprite two's corners are
x3,y3..............x4,y3
x3,y4..............x4,y4

Then



Enjoy your day.

Login to post a reply

Server time is: 2026-07-11 09:48:37
Your offset time is: 2026-07-11 09:48:37