Пример #1
0
        /*************************************** MOVIMIENTO ************************************************/

        public virtual void calcularTraslacionYRotacion(float elapsedTime, TerrenoSimple agua, float time, Vector3 lastPosition)
        {
            Vector3 lastPositionEnemy = EjemploAlumno.Instance.shipContrincante.getPosition();

            if (input.keyDown(Key.Left))
            {
                anguloRotacion -= elapsedTime * ROTATION_SPEED;
                rotacion        = Matrix.RotationY(anguloRotacion);
            }

            else if (input.keyDown(Key.Right))
            {
                anguloRotacion += elapsedTime * ROTATION_SPEED;
                rotacion        = Matrix.RotationY(anguloRotacion);
            }

            if (input.keyDown(Key.Up))
            {
                movementSpeed = Math.Min(movementSpeed + ESCALON_VEL, VEL_MAXIMA);
            }

            else if (input.keyDown(Key.Down))
            {
                movementSpeed = Math.Max(movementSpeed - ESCALON_VEL, 0);
            }



            movZ -= Convert.ToSingle(movementSpeed * Math.Cos(anguloRotacion) * elapsedTime);
            movX -= Convert.ToSingle(movementSpeed * Math.Sin(anguloRotacion) * elapsedTime);
            movY  = agua.aplicarOlasA(getPosition(), time).Y + AltoBote / 2;

            administrarColisiones(lastPosition, new Vector3(movX, movY, movZ), lastPositionEnemy);
        }
Пример #2
0
        public override void calcularTraslacionYRotacion(float elapsedTime, TerrenoSimple agua, float time, Vector3 lastPosition)
        {
            distance = player.popa() - this.getPosition();
            Vector3 iaDirectionVersor = this.vectorDireccion();

            iaDirectionVersor.Normalize();
            Vector3 lookAtPopaVersor = new Vector3(distance.X, distance.Y, distance.Z);

            lookAtPopaVersor.Normalize();

            float   rotationAngle = FastMath.Acos(Vector3.Dot(iaDirectionVersor, lookAtPopaVersor));
            Vector3 cross         = Vector3.Cross(lookAtPopaVersor, iaDirectionVersor);

            //Vector3 lastPosition = getPosition();

            if (cross.Length() > 0.1)
            {
                if (cross.Y > 0.1)
                {
                    anguloRotacion -= elapsedTime * ROTATION_SPEED;
                }
                if (cross.Y < -0.1)
                {
                    anguloRotacion += elapsedTime * ROTATION_SPEED;
                }

                rotacion = Matrix.RotationY(anguloRotacion);
            }

            if (FastMath.Abs(distance.Length()) > 1000)
            {
                movementSpeed = Math.Min(movementSpeed + ESCALON_VEL, VEL_MAXIMA);
            }
            if (FastMath.Abs(distance.Length()) <= 1000)
            {
                if (FastMath.Abs(distance.Length()) > 400)
                {
                    movementSpeed = Math.Max(movementSpeed - movementSpeed / distance.Length(), 0);
                }
                else
                {
                    movementSpeed = 0;
                }
            }

            movZ -= movementSpeed * FastMath.Cos(anguloRotacion) * elapsedTime;
            movX -= movementSpeed * FastMath.Sin(anguloRotacion) * elapsedTime;
            movY  = agua.aplicarOlasA(getPosition(), time).Y + AltoBote / 2;

            administrarColisiones(lastPosition, new Vector3(movX, movY, movZ));
        }
Пример #3
0
        /*************************************** MOVIMIENTO ************************************************/
        public virtual void calcularTraslacionYRotacion(float elapsedTime, TerrenoSimple agua, float time, Vector3 lastPosition)
        {
            Vector3 lastPositionEnemy = EjemploAlumno.Instance.shipContrincante.getPosition();

            if (input.keyDown(Key.Left))
            {
                anguloRotacion -= elapsedTime * ROTATION_SPEED;
                rotacion = Matrix.RotationY(anguloRotacion);
            }

            else if (input.keyDown(Key.Right))
            {
                anguloRotacion += elapsedTime * ROTATION_SPEED;
                rotacion = Matrix.RotationY(anguloRotacion);

            }

            if (input.keyDown(Key.Up))
            {
                movementSpeed = Math.Min(movementSpeed + ESCALON_VEL, VEL_MAXIMA);
            }

            else if (input.keyDown(Key.Down))
            {
                movementSpeed = Math.Max(movementSpeed - ESCALON_VEL, 0);
            }

            movZ -= Convert.ToSingle(movementSpeed * Math.Cos(anguloRotacion) * elapsedTime);
            movX -= Convert.ToSingle(movementSpeed * Math.Sin(anguloRotacion) * elapsedTime);
            movY = agua.aplicarOlasA(getPosition(), time).Y + AltoBote / 2;

            administrarColisiones(lastPosition, new Vector3(movX, movY, movZ), lastPositionEnemy);
        }
Пример #4
0
        public override void calcularTraslacionYRotacion(float elapsedTime, TerrenoSimple agua, float time, Vector3 lastPosition)
        {
            distance = player.popa() - this.getPosition();
            Vector3 iaDirectionVersor = this.vectorDireccion();
            iaDirectionVersor.Normalize();
            Vector3 lookAtPopaVersor = new Vector3(distance.X, distance.Y, distance.Z);
            lookAtPopaVersor.Normalize();

            float rotationAngle = FastMath.Acos(Vector3.Dot(iaDirectionVersor, lookAtPopaVersor));
            Vector3 cross = Vector3.Cross(lookAtPopaVersor, iaDirectionVersor);

            //Vector3 lastPosition = getPosition();

            if (cross.Length() > 0.1)
            {
                if (cross.Y > 0.1)
                {
                    anguloRotacion -= elapsedTime * ROTATION_SPEED;
                }
                if (cross.Y < -0.1)
                {
                    anguloRotacion += elapsedTime * ROTATION_SPEED;
                }

                rotacion = Matrix.RotationY(anguloRotacion);
            }

            if (FastMath.Abs(distance.Length()) > 1000)
            {
                movementSpeed = Math.Min(movementSpeed + ESCALON_VEL, VEL_MAXIMA);
            }
            if (FastMath.Abs(distance.Length()) <= 1000)
            {
                if (FastMath.Abs(distance.Length()) > 400)
                {
                    movementSpeed = Math.Max(movementSpeed - movementSpeed / distance.Length(), 0);
                }
                else
                {
                    movementSpeed = 0;
                }

            }

                movZ -= movementSpeed * FastMath.Cos(anguloRotacion) * elapsedTime;
                movX -= movementSpeed * FastMath.Sin(anguloRotacion) * elapsedTime;
                movY = agua.aplicarOlasA(getPosition(), time).Y + AltoBote / 2;

            administrarColisiones(lastPosition, new Vector3(movX, movY, movZ));
        }