当前位置: 首页>>代码示例>>C++>>正文


C++ Guard::addObjective方法代码示例

本文整理汇总了C++中Guard::addObjective方法的典型用法代码示例。如果您正苦于以下问题:C++ Guard::addObjective方法的具体用法?C++ Guard::addObjective怎么用?C++ Guard::addObjective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guard的用法示例。


在下文中一共展示了Guard::addObjective方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file


//.........这里部分代码省略.........
                QPolygonF myPolygon;
                myPolygon << QPointF(-5, 0) << QPointF(0, 5)
                        << QPointF(5, 0) << QPointF(0, -5)
                        << QPointF(-5, 0);
                board[j][i]->setPolygon(myPolygon);
                board[j][i]->setZValue(0);
                board[j][i]->setBrush(Qt::blue);
                goals.append(board[j][i]);
            }
            board[j][i]->occupant = NULL;
            this->addItem(board[j][i]);
        }
    }

    /*for(int i = 0; i < 16; ++i){
        this->addLine((float)(i * 20),0.0,(float)(i * 20),300.0,QPen(QColor(Qt::gray)));
        this->addLine(0.0,(float)(i * 20),300.0,(float)(i * 20),QPen(QColor(Qt::gray)));
    }*/
    


    // --------------------------------------
    QString fileName = "test2.glbt.xml";

    QFile file(fileName);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){
        qDebug("Could not open behavior tree file");
        return;
    }
    QByteArray byteArray = file.readAll();
    QString fileContents(byteArray.data());
    file.close();

/*    QString logFilename = "log.txt";

    logFile = new QFile(logFilename);
    if(!logFile->open(QIODevice::Append | QIODevice::Text)){
        qDebug("Could not open file");
        return;
    }

    QTextStream out(logFile);
    out << ";Board;Killtime;Avg Killtime;Interest;Challenge;Behavior Div;Spatial Div;Max Deviation;Standard Deviation;\n";//*/


    //QByteArray byteArray = logFile.readAll();
   // QString fileContents(byteArray.data());

    //file.close();

    btBrain *brain = new btBrain(fileContents);
    
    //this->setBackgroundBrush(QBrush(QColor(Qt::black)));

   /* ss = new ScenarioSet();
    Scenario *s1 = new Scenario();

    ss->addScenario(s1);*/
    
    marker = new Player(this,QPoint(8,12));//new GameItem(this);
    connect(marker, SIGNAL(pacmanLost()), this, SLOT(resetAfterLost()));
    connect(marker, SIGNAL(pacmanWon()), this, SLOT(resetAfterWon()));


    marker->setBrush(Qt::magenta);
    
    Enemy *player = new Enemy(marker,brain->getBehaviorTree(2));
    player->thename = "mr. anderson";
    Runner* playerRunner = new Runner(player);
    connect(playerRunner, SIGNAL(finished()), this, SLOT(resetGame()));
    runners.append(playerRunner);//*/
    
    //int trees[3] = {6,7,9}; // pinky
    //int trees[3] = {7,7,9}; // clyde
    //int trees[3] = {9,7,9}; // Blinky
    //int trees[3] = {0,7,9}; // Pure Random*/
	
	//int trees[1] = {0};
	int trees[1] = {1};

    ColorGen colors(0,255,30);

    for (int i = 0; i < this->numberOfEnemies(); i++)
    {
        Guard* agent = new Guard(this,QPoint(0,0));
        Enemy *enemy = new Enemy(agent,brain->getBehaviorTree(trees[i]));
        agent->setBrush(QBrush(colors.nextColor()));
        
        Runner* runner = new Runner(enemy);
        connect(runner, SIGNAL(finished()), this, SLOT(resetGame()));
        runners.append(runner);
        enemy->thename = "mr. smith " + QVariant(i).toString();
        agent->addObjective(marker);
        //connect(agent, SIGNAL(enteredNewCell(int,int)), s1, SLOT(visit(int,int)));
        marker->addObjective(agent);
    }//*/

    foreach(GameItem* goal,goals){
        marker->addGoal(goal);
    }
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的Guard::addObjective方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。