using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;

namespace Game200
{
    public static class C
    {
        public static ContentManager Content;
        public static SpriteBatch spriteBatch;
        public static GraphicsDevice graphicsDevice;
        public static Vec screenDim;
        public static int length;

        static C()
        {
            screenDim = new Vec(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height);
            length = 20;
        }

        public static Vector2 UnitVector(float angle)
            => new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle));
        public static Texture2D LoadImage(string name)
            => Content.Load<Texture2D>(name);
        public static void SimpleDraw(Texture2D image, Vec position, Color color, float scale)
            => spriteBatch.Draw(image, FromCoord(position).ToVector2(), null, color, 0, new Vector2((float)image.Width / 2, (float)image.Height / 2), scale, SpriteEffects.None, 0);
        public static Vec ToCoord(Vector2 pos)
            => new Vec((int)(pos.Y / length + 0.5f), (int)(pos.X / length + 0.5f));
        public static Point FromCoord(Vec pos)
            => new Point(pos.Y * length, pos.X * length);
        public static Vector2 FromCoord(Vector2 pos)
            => new Vector2(pos.Y * length, pos.X * length);
        public static Vec MousePos()
            => ToCoord(new Vector2(Mouse.GetState().X, Mouse.GetState().Y));
        public static Point MousePoint()
            => new Point(Mouse.GetState().X, Mouse.GetState().Y);
        public static bool IsMousePressed()
            => Mouse.GetState().LeftButton == ButtonState.Pressed;
        public static bool IsMouseReleased()
            => Mouse.GetState().LeftButton == ButtonState.Released;
    }
}
