Esempio n. 1
0
 public void swallow(RegularBall ball)
 {
     ball.isDone = true;
     Console.WriteLine("Terminated " + ball.ballType + " Ball [ " + ball.id + "]");
     this.color   = BallUtils.combineColors(this, ball);
     this.radius += ball.radius;
 }
Esempio n. 2
0
        private void initRegularBalls()
        {
            for (int i = 0; i < regularBallsCount; i++)
            {
                int       radius    = rnd.Next(1, 10);
                Position  position  = new Position(rnd.Next(canvas.width), rnd.Next(canvas.height));
                Color     color     = Color.FromArgb(rnd.Next(255), rnd.Next(255), rnd.Next(255));
                Direction direction = new Direction(rnd.Next(1, 5), rnd.Next(1, 5), rnd.Next(1, 10));

                RegularBall ball = new RegularBall(radius, position, color, direction);

                balls.Add(ball);
            }
        }
Esempio n. 3
0
        public void swallow(RegularBall ball)
        {
            //Console.WriteLine("R vs. R");
            RegularBall eater, eaten;

            if (this.radius > ball.radius)
            {
                eater = this;
                eaten = ball;
            }
            else
            {
                eater = ball;
                eaten = this;
            }

            eaten.isDone = true;
            Console.WriteLine("Terminated " + eaten.ballType + " Ball [ " + eaten.id + "]");
            eater.color   = BallUtils.combineColors(eater, eaten);
            eater.radius += eaten.radius;
        }
Esempio n. 4
0
 public void swallow(RegularBall ball)
 {
     this.color         = BallUtils.combineColors(this, ball);
     ball.direction.dx *= -1;
     ball.direction.dy *= -1;
 }