public override Rectangle[] getCollisionBoxes() { Rectangle[] r = new Rectangle[bounds.w * bounds.h]; for (int i = 0; i < bounds.h; i++) { for (int j = 0; j < bounds.w; j++) { r[i * bounds.w + j] = new Rectangle(bounds.x + j, bounds.y + i, 1, 1); } } return r; }
public static double Distance(Rectangle r1, Rectangle r2) { return Math.Sqrt(Math.Pow(r1.x - r2.x, 2) + Math.Pow(r1.y - r2.y, 2)); }
public static bool Contains(Rectangle a, Point p) { return (p.x >= a.x && p.x <= a.x + a.w && p.y >= a.y && p.y <= a.y + a.h); }
public static bool Intersects(Rectangle a, Rectangle b) { return Contains(a, b.getTopLeft()) || Contains(a, b.getBottomRight()); }
public BasicRoom(int x, int y, int w, int h) { bounds = new Rectangle(x, y, w, h); }