예제 #1
0
        internal static void TryPushBallLine(GameState.Player player, GameState.PerimeterSegment perimeterSegment)
        {
            var directionalUnit = DirectionalUnit(perimeterSegment.Start, perimeterSegment.End);
            var normalUnit      = NormalUnit(perimeterSegment.Start, perimeterSegment.End, directionalUnit);

            var normalDistance     = player.PlayerFoot.Position.Dot(normalUnit);
            var lineNormalDistance = perimeterSegment.Start.Dot(normalUnit);

            var violation = Math.Abs(lineNormalDistance - normalDistance) - Constants.BallRadius;

            if (violation < 0)
            {
                var violationVector = normalUnit.NewScaled(violation * Math.Sign(lineNormalDistance - normalDistance));
                player.ExternalVelocity = player.ExternalVelocity.NewAdded(violationVector);
            }
        }
예제 #2
0
        internal static void TryPushBallBall(GameState.Player player1, GameState.Player player2)
        {
            // TODO
            // I want to make it possible to hold space
            // if you are holding your ground you dont move
            // if you are pushing you bounce off
            // or... maybe not
            // if you want to hold your ground you have to push back

            var dis = player1.PlayerBody.Position.NewAdded(player2.PlayerBody.Position.NewMinus());

            var violation = Constants.footLen * 8 - dis.Length;

            if (violation > 0)
            {
                player1.ExternalVelocity = player1.ExternalVelocity.NewAdded(dis.NewUnitized().NewScaled(violation * .005));
                player2.ExternalVelocity = player2.ExternalVelocity.NewAdded(dis.NewUnitized().NewScaled(-violation * .005));
            }
        }
예제 #3
0
 internal static void TryPushBallWall(GameState.Player player, (double x, double y, double radius) ballwall)