示例#1
0
        private static int MovePlayer(int x)
        {
            int noChangeX = x;

            if (isGrounded)
            {
                if (moveLeft)
                {
                    x -= Gravity_Engine.MomentumCalculater();
                }
                else if (moveRight)
                {
                    x += Gravity_Engine.MomentumCalculater();
                }
                else
                {
                    if (Gravity_Engine.MomentumCalculater() > 0)
                    {
                        if (x < noChangeX)
                        {
                            x += Gravity_Engine.MomentumCalculater();
                        }
                        else if (x > noChangeX)
                        {
                            x -= Gravity_Engine.MomentumCalculater();
                        }
                    }
                    else
                    {
                        Gravity_Engine.SetAirSpeed("Stop");
                    }
                    Console.WriteLine(Gravity_Engine.MomentumCalculater());
                }
            }
            else
            {
                if (moveLeft)
                {
                    x -= Gravity_Engine.MomentumCalculater();
                }
                else if (moveRight)
                {
                    x += Gravity_Engine.MomentumCalculater();
                }
            }
            return(x);
        }
示例#2
0
        private static int JumpPlayer(int y)
        {
            if (isGrounded && canJump)
            {
                Gravity_Engine.SetAirSpeed("Up");
                y         -= Gravity_Engine.JumpGravity();
                isGrounded = false;
            }

            else if (!isGrounded && canJump)
            {
                y -= Gravity_Engine.JumpGravity();
            }

            else if (!isGrounded && !canJump)
            {
                y += Gravity_Engine.FallingGravity();
            }
            return(y);
        }