Advertiser Content

Luka S.J.

Jealous Croatian

Age 26
Male
Croatia
Seen 23 Hours Ago
Posted 23 Hours Ago
1,136 posts
10.6 Years
If a circle is all you want, you don't even need to do any fancy math.
dist_x = Math.abs(target_x - mouse_x)
dist_y = Math.abs(target_y - mouse_y)
radius = Math.sqrt(dist_x ** 2 + dist_y ** 2)

# to check if mouse is in a circle of radius 'r' around the target X and Y coordinates, simply check for
# if radius <= r
Seen June 9th, 2019
Posted June 9th, 2019
13 posts
83 Days
If a circle is all you want, you don't even need to do any fancy math.
dist_x = Math.abs(target_x - mouse_x)
dist_y = Math.abs(target_y - mouse_y)
radius = Math.sqrt(dist_x ** 2 + dist_y ** 2)

# to check if mouse is in a circle of radius 'r' around the target X and Y coordinates, simply check for
# if radius <= r
Thanks it works
,but abs is not a method of math module ,i think it is of fixnum or it's super class.
ex= -300.abs=>300 ,while Math.abs(-300) gives me error in ruby or rgss.
Seen June 9th, 2019
Posted June 9th, 2019
13 posts
83 Days
So you want to know if a point is within an ellipse? Did you try Googling that? "Point ellipse collision" got me this Stack Exchange answer.
i have googled but don't get to that point also complex maths is not completely understandable to me as i want complete access with math .
Advertiser Content