using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using Tao.OpenGl;

namespace Log740
{
    class Enemy : Cube
    {
        static public double Ground = -1;
        private Vecteur3F speed;

        public Enemy(double up_speed)
            : base(new Vecteur3F(1, 0, 0))
        {
            this.speed = new Vecteur3F(0, 0, up_speed);
        }

        protected double DistanceUnderground()
        {
            return Ground - (this.location.Z - this.size.Z);
        }

        protected override void AnimateInternal()
        {
            this.location += this.speed;

            double distance = DistanceUnderground();

            if (distance > 0)
            {
                this.speed.Z = -this.speed.Z;
                this.location.Z = Ground + this.size.Z + distance;
            }

            this.speed.Z -= 0.01; // gravity
        }
    }
}
