Apologies in advance if this is an embarrassingly simple problem. Complete newbie to game creation (and math).
I'm want to make a top down game where instead of the player moving on the screen, they stay static in the center and enemies on the screen move and rotate according the the player's virtual movements.
We find the virtual X and Y and hypotenuse like so:
set enemy.distanceX to enemy.virtualX - player.virtualX
set enemy.distanceY to enemy.virtualY - player.virtualY
set distanceFromPlayer to sqrt(enemy.distanceX^2 + enemy.distanceY^2)
From there I want to know how far the player (and therefore the whole screen) is rotated in relation to the virtual coordinates. I get that like so:
set enemy.virtualAngle to asin(enemy.distanceY/enemy.distanceFromPlayer)
set enemy.totalAngle to enemy.virtualAngle + player.rotation
Then to find the enemy's screen x and y coordinates:
set enemy.X to cos(enemy.totalAngle)*enemy.distanceFromPlayer
set enemy.Y to sin(enemy.totalAngle)*enemy.distanceFromPlayer
The problem is that when an enemy passes from one quadrant to another asin(enemy.distanceY/enemy.distanceFromPlayer) "bounces". I assumed because of the negative/positive values for enemy.distanceY that a value could be returned anywhere in the full 360 degree range. Instead, it rises to 90 and then bounces back.
My apologies again if this is a stupid question, or if I've explained it poorly. I didn't even know what the hell sine was until 3 days ago. Working at it though :p