Camera functions to convert between world and screen coordinates

This commit is contained in:
Simon Holmberg
2012-09-27 23:08:11 +02:00
parent a6117af112
commit 11aef39e29
2 changed files with 14 additions and 4 deletions
+10 -1
View File
@@ -28,6 +28,16 @@ namespace DepthsBelow
Speed = 300;
}
public Vector2 ScreenToWorld(Vector2 screenPos)
{
return Vector2.Transform(screenPos, Matrix.Invert(Transform));
}
public Vector2 WorldToScreen(Vector2 worldPos)
{
return Vector2.Transform(worldPos, Transform);
}
public void Update(GameTime gameTime)
{
float elapsed = gameTime.ElapsedGameTime.Milliseconds / 1000.0f;
@@ -48,7 +58,6 @@ namespace DepthsBelow
Matrix.CreateTranslation(new Vector3(-Position.X, -Position.Y, 0))
* Matrix.CreateRotationZ(Rotation)
* Matrix.CreateScale(Zoom)
//* Matrix.CreateTranslation(new Vector3(
;
}
}