Beispiel #1
0
        private void updateMovement()
        {
            bool isMoveLeft  = Keyboard.IsKeyPressed(Keyboard.Key.A);
            bool isMoveRight = Keyboard.IsKeyPressed(Keyboard.Key.D);
            bool isJump      = Keyboard.IsKeyPressed(Keyboard.Key.Space);
            bool isMove      = isMoveLeft || isMoveRight;

            // Прыжок
            if (isJump && !isFly)
            {
                velocity.Y = -10f;
                //Program.ASD();
            }

            if (isFly && !isJump)
            {
                //Program.ASD();
            }
            if (isMove)
            {
                if (isFly && !isJump)
                {
                    Program.ASD();
                }
                if (isMoveLeft)
                {
                    if (movement.X > 0)
                    {
                        movement.X = 0;
                    }

                    movement.X -= PLAYER_MOVE_SPEED_ACCELERATION;
                    movement2.X = movement.X;
                    Direction   = -1;
                }
                else if (isMoveRight)
                {
                    if (movement.X < 0)
                    {
                        movement.X = 0;
                    }

                    movement.X += PLAYER_MOVE_SPEED_ACCELERATION;
                    Direction   = 1;
                    movement2.X = movement.X;
                }

                if (movement.X > PLAYER_MOVE_SPEED)
                {
                    movement.X = PLAYER_MOVE_SPEED;
                }
                else if (movement.X < -PLAYER_MOVE_SPEED)
                {
                    movement.X = -PLAYER_MOVE_SPEED;
                }

                // Анимация
                asHair.Play("run");
                asHead.Play("run");
                asShirt.Play("run");
                asUndershirt.Play("run");
                asHands.Play("run");
                asLegs.Play("run");
                asShoes.Play("run");
            }
            else
            {
                movement = new Vector2f();

                // Анимация
                asHair.Play("idle");
                asHead.Play("idle");
                asShirt.Play("idle");
                asUndershirt.Play("idle");
                asHands.Play("idle");
                asLegs.Play("idle");
                asShoes.Play("idle");
            }
        }