コード例 #1
0
ファイル: Ball.cs プロジェクト: fagan2888/coding-world-cup
        public Position StopPosition(GamePitch pitch)
        {
            double   distance     = (speed * speed) / (2 * friction);
            Vector   scaledVector = vector.getScaledVector(distance);
            Position stopPosition = position.getPositionPlusVector(scaledVector);

            stopPosition.AdjustBounce(pitch);
            return(stopPosition);
        }
コード例 #2
0
        public void AdjustBounce(GamePitch pitch)
        {
            if (this.x < 0.0)
            {
                this.x *= -1.0;
            }
            if (this.x > pitch.width)
            {
                this.x = pitch.width - (this.x - pitch.width);
            }

            if (this.y < 0.0)
            {
                this.y *= -1.0;
            }

            if (this.y > pitch.height)
            {
                this.y = pitch.height - (this.y - pitch.height);
            }
        }