Exemple #1
0
        public override void ClientMoveAndDisplay(GameTime gameTime)
        {
            IndexedVector3 walkDirection = IndexedVector3.Zero;
            float          walkVelocity  = 1.1f * 4.0f; // 4 km/h -> 1.1 m/s
            float          walkSpeed     = walkVelocity * 0.001f;

            IndexedMatrix xform = ghostObject.GetWorldTransform();


            IndexedVector3 forwardDir = xform._basis[2];
            IndexedVector3 upDir      = xform._basis[1];
            IndexedVector3 strafeDir  = xform._basis[0];

            forwardDir.Normalize();
            upDir.Normalize();
            strafeDir.Normalize();

            KeyboardState keyboardState = Keyboard.GetState();


            if (keyboardState.IsKeyDown(Keys.I))
            {
                walkDirection += forwardDir;
            }
            if (keyboardState.IsKeyDown(Keys.K))
            {
                walkDirection -= forwardDir;
            }
            if (keyboardState.IsKeyDown(Keys.J))
            {
                IndexedMatrix orn = ghostObject.GetWorldTransform();
                orn._basis *= IndexedBasisMatrix.CreateFromAxisAngle(new IndexedVector3(0, 1, 0), 0.01f);
                ghostObject.SetWorldTransform(orn);
            }
            if (keyboardState.IsKeyDown(Keys.L))
            {
                IndexedMatrix orn = ghostObject.GetWorldTransform();
                orn._basis *= IndexedBasisMatrix.CreateFromAxisAngle(new IndexedVector3(0, 1, 0), -0.01f);
                ghostObject.SetWorldTransform(orn);
            }
            //if (key == Keys.O)
            //{
            //    playerController.Jump();
            //}

            IndexedVector3 result = walkDirection * walkSpeed;

            playerController.SetWalkDirection(ref result);

            base.ClientMoveAndDisplay(gameTime);
        }
        public override void ClientMoveAndDisplay(GameTime gameTime)
        {
            IndexedVector3 walkDirection = IndexedVector3.Zero;
            float          walkVelocity  = 1.1f * 4.0f;
            float          walkSpeed     = walkVelocity * gameTime.ElapsedGameTime.Milliseconds / 1000.0f;

            IndexedMatrix  xform      = m_ghostObject.GetWorldTransform();
            IndexedVector3 forwardDir = xform._basis[2];
            IndexedVector3 upDir      = xform._basis[1];
            IndexedVector3 strafeDir  = xform._basis[0];

            forwardDir.Normalize();
            upDir.Normalize();
            strafeDir.Normalize();

            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.I))
            {
                walkDirection += forwardDir;
            }
            if (keyboardState.IsKeyDown(Keys.K))
            {
                walkDirection -= forwardDir;
            }
            if (keyboardState.IsKeyDown(Keys.J))
            {
                IndexedMatrix orn = m_ghostObject.GetWorldTransform();
                orn._basis *= IndexedBasisMatrix.CreateFromAxisAngle(new IndexedVector3(0, 1, 0), 0.01f);
                m_ghostObject.SetWorldTransform(orn);
            }
            if (keyboardState.IsKeyDown(Keys.L))
            {
                IndexedMatrix orn = m_ghostObject.GetWorldTransform();
                orn._basis *= IndexedBasisMatrix.CreateFromAxisAngle(new IndexedVector3(0, 1, 0), -0.01f);
                m_ghostObject.SetWorldTransform(orn);
            }

            IndexedVector3 result = walkDirection * walkSpeed;

            m_character.SetWalkDirection(ref result);

            base.ClientMoveAndDisplay(gameTime);
        }