using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game200
{
    public class Button
    {
        Texture2D image;
        Rectangle rec;
        Color color;
        bool wasPressed;
        public bool isPressed;

        public Button(string name, int x, int y)
        {
            image = C.LoadImage(name);
            rec = new Rectangle(x - image.Width / 2, y - image.Height / 2, image.Width, image.Height);
            color = Color.White;
            isPressed = false;
            wasPressed = false;
        }

        public void Update()
        {
            if (rec.Contains(C.MousePoint()))
            {
                color = Color.Yellow;
                isPressed = C.IsMousePressed();
                if (wasPressed && isPressed)
                {
                }
                else
                {
                    wasPressed = isPressed;
                }
                if (!wasPressed)
                    isPressed = false;
            }
            else
            {
                isPressed = false;
                wasPressed = false;
                color = Color.White;
            }
        }

        public void Draw()
        {
            C.spriteBatch.Draw(image, rec, color);
        }
    }
}
