예제 #1
0
        private void centeringControl(long thisTime)
        {
            if (IsStateAlso(BallState.Sliding) && (Math.Abs(xyrotatorAnim.GetAnimation(0).GetCurrentSpeed(thisTime)) < 0.256))
            {
                Console.WriteLine("Devo scivolare!");
                double d = 1;
                if (!movingRight)
                {
                    d *= -1;
                }
                xyrotatorAnim.ChangeAnimator(
                    0,
                    new LinearUnboundedAnimator(
                        Math.Round(centerX),
                        thisTime,
                        d * 0.256
                        )
                    );
            }

            int   relativeX = getRelativeX(thisTime) - ((int)(Constants.BlockWidth / 2f));
            float maxRegion = Constants.BlockWidth * Constants.JumpableBlockRatio;

            if (Math.Abs(maxRegion) > Math.Abs(relativeX) && !isThisStateAlso(state, BallState.Sliding) && !isGoingToMove)
            {
                blockAll(thisTime);
            }
            if (!game.CheckBlock(0, 1))
            {
                StartFalling(thisTime);
            }
        }