Exemplo n.º 1
0
        internal bool isIntersectingTop(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;
        }
Exemplo n.º 2
0
 public void createGemBoundingBox()
 {
     Vector2 boundingBox = new Vector2(centerBottomPosition.X, (centerBottomPosition.Y));
     gemBoundingBox = FloatRectangle.createFromTopLeft(boundingBox, gemSize);
 }
Exemplo n.º 3
0
        /*************************************************
         * Check if object is coliding with a tile
         *************************************************/
        internal bool IsCollidingAt(FloatRectangle a_rect, Vector2 a_centerBottomPosition)
        {
            Vector2 topLeft = new Vector2(a_centerBottomPosition.X - 2, a_centerBottomPosition.Y);
            Vector2 topRight = new Vector2(a_centerBottomPosition.X + 2, a_centerBottomPosition.Y);

            if (topRight.X > Model.Level.LEVEL_WIDTH)
                topRight.X = Model.Level.LEVEL_WIDTH;

            if (topLeft.X < 0)
                topLeft.X = 0;

            Vector2 tileSize = new Vector2(1f, 1f);
            for (int x = (int)topLeft.X; x < topRight.X; x++)
            {
                for (int y = 0; y < LEVEL_HEIGHT; y++)
                {
                    FloatRectangle rect = FloatRectangle.createFromTopLeft(new Vector2(x, y), tileSize);
                    if (a_rect.isIntersecting(rect))
                    {
                        if (levelTiles[x, y].isBlocked())
                        {
                            player.setAllowedJump(true);
                            player.setMustBoogie(false);
                            return true;
                        }

                        if (levelTiles[x, y].isTrap())
                        {
                            levelTiles[x, y].setWalkedOn(true);
                            player.setAllowedJump(false);
                            player.setMustBoogie(true);
                            return true;
                        }

                        if (levelTiles[x, y].isExit())
                            exitLevel = true;
                    }
                }
            }
            return false;
        }
Exemplo n.º 4
0
 public void createBoundingBox()
 {
     Vector2 boundingBox = new Vector2(centerBottomPosition.X - playerSize.X / 2, (centerBottomPosition.Y - playerSize.Y));
     playerBoundingBox = FloatRectangle.createFromTopLeft(boundingBox, playerSize);
 }