Re: Collision detection in 2d games when turning is a thing?
I'd personally do target_x-player_x, not the other way around because you can do the following.
If you need to get the angle between an angle, you can use:
angle = atan(sin(target_y-player_y)/cos(target_x-player_x))
If you have a point at say 3, 3 and the player is at 1, 1, then you can subtract the player's coordinates from the target's coordinates. Similarly, if the player is at 3 3 and the target at 1 1, then the relative difference between the 2 points is -2, -2, therefore you get the angle in the appropriate quadrant.
If you do player_x-target_x, if the player is at 1 and the target at 2, you get a relative difference of -1, which is the negative of the correct distance. Similarly if the player is at -1 and the target at -2, -1-(-2) = 1, therefore you have the target appearing in the opposite direction.
_______________________________________________ Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector