예제 #1
0
        public void UpdatePosition()
        {
            PhysicsUtilites.ClampVelocity((IPhysics)this);
            double xPos = Block.DestinationRectangle.Location.X;
            double yPos = Block.DestinationRectangle.Location.Y;

            yPos += Math.Round(YVelocity);
            Vector2 pos = PhysicsUtilites.ClampPosition(xPos, yPos, (IPhysics)this);

            Block.Location             = pos;
            Block.DestinationRectangle = new Rectangle((int)pos.X, (int)pos.Y, Block.DestinationRectangle.Width, Block.DestinationRectangle.Height);
            YVelocity += GravityCoef;
        }
예제 #2
0
        public void UpdatePosition()
        {
            PhysicsUtilites.ClampVelocity((IPhysics)this);
            double xPos = Mario.DestinationRectangle.Location.X;
            double yPos = Mario.DestinationRectangle.Location.Y;

            xPos += Math.Round(XVelocity);
            yPos += Math.Round(YVelocity);
            if (yPos > MinPosition.Y)
            {
                Mario.KillMario();
            }
            if (xPos > MaxPosition.X)
            {
                XMinVelocity = PhysicsUtilites.PlayerMinVelocityX;
            }
            if (xPos > PhysicsUtilites.FlagPosition && yPos < 0)
            {
                XVelocity = 0;
                xPos      = PhysicsUtilites.FlagPosition;
            }
            if (xPos > PhysicsUtilites.FlagPosition - 1)
            {
                resetTimer++;
                if (resetTimer >= 500)
                {
                    game.GameReset.Execute();
                    game.toggleCastle = false;
                }
            }
            if (xPos >= PhysicsUtilites.XMaxPosition)
            {
                Mario.DrawInvisibleSprite = true;
                game.toggleCastle         = true;
            }
            else
            {
                game.toggleCastle = false;
            }
            Vector2 pos = PhysicsUtilites.ClampPosition(xPos, yPos, (IPhysics)this);

            Mario.SetPosition(pos);
            XVelocity  = XVelocity * XDampingCoef;
            YVelocity += GravityCoef;
        }