public static bool didCollide(Vector2 centerBottom, Vector2 size, Level level) { FloatRectangle occupiedArea = FloatRectangle.createFromCenterBottom(centerBottom, size); if (level.IsCollidingAt(occupiedArea)) { return(true); } return(false); }
public bool IsCollidingAt(FloatRectangle a_rect) { Vector2 tileSize = new Vector2(1, 1); for (int x = 0; x < LEVEL_WIDTH; x++) { for (int y = 0; y < LEVEL_HEIGHT; y++) { FloatRectangle rect = FloatRectangle.createFromTopLeft(new Vector2(x, y), tileSize); if (a_rect.isIntersecting(rect)) { if (m_tiles[x, y] == Tile.BLOCKED) { return(true); } } } } return(false); }
internal bool isIntersecting(FloatRectangle other) { if (Right < other.Left) { return(false); } if (Bottom < other.Top) { return(false); } if (Left > other.Right) { return(false); } if (Top > other.Bottom) { return(false); } return(true); }