Beispiel #1
0
        public override void move(AutomatedMovingObject obj)
        {
            double x = obj.getPosition().X;
            double y = obj.getPosition().Y;

            obj.setPreviousPosition(x, y);

            double velX = obj.getVelocity().X;
            double velY = obj.getVelocity().Y;


            double angle = (ScreenView.rnd.NextDouble() - ScreenView.rnd.NextDouble()) * Math.PI * 2 * 0.05;
            double newVX = velX * Math.Cos(angle) - velY * Math.Sin(angle);
            double newVY = velX * Math.Sin(angle) + velY * Math.Cos(angle);

            x += newVX;
            y += newVY;

            if (x < 0)
            {
                x = -x; newVX = -newVX;
            }
            if (x > 1)
            {
                x = 2 - x; newVX = -newVX;
            }
            if (y < 0 - obj.getSize())
            {
                y = 0 - obj.getSize(); newVY = -newVY;
            }

            obj.setPosition(x, y);
            obj.setVelocity(newVX, newVY);
        }
Beispiel #2
0
        public override void move(AutomatedMovingObject obj)
        {
            double x = obj.getPosition().X;
            double y = obj.getPosition().Y;

            obj.setPreviousPosition(x, y);

            double velX = obj.getVelocity().X;
            double velY = obj.getVelocity().Y;

            if (velY <= 0.0005 && velX < 0)
            {
                velY = 0.0005;
                obj.movementPhase = 1;
            }
            else if (velY <= 0.0005 && velX > 0)
            {
                velY = 0.0005;
                obj.movementPhase = 0;
            }


            double angle = 0;

            if (obj.movementPhase == 0)
            {
                angle = 0.05 * Math.PI * 2 * 0.05;
            }
            else if (obj.movementPhase == 1)
            {
                angle = -0.05 * Math.PI * 2 * 0.05;
            }

            double newVX = velX * Math.Cos(angle) - velY * Math.Sin(angle);
            double newVY = velX * Math.Sin(angle) + velY * Math.Cos(angle);

            x += newVX;
            y += newVY;

            if (x < 0)
            {
                x = -x; newVX = -newVX;
            }
            if (x > 1)
            {
                x = 2 - x; newVX = -newVX;
            }
            if (y < 0 - obj.getSize())
            {
                y = 0 - obj.getSize(); newVY = -newVY;
            }

            obj.setPosition(x, y);
            obj.setVelocity(newVX, newVY);
        }
Beispiel #3
0
        public override void move(AutomatedMovingObject obj)
        {
            double x = obj.getPosition().X;
            double y = obj.getPosition().Y;

            obj.setPreviousPosition(x, y);

            double velX = obj.getVelocity().X;
            double velY = obj.getVelocity().Y;

            double newX = x + velX;
            double newY = y + velY;

            obj.setPosition(newX, newY);
        }
Beispiel #4
0
 public abstract void move(AutomatedMovingObject obj);