private bool didCollide(Vector2 a_centerBottom, Vector2 a_size) { FloatRectangle occupiedArea = FloatRectangle.createFromCenterBottom(a_centerBottom, a_size); if (m_level.IsCollidingAt(occupiedArea)) { return(true); } return(false); }
internal bool IsCollidingAt(FloatRectangle a_rect) { Vector2 tileSize = new Vector2(0.9f, 0.9f); for (int x = 0; x < g_levelWidth; x++) { for (int y = 0; y < g_levelHeight; y++) { FloatRectangle rect = FloatRectangle.createFromTopLeft(new Vector2(x, y), tileSize); if (a_rect.isIntersecting(rect)) { if (m_tiles[x, y] == TileType.BLOCKED || m_tiles[x, y] == TileType.Background) { 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); }