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.

DarkBASIC Discussion / Triangle Collision Check

Author
Message
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 24th Mar 2010 01:08 Edited at: 3rd Sep 2012 02:09
I was messing around with my isometric tile map and stumbled onto this. This may only be useful in 2d tile-based game however.


The example shows a rough collision check of the top left corner of the box. It is also possible for all the other corners and you can adjust the length of a side.


chafari
Valued Member
17
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 24th Mar 2010 01:48
It works!!, and I think this method can be translated to 3D just using x,z as the x,y of mouse, but now a day, there are good methods for 3D collision check, any way...good job !!.


Cheers!

I'm not a grumpy grandpa
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Mar 2010 17:28 Edited at: 25th Mar 2010 17:31
Nice.
I've overhauled your code.
I couldn't work out what the (mx-100) was for so I took it out and put in my own code for checking the triangle.
I've put everything in variables so it is very tweak-able.


"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright
Ashingda 27
16
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 25th Mar 2010 19:56 Edited at: 25th Mar 2010 19:57
Wow that's nice I like it, a lot easier to use.

that mx-100 was because the start of the box is (100,100).
29 games
18
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 25th Mar 2010 20:45
That's a clever method. I like it.

I spend a lot of time pondering maths collision methods but it never occured to do triangles like this.
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 25th Mar 2010 21:01
Quote: "that mx-100 was because the start of the box is (100,100)."

Ohhh, I did the same then (mx-boxax).

"With games, we create these elaborate worlds in our minds, and the computer is there to do the bookkeeping." - Will Wright

Login to post a reply

Server time is: 2024-04-27 11:01:02
Your offset time is: 2024-04-27 11:01:02