public static double GetDisplacement(ICA3Ball ball1, ICA3Ball ball2)
        {
            double displacement;

            displacement = Math.Sqrt(Math.Pow((ball2._pos.X - ball1._pos.X), 2) + Math.Pow((ball2._pos.Y - ball1._pos.Y), 2));
            ++DisplacementCalls;

            return(displacement);
        }
        public void MarkOverlap(ICA3Ball oBall)
        {
            double displacement = GetDisplacement(this, oBall);

            if (displacement <= ballRadius)
            {
                bColor = Color.Red;
                _color = bColor;
            }
        }
Пример #3
0
        private void TimerClick_Tick(object sender, EventArgs e)
        {
            Point    newClick = new Point(-1, -1);
            ICA3Ball newBall;


            if (canvas.GetLastMouseLeftClick(out newClick))
            {
                newBall = new ICA3Ball(canvas, newClick);
                canvas.Clear();
                for (int ballIndex = 0; ballIndex < ballList.Count(); ++ballIndex)
                {
                    ballList[ballIndex].MarkOverlap(newBall);
                }
                ballList.Add(newBall);

                foreach (ICA3Ball ball in ballList)
                {
                    ball.Render();
                }
                canvas.Render();
            }
        }