RocketMonster
Member
I am trying to find an elegant way to calculate if a given point is inside a slope (of varying degrees).
A 45 is easy with the below formulae to check if the green point is inside the slope (pink);
if x + y > tile_width then inside = true
Is there a math trick for checking non 45 degree slops such as...
I could store the "inside" points in an array and check that but my tiles are 24x24 in game and I have over 20 non 45 degree sloped tiles, so that's a lot of numbers and a lot of work if I decide later to use smaller or larger tiles or add more tiles etc.
A 45 is easy with the below formulae to check if the green point is inside the slope (pink);
if x + y > tile_width then inside = true
Is there a math trick for checking non 45 degree slops such as...
I could store the "inside" points in an array and check that but my tiles are 24x24 in game and I have over 20 non 45 degree sloped tiles, so that's a lot of numbers and a lot of work if I decide later to use smaller or larger tiles or add more tiles etc.
Attachments
-
1.3 KB Views: 0