AxiosEngine-old 

AxiosEngine-old Mercurial Source Tree


Root/axios/Engine/Gleed2D/Camera.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
 
namespace Axios.Engine.Gleed2D
{
    public class Camera
    {
        Vector2 position;
        public Vector2 Position
        {
            get
            {
                return position;
            }
            set
            {
                position = value;
                updatematrix();
            }
        }
 
        float rotation;
        public float Rotation
        {
            get
            {
                return rotation;
            }
            set
            {
                rotation = value;
                updatematrix();
            }
        }
 
        float scale;
        public float Scale
        {
            get
            {
                return scale;
            }
            set
            {
                scale = value;
                updatematrix();
            }
        }
 
        public Matrix matrix;
        Vector2 viewport;                //width and height of the viewport
 
 
        public Camera(float width, float height)
        {
            position = Vector2.Zero;
            rotation = 0;
            scale = 1.0f;
            viewport = new Vector2(width, height);
            updatematrix();
        }
 
        void updatematrix()
        {
            matrix = Matrix.CreateTranslation(-position.X, -position.Y, 0.0f) *
                     Matrix.CreateRotationZ(rotation) *
                     Matrix.CreateScale(scale) *
                     Matrix.CreateTranslation(viewport.X / 2, viewport.Y / 2, 0.0f);
        }
 
        public void updateviewport(float width, float height)
        {
            viewport.X = width;
            viewport.Y = height;
            updatematrix();
        }
 
    }
}
Source at commit b5444bca056e created 12 years 5 months ago.
By Nathan Adams, * - Starting work on AxiosCSV

Archive Download this file

Page rendered in 1.42947s using 11 queries.