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.

2D All the way! / Any suggestions / guidance for a more elegant collision test solution between a complex boundary and a sprite?

Years of Service
User Offline
Joined: 18th Feb 2017
Posted: 28th Feb 2017 15:50
Does anyone have an an elegant solution to checking for a collision between a sprite, and a complex boundary, as illustrated in this example image?
I've got some clugey ideas, like making every straight line into an individual sprite, and checking for collision, but Is there any veterans in here, with a better solution?


Login to view attachments
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 28th Feb 2017 22:43
what exactly are you trying to do keep the sprites inside the object? can think of many ways to check for collisions what language are you using?
A child's dream never dies.

Van B
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Mar 2017 17:20
In AppGameKit, you can define your own collision shape, line by line and as many as you need. You can also grab a line to line intersection function, store the lines in an array, then use that as your own collision system. There are examples about, I can post one if you're stuck - but these would be for DBPro... with AppGameKit the collision line by line setup is a no brainer.

One cool thing about convex shapes made from connected straight lines, is you can very easily tell if a coordinate is inside it, or out.... just project a line between the sprite and a coordinate that you know is inside the shape (or outside, you just need to know which), and count how many of your lines intersect with that line. If the sprite is inside the shape there will be an even number of collisions, otherwise an odd number of collisions. It's pretty cool really how easy that is and how it works with even the most complex shapes.
The code is dark and full of errors
Kevin Picone
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 2nd Mar 2017 00:03

In PlayBASIC you'd draw the series of edges as a collision world, create a sprite, enable circle collision mode and tell it what world to use for colision, then every time you move the sprite it'll slide off the edges for you.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2023-12-08 22:52:11
Your offset time is: 2023-12-08 22:52:11