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 / [DBP] - Easy Sliding Collision

Author
Message
Rick the Programmer
20
Years of Service
User Offline
Joined: 23rd Mar 2004
Location: Maryland
Posted: 23rd May 2013 02:23 Edited at: 19th Jun 2013 07:16
Hey all. When I was first trying to figure out sliding collision, I had a heck of a time finding anything incredibly helpful on the boards here. As I have finally produced a relatively functional collision system, I'd like to contribute the code to the boards somewhere that it should be easy for others to find.

This code is not perfect, but it will get you past the most important collision scenarios you'll encounter while in the beginning stages of your program.




In order to make it work, ensure that you've set collision "on" on your objects and simply include these two functions in your main loop:
MoveButtons(playerID)
ApplyGravity(playerID, gravity#)

playerID being the object you'd like to apply WASDQE movement con collision.
Also, keep gravity# over .1 or under -.1

Happy Programming!

P.S. For anyone trying to understand the code above, all of the trickery happens within the REM'd bounds labeled "TEST CODE"

Ask not for whom the bell tolls;
It tolls for ye!
Sergey K
20
Years of Service
User Offline
Joined: 4th Jan 2004
Location:
Posted: 13th Jun 2013 16:11
If there was a Thumbs UP (Like) button here, you sure will get one!

why? i didnt tested the code yet, but by the looks of how the code is sorted and the way you seperating functions and using them is very pro!
excelent work man!

Stream SnifferTools/Plugins/Models/Games and more!
Rick the Programmer
20
Years of Service
User Offline
Joined: 23rd Mar 2004
Location: Maryland
Posted: 29th Jun 2013 22:21
Thanks for the compliment, Sergey. I just tried to make it as simple as I could

Ask not for whom the bell tolls;
It tolls for ye!
Duffer
21
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 30th Jun 2013 11:41
@ Rick the Programmer,

What SergeyK said - that piece of code is almost-suspiciously short and v well organised. Thanks again.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...

Login to post a reply

Server time is: 2024-04-16 08:01:51
Your offset time is: 2024-04-16 08:01:51