I am trying to make a simple game where one object is moving between to curvedVertexes. Now I want to add an event incase the object is colliding with the obstacles aka the curvedVertexes. I have found “collidePointPoly()” (https://github.com/bmoren/p5.collide2D#collidepointpoly 1) to be a simular case. But once I have tried it out, the function turned true everytime the dot was under a point. They did not touch, since their x position was different, they were mearly on the same y position.(this is the link to the discribed case https://glitch.com/edit/#!/wave-collision?path=index.html:175:0).
I have also tried out a different approach. As a basis of which I used this http://www.jeffreythompson.org/collision-detection/poly-circle.php processing sketch. But I had trouble converting it into javascript, so that I was not even able to test it out. (https://glitch.com/edit/#!/wave-collision-3?path=index.html:220:9 this is the link to my test)
I am now wondering is there another solution to this or can someone see and explain my mistake?
Thank you