using Otter;
using System;

namespace PenniesAreGold.objects
{
    class MenuPenny : Entity
    {
        private Spritemap<string> _spriteMap;
        private float _radius = Rand.Int(130);
        private float _angle = 0;
        private float _rotationSpeed = Rand.Float(5.5f);
        private int _life = 300;

        public MenuPenny(float x, float y)
        {
            X = x; Y = y;
            _spriteMap = new Spritemap<string>(Assets.MENUPENNY, 10, 10);
            _spriteMap.Add("spin", new int[] { 0, 1, 2, 3, 4, 5, 6, 7 }, new float[] { 5f, 5f });
            _spriteMap.Play("spin");
            Graphic = _spriteMap;
            Layer = 2;
        }

        public override void Update()
        {
            base.Update();
            X = 300 + _radius * (float)Math.Cos(_angle * Math.PI / 180);
            Y = 250 + _radius * (float)Math.Sin(_angle * Math.PI / 180);
            _angle -= _rotationSpeed;
            _radius += 1f;
            if (_life <= 0)
                this.RemoveSelf();
            if (_life > 0)
                _life--;
        }

    }
}
