示例#1
0
        private Droplet CreateRandomDroplet(Random rand)
        {
            //var rand = new Random();
            Color[] colors = { Color.DarkSlateBlue, Color.MidnightBlue, Color.DarkBlue, Color.DarkRed, Color.DarkSeaGreen, Color.ForestGreen, Color.DarkBlue, Color.DarkOliveGreen, Color.OliveDrab };

            //Color[] colors = { Color.Sienna };

            float randX = (float)rand.Next(this.GraphicsDevice.Viewport.Width);

            Console.WriteLine(randX);
            Console.WriteLine(this.GraphicsDevice.Viewport.Width);
            Console.WriteLine(this.graphics.PreferredBackBufferWidth);
            float randY    = (float)rand.Next(this.GraphicsDevice.Viewport.Height / 2);
            float randSize = (float)rand.Next(15, 30);
            //float randSpeed = rand.Next(1, 2);
            //float randSpeed = 0.5f;
            float randSpeed = (float)(rand.NextDouble()) * (1.2f - 0.3f) + 0.3f;
            int   randColor = rand.Next(colors.Length);

            Droplet drop = new Droplet(randX, randY, randSize, randSpeed * 0.5f, colors[randColor], this);

            drop.LoadContent(this.Content);

            return(drop);
        }
示例#2
0
 public bool CollidesWith(Droplet b)
 {
     if (
         ((b.bounds.X > this.bounds.X && b.bounds.X < this.bounds.X + this.bounds.Width) ||
          (b.bounds.X + b.bounds.Width > this.bounds.X && b.bounds.X + b.bounds.Width < this.bounds.X + this.bounds.Width))
         &&
         ((this.bounds.Y + this.bounds.Height > b.bounds.Y && this.bounds.Y + this.bounds.Height < b.bounds.Y + b.bounds.Height) ||
          (this.bounds.Y < b.bounds.Y + b.bounds.Height && this.bounds.Y > b.bounds.Y)))
     {
         return(true);
     }
     return(false);
 }
示例#3
0
 public void RemoveDroplet(Droplet d)
 {
     this.droplets.Remove(d);
 }