Advertisement
Guest User

Untitled

a guest
May 29th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1.         public Matrix matrix;
  2.         public Vector2 viewport;        
  3.  
  4.         public Vector2 Position
  5.         {
  6.             get
  7.             {
  8.                 return position;
  9.             }
  10.             set
  11.             {
  12.                 position = value;
  13.                 updatematrix();
  14.             }
  15.         }
  16.  
  17.  public Camera(float width, float height, Scene scene)
  18.         {
  19.             position = Vector2.Zero;
  20.             rotation = 0;
  21.             scale = 1.0f;
  22.             viewport = new Vector2(width, height);
  23.             updatematrix();
  24.             this.scene = scene;
  25.             this.rand = new Random();
  26.             this.width = width;
  27.             this.height = height;
  28.         }      
  29.  
  30.   void updatematrix()
  31.         {
  32.             matrix = Matrix.CreateTranslation(-position.X, -position.Y, 0.0f) *
  33.                      Matrix.CreateRotationZ(rotation) *
  34.                      Matrix.CreateScale(scale) *
  35.                      Matrix.CreateTranslation(viewport.X / 2, viewport.Y / 2, 0.0f);
  36.         }
  37.  
  38.         public void updateviewport(float width, float height)
  39.         {
  40.             viewport.X = width;
  41.             viewport.Y = height;
  42.             updatematrix();
  43.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement