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 / 2D Sliding Collision

Author
Message
Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 28th Feb 2003 00:51 Edited at: 18th Jan 2023 02:08
Hi Coders,

Just posted an example on UnderwareDesigncom that allows you to perform 2D sliding collision on a circle against static Convex or Concave shapes. Shapes can also be intersecting. Sliding collision seems to be something of a holly grail in the DB forums, while it's not the most straight foreward thing to understand the concept behind is really very simple.

This code contains two main parts. There's a small set of functions to define your 2D wall lines. These Wall lines are single sided, meaning collision is only available on one side. So all shapes you want run collision against, will need to be enclosed shapes.

To use the RUN_COLLISION function. You pass it the current position of an object and the position the object wishes too move to. After the Run_Collision function has completed it's work, you then position this object at the location returned by the function..

I'll write a 3D one later (sphere to polygon). When I need it.. Soonish

Download (collision & Intersections section)
=============================================

https://www.underwaredesign.com/?page=programs.Dark-Basic-Source-Codes


PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code

Login to post a reply

Server time is: 2024-11-24 04:27:04
Your offset time is: 2024-11-24 04:27:04