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); }
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; }
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; }