예제 #1
0
        public void AddGeneratedBall()
        {
            int xCoordSpawn = 0;
            int yCoordSpawn = 0;

            Random randomGen = new Random();

            xCoordSpawn = 30 + randomGen.Next(width - 60);
            yCoordSpawn = 30 + randomGen.Next(height - 60);

            randomGen = new Random();
            double cosGen = randomGen.NextDouble() * 2 - 1;
            int    sign   = Math.Sign(-1 + randomGen.Next(1)) == 0 ? 1 : Math.Sign(-1 + randomGen.Next(1));
            double sinGen = sign * Math.Sqrt(1 - cosGen * cosGen);

            Ball ball = new Ball(xCoordSpawn, yCoordSpawn, ballsDiametrDefault, ballsColorDefault, Math.Atan2(sinGen, cosGen));

            balls.Add(ball);
            ball.Id = controller.AddBallRedrawing(ball);
        }