示例#1
0
文件: BallsDoc.cs 项目: AtanasK/VP
 void GenerateHolesR(int left, int top, int width, int height)
 {
     if (Holes.Count == 5) return;
     int x = random.Next(left + Hole.RADIUS, (left + width) - Hole.RADIUS);
     int y = random.Next(top + Hole.RADIUS, (top + height) - Hole.RADIUS);
     bool touches = false;
     foreach (Hole h in Holes)
     {
         touches = h.Touches(x, y);
         if (touches) break;
     }
     if (!touches)
     {
         Hole h = new Hole(new Point(x, y));
         Holes.Add(h);
     }
     GenerateHolesR(left, top, width, height);
 }
示例#2
0
文件: Ball.cs 项目: AtanasK/VP
 public bool InHole(Hole hole)
 {
     float d = (Center.X - hole.Center.X) * (Center.X - hole.Center.X) + (Center.Y - hole.Center.Y) * (Center.Y - hole.Center.Y);
     return d <= RADIUS * RADIUS;
 }
示例#3
0
文件: Hole.cs 项目: kmartin62/VP
 public bool Colliding(Hole hole)
 {
     return(((hole.Centar.X - Centar.X) * (hole.Centar.X - Centar.X) + (hole.Centar.Y - Centar.Y) * (hole.Centar.Y - Centar.Y)) <= hole.RADIUS * RADIUS);
     //return (x - Centar.X) * (x - Centar.X) + (y - Centar.Y) * (y - Centar.Y) <= RADIUS * RADIUS;
 }