Skip to content

Commit

Permalink
Base angle movement
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuj committed Mar 4, 2022
1 parent 775b669 commit 09b1c8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions Characters/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,19 @@ public override void Update(GameTime delta)
var movement = InputHandler.GetEvent("Movement");
var mouseState = Mouse.GetState();
DiagnosticsHook.DebugMessage(damage.ToString());
Vector2 mousePos = Scene.ToGridLocation(mouseState.Position);
Vector2 deltaPos = new Vector2((mousePos.X - Position.X), -(mousePos.Y - Position.Y));
DiagnosticsHook.DebugMessage(deltaPos.ToString());

if(health <= 0)
double personAngle = Math.Atan2(deltaPos.Y, deltaPos.X);
//double personAngle = Math.Atan(tanAngle);
//DiagnosticsHook.DebugMessage("Tan angle = " + tanAngle);
//DiagnosticsHook.DebugMessage("Person angle = " + personAngle);
float radianAngle = (float)((Math.PI / 180) * personAngle);
DiagnosticsHook.DebugMessage("Radian angle = " + radianAngle);
//sprite.Rotation = radianAngle;

if (health <= 0)
{
respawn();
} else
Expand All @@ -229,5 +240,4 @@ public override void Update(GameTime delta)
Scene.LookAt(Position);
}
}

}

0 comments on commit 09b1c8f

Please sign in to comment.