public bool Move(int width, int height)
        {
            for (int i = Count - 1; i >= 0; --i)
            {
                if (_movingBall.TouchesGreen(Balls[i]))
                {
                    Balls.RemoveAt(i);
                }
            }

            _movingBall.Move(width, height);

            if (Balls.RemoveAll(ball => ball.OutOfBounds) > 0)
            {
                _movingBall = null;
                return(true);
            }

            return(false);
        }
示例#2
0
        public void Move()
        {
            if (movingBall != null)
            {
                Point p = new Point(movingBall.Centar.X + (int)(10 * Math.Cos(movingAngle)), movingBall.Centar.Y + (int)(10 * Math.Sin(movingAngle)));
                movingBall.Move(p);
                if ((p.X + Ball.Radius < 0 || p.X - Ball.Radius > Width) || (p.Y + Ball.Radius < 0 || p.Y - Ball.Radius > Height))
                {
                    balls.Remove(movingBall);
                    movingBall = null;
                }
            }

            if (movingBall != null)
            {
                for (int i = 0; i < balls.Count; i++)
                {
                    if (balls[i].Color == Color.Green && balls[i].isHit(movingBall.Centar.X, movingBall.Centar.Y))
                    {
                        balls.RemoveAt(i);
                    }
                }
            }
        }