예제 #1
0
        internal bool IsCollidingAt(FloatRectangle a_rect)
        {
            Vector2 tileSize = new Vector2(0.034f, 0.034f);

            for (int x = 0; x < m_levelWidth; x++)
            {
                for (int y = 0; y < m_levelHeight; y++)
                {
                    FloatRectangle rect = FloatRectangle.createFromTopLeft(new Vector2((float)x / 30, (float)y / 30), tileSize);
                    if (a_rect.isIntersecting(rect))
                    {
                        if (m_tiles[x, y].GetTileType() == TileType.PORTAL)
                        {
                            m_playerHitPortal = true;
                            return(false);
                        }

                        if (m_tiles[x, y].GetTileType() == TileType.LETHAL)
                        {
                            m_playerStruckLethalTile = true;
                            return(false);
                        }
                        else if (m_tiles[x, y].GetTileType() == TileType.FAKE) // When the player hits a fake tile, make it an empty tile.
                        {
                            m_tiles[x, y] = Tile.CreateEmpty();
                        }
                        if (m_tiles[x, y].isBlocked() || m_playerStruckLethalTile)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }