# GLBasic forum

## Main forum => GLBasic - en => Topic started by: Kyo on 2014-Sep-23

Title: Collisions Question
Post by: Kyo on 2014-Sep-23
Hi Guys!
I want to give you a few questions on collisions!

there is a function to calculate the collision between two triangles??
(https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcSSz7gZ2yh353ZtOqE9y6Ig5FNzet5rmNXhxZdvE-tjGJ4exiXnbw)

there is a function to calculate the collision between two rotated rectangles?
(http://images.gamedev.net/features/programming/2dRotatedRectCollision/fig2.png)

and if I want to use the shape collisions?
(https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTjJr1-gFBuBaYjPIp8Ce209feehgHGdhL85h_Y60a1oRhWvCuXhw)

Thanks for help!
Title: Re: Collisions Question
Post by: Moru on 2014-Sep-23

Long(er) answer: Depends on what you want to do :-)

You could draw the objects on a sprite and then do pixel perfect collision detection on the sprites.
Title: Re: Collisions Question
Post by: Kyo on 2014-Sep-23

Long(er) answer: Depends on what you want to do :-)

You could draw the objects on a sprite and then do pixel perfect collision detection on the sprites.

I don't want to use the pixel perfect collision because it's slow on big images!
The best way is definitely the shape collisions, so if anyone can help me with the code I would be grateful  :nw:
Title: Re: Collisions Question
Post by: Moru on 2014-Sep-23
Have a try with these:
http://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

Title: Re: Collisions Question
Post by: mentalthink on 2014-Sep-23
Hi Kyo in my game I use circles and box collision(without rotating), because you can do any collision with this 2 shapes or aproximate to any shape.

I did an Collision Editor and if I want an especific collision I paint them.

If you need more help about this comment me, I think I have the code well ordened and not problem to give you.
Title: Re: Collisions Question
Post by: Kyo on 2014-Sep-23
Hi Kyo in my game I use circles and box collision(without rotating), because you can do any collision with this 2 shapes or aproximate to any shape.

I did an Collision Editor and if I want an especific collision I paint them.

If you need more help about this comment me, I think I have the code well ordened and not problem to give you.

For  circles and box collision(without rotating) I have no problem.
But for isometric game I have to use or box with rotation or shape zone.

Have a try with these:
http://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

Thanks, now I study this!  :good:

Title: Re: Collisions Question
Post by: matchy on 2014-Sep-23
Object collision based on vectors & spheres
http://www.glbasic.com/forum/index.php?topic=9265.msg79405#msg79405
Title: Re: Collisions Question
Post by: Kyo on 2014-Sep-23
Object collision based on vectors & spheres
http://www.glbasic.com/forum/index.php?topic=9265.msg79405#msg79405

Interesting, Thanks  :good:
Title: Re: Collisions Question
Post by: MrPlow on 2014-Sep-23
Also for isometric there is a mathematical calc from ortho top down (cartesian) to iso and collisions could be calculated before the math that would translate the objects to the screen as isometric.

That way you could not need funny angles...
:P

//Cartesian to isometric:

isoX = cartX - cartY;
isoY = (cartX + cartY) / 2;

So do collision based on cartX cartY and draw using isoX isoY
Title: Re: Collisions Question
Post by: Kitty Hello on 2014-Sep-24
Search for tritri collision. I have such a function. Somewhere...

Gesendet von meinem GT-N7100 mit Tapatalk

Title: Re: Collisions Question
Post by: Kyo on 2014-Sep-24
Search for tritri collision. I have such a function. Somewhere...

Gesendet von meinem GT-N7100 mit Tapatalk

In gl_b forum I can't find ...
sure that the name is tritri collision?
Title: Re: Collisions Question
Post by: Moru on 2014-Sep-24
There was something, I think it was in the showcase that could load polygons and maybe collisions. Could it be this one?
http://www.glbasic.com/showroom.php?site=games&game=AC3DPoly (http://www.glbasic.com/showroom.php?site=games&game=AC3DPoly)

I guess tritri means triangle - triangle collision.