Ejemplo n.º 1
0
    //makes a "room" AKA an open space surrounded on all sides by walls
    bool make_room(int px, int py, int rx, int ry)
    {
        if (px + rx == size + 1 || py + ry == size + 1)
        {
            return(false);
        }
        //Go to that position
        for (int y = py; y < py + ry; y++)
        {
            for (int x = px; x < px + rx; x++)
            {
                tile t = maze [y, x];
                t.set_status(tile.Status.maze);

                //If x == 0 set west wall
                if (x == px)
                {
                    t.set_westwall(tile.Wall.wall);

                    if (!((x - 1) < 0))
                    {
                        maze [y, x - 1].set_eastwall(tile.Wall.wall);
                    }
                }
                else
                {
                    t.set_westwall(tile.Wall.none);

                    if (!((x - 1) < 0))
                    {
                        maze [y, x - 1].set_eastwall(tile.Wall.none);
                    }
                }
                //if y == 0 set north wall
                if (y == py)
                {
                    t.set_northwall(tile.Wall.wall);
                    if (!((y - 1) < 0))
                    {
                        maze [y - 1, x].set_southwall(tile.Wall.wall);
                    }
                }
                else
                {
                    t.set_northwall(tile.Wall.none);
                    if (!((y - 1) < 0))
                    {
                        maze [y - 1, x].set_southwall(tile.Wall.none);
                    }
                }
                //if x == size set east wall
                if (x == px + rx - 1)
                {
                    t.set_eastwall(tile.Wall.wall);
                    if (!((x + 1) == size))
                    {
                        maze [y, x + 1].set_westwall(tile.Wall.wall);
                    }
                }
                else
                {
                    t.set_eastwall(tile.Wall.none);
                    if (!((x + 1) == size))
                    {
                        maze [y, x + 1].set_westwall(tile.Wall.none);
                    }
                }
                //if y == size set south wall
                if (y == py + ry - 1)
                {
                    t.set_southwall(tile.Wall.wall);

                    if (!((y + 1) == size))
                    {
                        maze [y + 1, x].set_northwall(tile.Wall.wall);
                    }
                }
                else
                {
                    t.set_southwall(tile.Wall.none);
                    if (!((y + 1) == size))
                    {
                        maze [y + 1, x].set_northwall(tile.Wall.none);
                    }
                }
            }
        }

        return(true);
        //for loop through the array
        //set every tile to room tile
        //set every tile to have no walls (this would be an issue if it's an edge wall)
    }