Touch Thumb Stick
I'm currently working on a touch thumb stick for agame, but in order to do so, I need to check if you click on a circle.
how would you do collision for circles?
I'm currently working on a touch thumb stick for agame, but in order to do so, I need to check if you click on a circle.
how would you do collision for circles?
There is a myth passed down by wandering bards that there is powerful mathematics behind such collision detection.
Use the Pythagorean theorem to determine the distance between the center of the circle and the mouse and then compare it to the radius of the circle.
collision_circle_point = function(circle, point)
local distance = sqrt((circle.x - point.x)^2 - (circle.y - point.y)^2)
return distance <= circle.radius
end