Guest User

Untitled

a guest
Jul 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. public Matrix Transform(GraphicsDevice graphicsDevice)
  2. {
  3. float ViewportWidth = graphicsDevice.Viewport.Width;
  4. float ViewportHeight = graphicsDevice.Viewport.Height;
  5.  
  6. matrixTransform =
  7. Matrix.CreateTranslation(new Vector3(-cameraPosition.X, -cameraPosition.Y, 0)) *
  8. Matrix.CreateRotationZ(Rotation) *
  9. Matrix.CreateScale(new Vector3(Zoom, Zoom, 0)) *
  10. Matrix.CreateTranslation(
  11. new Vector3(ViewportWidth * 0.5f, ViewportHeight * 0.5f, 0));
  12. return matrixTransform;
  13. }
  14.  
  15. //Offsets any cam location by a zoom scaled window bounds
  16. Vector2 CamCenterOffset
  17. {
  18. get { return new Vector2((game.Window.ClientBounds.Height / Zoom)
  19. * 0.5f, (game.Window.ClientBounds.Width / Zoom) * 0.5f);
  20. }
  21. }
  22.  
  23. //Scales the mouse.X and mouse.Y by the same Zoom as everything.
  24. Vector2 MouseCursorInWorld
  25. {
  26. get
  27. {
  28. currMouseState = Mouse.GetState();
  29. return cameraPosition + new Vector2(currMouseState.X / Zoom,
  30. currMouseState.Y / Zoom);
  31. }
  32. }
Add Comment
Please, Sign In to add comment