Routine for any collisions

Share your advanced PureBasic knowledge/code with the community.
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Routine for any collisions

Post by gnasen »

Hi folks,

I read very often that something like a collision routine is missing, so I decided to write my own. I hope it is as easy to use as I tried to make it.
There are 3 testprograms (with source) and a documentation in the package.

Features:
-create any polygons as hitbox
-move and rotate hitboxes
-very fast check if hitboxes collide
-easy to use with pb like syntax
-linux and windows compatible, 64bit not checked yet
-create hitbox out of a sprite

Download: http://wwwhomes.uni-bielefeld.de/ddiffe ... lision.zip

Little, good readable example with awesome graphics:
Image

Sandbox editor:
Image

Performance check:
Image
Last edited by gnasen on Fri Feb 04, 2011 12:12 am, edited 4 times in total.
pb 5.11
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Post by gnasen »

I improved the speed of the collision checks and got a speedboost of 50% on different collisions and more then 600% if there is no collision between some triangles (which are part of every hitbox).

Have fun. Would be happy about some further testing. And maybe some Feedback :wink:

new Download:
see first post.

new speedcheck
Image
pb 5.11
White Eagle
Enthusiast
Enthusiast
Posts: 215
Joined: Sun Jan 04, 2004 3:38 am
Location: Maryland

Post by White Eagle »

Danke
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Post by luis »

Very nice!

I just tested without trying to understand the code for now, don't have time ATM.

But thank you very much for sharing it, I certainly will look into it.
gnasen
Enthusiast
Enthusiast
Posts: 282
Joined: Wed Sep 24, 2008 12:21 am

Post by gnasen »

added a requested function to create a hitbox out of a sprite. So its very easy to create hitboxes.

col_import(sprite,transcolor,gridsize)

transcolor is the not solid area, gridsize the "scan resolution".

Have fun
pb 5.11
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

read very often that something like a collision routine is missing,
me too

ok I will integrate one to my sprite lib :D
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4326
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Looks interesting! Will try it with my particle system.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Routine for any collisions

Post by wombats »

It might be a bit of a long shot, but does anyone still have this? I don't think it's on RSBasic.de.
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Routine for any collisions

Post by Demivec »

wombats wrote:It might be a bit of a long shot, but does anyone still have this? I don't think it's on RSBasic.de.
I do. I am not quite sure if I have the latest version though. The link in the first post was a zip and mine is a rar.

I looked over the code and updated it to PureBasic v5.72 so it is runnable and changed variables from .l to .i for example. I also increased the readability a little with some added returns and spaces. I finished it all up by zipping it and placing it on DropBox.

Here's the link. It will be available for a while though I may eventually remove the link to it.
wombats
Enthusiast
Enthusiast
Posts: 663
Joined: Thu Dec 29, 2011 5:03 pm

Re: Routine for any collisions

Post by wombats »

Demivec wrote:
wombats wrote:It might be a bit of a long shot, but does anyone still have this? I don't think it's on RSBasic.de.
I do.
Thank you!
Post Reply