Advertisement
Guest User

Camera.cs

a guest
Jun 4th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Microsoft.Xna.Framework;
  6. using Microsoft.Xna.Framework.Input;
  7. using Microsoft.Xna.Framework.Graphics;
  8.  
  9. namespace The_Calling
  10. {
  11.         public class Camera
  12.         {
  13.             public Matrix viewMatrix;
  14.             private Vector2 m_position;
  15.             private Vector2 m_halfViewSize;
  16.  
  17.             public Camera(Rectangle clientRect)
  18.             {
  19.                 m_halfViewSize = new Vector2(clientRect.Width * 0.5f, clientRect.Height * 0.5f);
  20.                 UpdateViewMatrix();
  21.             }
  22.  
  23.             public Vector2 Pos
  24.             {
  25.                 get
  26.                 {
  27.                     return m_position;
  28.                 }
  29.  
  30.                 set
  31.                 {
  32.                     m_position = value;
  33.                     UpdateViewMatrix();
  34.                 }
  35.             }
  36.  
  37.             private void UpdateViewMatrix()
  38.             {
  39.                 viewMatrix = Matrix.CreateTranslation(m_halfViewSize.X - m_position.X, m_halfViewSize.Y - m_position.Y, 0.0f);
  40.             }
  41.         }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement