Ejemplo n.º 1
0
void MapGenerator::fillBSP(TCODBsp* root){


        TCODBsp* temp = root;

        fillBox(temp->x,temp->y,temp->w,temp->h,"wall");


        if (temp->isLeaf()){
            std::cout<<temp->x<<", "<<temp->y<<"//"<<temp->w<<", "<<temp->h<<"\n";
            int offset = RNG->getInt(1, 2);
            temp->x = (temp->x)+offset;
            temp->w = RNG->getInt((temp->w)-3,(temp->w)-(offset+1));
            offset = RNG->getInt(1, 2);
            temp->y = (temp->y)+offset;
            temp->h = RNG->getInt((temp->h)-3,(temp->h)-(offset+1));
            fillBox(temp->x,temp->y,temp->w,temp->h,"grnd");
        }

     //   fillBox(temp->x,temp->y,temp->w,temp->h,"grnd");

         if (!temp->isLeaf()){
            fillBSP(temp->getLeft());
            fillBSP(temp->getRight());

            connectBSP(temp);

            }





}
Ejemplo n.º 2
0
void MapGenerator::genBSP(int numberLayers, int layerNumber){
    if (layerNumber == 0){
        fillBox(0,0,mapw,maph,"watr");
    }
    else{
        fillBox(0,0,mapw,maph,"watr");
    }
    TCODBsp* myBSP = new TCODBsp(0,0,mapw, maph);

        int firstSplit = RNG->getInt(19,30);
        myBSP->splitOnce(false,firstSplit);
         TCODBsp *openSpace;
         TCODBsp *closedSpace;
   //      if(firstSplit>39 ){// this is one of many possible configurations. using bsp, half open, half closed style level.

     //           openSpace = myBSP->getLeft();
       //         closedSpace = myBSP->getRight();
         //}else{

                closedSpace = myBSP->getLeft();
                openSpace = myBSP->getRight();
        //}

         closedSpace->splitRecursive(NULL,4,8,8,1.8,1.4);
         openSpace->splitRecursive(NULL, 3,7 ,7,1.5,1.5);
        TCODBsp *temp = closedSpace;

        fillBSP(closedSpace);
        //connectBSP(closedSpace);
        myBSP->resize(0,0,mapw, maph);
}