本文整理汇总了C++中EventHandler::bang方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::bang方法的具体用法?C++ EventHandler::bang怎么用?C++ EventHandler::bang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::bang方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void Test :: run(){
//Test frand
// assert( frand()==0.1f );
// assert( frand()==0.7f );
// assert( frand()==0.7f );
// assert( frand()==0.1f );
// cout << "gismoManager::randmom() is OK."<<endl;
cout << "CLASS Sound is ok.(check the receive yourself.)" << endl;
//TestEventHandler
EventHandler eventHandler;
EvTest evTest;
eventHandler.eventAdd("/t01" , &evTest);
int args[] = {0,1,2};
assert ( eventHandler.bang("/t01", args) == 138 );
assert ( eventHandler.bang("/t01") == 137 );
cout << "GismoBundledClass::eventHandler is OK." << endl;
//Test EventHandler with Gismo
gismo.eventAdd("/t01" , &evTest);
assert ( gismo.bang("/t01" , args) == 138 );
//Sound Trigger
int snd_id = 0;
setSound(0);
setSound(2);
setSound(4);
cout << "GismoManager::eventHandler with Gismo is OK." << endl;
//Define an agent
ag_t ag;
//Test GismoManager.getAgents()
ag_t *agents = gismo.getAgents();
agents[0].posi.x = 0.13f;
agents[0].posi.y = 0.2f;
assert(agents[0].posi.x == 0.13f);
assert(agents[0].posi.y == 0.2f);
cout << "GismoManager:getAgent() is OK." << endl;
//Test GismoLibrary distance()
posi_t tmp1, tmp2;
tmp1.x = 0.0f;
tmp1.y = 0.0f;
tmp2.x = 3.0f;
tmp2.y = 4.0f;
assert(distance(tmp1, tmp2) == 5.0f);
tmp1.x = 0.5f;
tmp1.y = 0.5f;
tmp2.x = -0.5f;
tmp2.y = -0.5f;
assert(distance(tmp1, tmp2)==(float)sqrt(2.0f));
tmp1.x = 3.0f;
tmp1.y = 4.0f;
tmp2.x = 0.0f;
tmp2.y = 0.0f;
assert(distance(tmp1, tmp2) == 5.0f);
tmp1.x = 5.0f;
tmp1.y = 12.0f;
tmp2.x = 0.0f;
tmp2.y = 0.0f;
assert(distance(tmp1, tmp2) == 13.0f);
cout << "GismoLibrary:distance() is OK." << endl;
//Test Init AgentActive
initAgentActive(&ag);
assert(ag.size == AG_DEF_SIZE);
assert(ag.active==true);
cout << "GismoLibrary:initAgentActive() is OK." << endl;
//TestAgentAdd
initAgentActive(&ag);
ag.view = 0.23f;
ag.posi.x = 0.2f; ag.posi.y=0.2f;
gismo.addAgent(ag);
assert (gismo.add.buf[0].view == 0.23f);
assert (gismo.add.count == 1);
cout << "GismoManager:addAgent() is OK." << endl;
//TestSync
ag_t ag2;
initAgentActive(&ag2);
ag2.view = 0.34f;
gismo.addAgent(ag2);
gismo.addSync(); //Finally gismo requires sync to avoid direct agent addition when processing agents.
assert(gismo.add.count==0 && gismo.agents.count==2);
assert(agents[0].active && agents[1].active);
assert(agents[0].view==0.23f && agents[1].view==0.34f);
cout << "gismoLibrary:addSync() is OK." << endl;
//Test gismo Library seekNearest();
agents[0].posi.x = 0.0f;
agents[0].posi.y = 0.0f;
agents[1].posi.x = 0.5f;
//.........这里部分代码省略.........