LWJGL Forum

Programming => General Java Game Development => Topic started by: that1guy232 on February 07, 2015, 05:43:15

Title: Click on object detection help
Post by: that1guy232 on February 07, 2015, 05:43:15
I've been teaching my self java for a while now. I know i am doing some things really wrong and I have been playing with hexagon grids lately and i cant figure you how to get onClick to work right i would love some help.

Here is the github link to my project & where the problem is.: https://github.com/that1guy232/ZK/blob/master/src/com/that1guy232/ZK/Hexagon.java
Title: Re: Click on object detection help
Post by: abcdef on February 07, 2015, 08:12:27
try and google for "check if a point is inside a hexagon", there are plenty of results telling you the maths to do this
Title: Re: Click on object detection help
Post by: that1guy232 on February 07, 2015, 18:33:48
Quote from: abcdef on February 07, 2015, 08:12:27
try and google for "check if a point is inside a hexagon", there are plenty of results telling you the maths to do this

Thanks, I came across http://www.codeproject.com/Tips/84226/Is-a-Point-inside-a-Polygon but i'm not quite sure i understand it. A little more help would be great!
Title: Re: Click on object detection help
Post by: quew8 on February 08, 2015, 16:28:23
What about this do you not understand? If it's the algorithm, and you want to understand it conceptually there there is a little paper written on it here: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html (http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html).

But there is no need to understand the algorithm, you have been given a method in C that almost works in Java already. Change the "c" to a boolean variable. Change the method to return a boolean variable. Replace C pointers/number of vertices parameter with Java array(s).