Advertisement
cheprogrammer

Isometric Map To Screen

May 13th, 2016
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1.         public Vector2 MapToScreen(Vector2 source)
  2.         {
  3.             switch (CameraDirection)
  4.             {
  5.                 case FaceDirection.NorthWest:
  6.                     return new Vector2(source.X * GameConstants.CellHalfWidth - source.Y * GameConstants.CellHalfWidth,
  7.                         source.X * GameConstants.CellHalfHeight + source.Y * GameConstants.CellHalfHeight);
  8.                 case FaceDirection.EastNorth:
  9.                     return new Vector2(source.Y * GameConstants.CellHalfWidth + source.X * GameConstants.CellHalfWidth,
  10.                         source.Y * GameConstants.CellHalfHeight - source.X * GameConstants.CellHalfHeight);
  11.                 case FaceDirection.SouthEast:
  12.                     return new Vector2(source.Y * GameConstants.CellHalfWidth - source.X * GameConstants.CellHalfWidth, -(source.X * GameConstants.CellHalfHeight + source.Y * GameConstants.CellHalfHeight));
  13.                 case FaceDirection.WestSouth:
  14.                     return new Vector2(-(source.X * GameConstants.CellHalfWidth + source.Y * GameConstants.CellHalfWidth), source.X * GameConstants.CellHalfHeight - source.Y * GameConstants.CellHalfHeight);
  15.             }
  16.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement