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


C++ Bird类代码示例

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


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

示例1: ofEnableAlphaBlending

//--------------------------------------------------------------
void ofApp::setup(){
    
    //Systemwide Settings
    ofEnableAlphaBlending();
    ofSetVerticalSync(TRUE);
    ofSetBackgroundAuto(FALSE);
    ofSetFrameRate(60);
//    ofSetFullscreen(true);
    ofSetBackgroundColor(0, 0, 0);
    ofSetCircleResolution(128);
    
    isMousePressed = false;
    
    //number of birds initiation
    numBirds = 300;
    framesBetweenRecordedPosition = 3;
    frameCounter = 0;
    
    //create all my birds
    for(int i = 0; i < numBirds; i++){
        Bird tempBird; //create a temp bird
        tempBird.setup(); //give it life
        myBirds.push_back(tempBird); //copy it and stick it in the vectory
    } //tempBird is no more
    
    
    //cursorAmp is the magnitude multiplier to the cursor attraction force it will approach an assymptote of
    cursorAmp = 1.0;
    ampAsymptote = 7.0;
}
开发者ID:conorrussomanno,项目名称:CreativeCoding_oF_F15,代码行数:31,代码来源:ofApp.cpp

示例2: setup

//--------------------------------------------------------------
void ofApp::setup(){
    numBirds = 100;
    //create all my birds
    for(int i=0; i<numBirds; i++){
        Bird tempBird; //create a temporary bird
        tempBird.setup(); //give it life
        myBirds.push_back(tempBird); //stick it in the vector
    } //tempBird is no more
}
开发者ID:danaavesar,项目名称:of_creativecoding_fall2015_dana_avesar,代码行数:10,代码来源:ofApp.cpp

示例3: countFastest

int BirdModel::countFastest() {
	int num = 0;
	Bird* bird;
	for (int i = 0; i < dimX * dimY; i++) {
		bird = agents.getAgent(repast::AgentId(i, rank, 0));
		if (bird->getFastest())
			num += 1;
	}
	return num;
}
开发者ID:LucRosset,项目名称:simpleHPC,代码行数:10,代码来源:model.cpp

示例4: hmm1

  Action Player::shoot(const GameState &pState, const Deadline &pDue) {
    if (lastRound != pState.getRound()) {
      hmm.clear();

      for (unsigned int i = 0; i < pState.getNumBirds(); ++i) {
        HMM hmm1(this -> STATES, this -> DIRECTIONS);
        hmm.push_back(hmm1);
      }
    }

    for (unsigned int i = 0; i < pState.getNumBirds(); ++i) {
      Bird b = pState.getBird(i);
      if (b.isDead())
        continue;

      int n = b.getSeqLength();

      // if (n < THRESHOLD || pState.getRound() == 0)
      //   continue;

      std::vector<int> seq(n, 0);
      for (int j = 0; j < n; ++j) {
        seq[j] = b.getObservation(j);
      }

      hmm[i].estimateMatrices(seq);

      std::vector<long double> em = hmm[i].getNextEmissionDist();
      long double max = -1;
      int nextMove = -1;
      for (int j = 0; j < DIRECTIONS; ++j) {
        if (em[j] > max) {
          max = em[j];
          nextMove = j;
        }
      }

      if (max > MIN_PROBABILITY) {
        std::cerr << "Shooting with prob: " << max << std::endl;
        hmm[i].printTransitionMatrix();
        hmm[i].printEmissionMatrix();
        std::cerr << std::endl << std::endl;
        ++shots;
        return Action(i, (EMovement)nextMove);
      }
    }

    // cerr << "Shots: " << shots << endl;
    // cerr << "Hits:  " << hits << endl;
    // if (shots != 0) 
    //   cerr << "Rate:  " << (double) hits / (double) shots << endl << endl;

    // This line choose not to shoot
    return cDontShoot;
  }
开发者ID:fristedt,项目名称:ai14,代码行数:55,代码来源:Player.cpp

示例5: new

Bird* Bird::create(const std::string& filename, const std::string& c_plist, const char* c_FileNameFormat, Vec2 P0, Vec2 P1, Vec2 P2, Vec2 P3, float DelayTime, float FlyTime)
{
	Bird *sprite = new (std::nothrow) Bird(filename, c_plist, c_FileNameFormat, P0, P1, P2, P3, DelayTime, FlyTime);
	if (sprite && sprite->init())
	{
		sprite->autorelease();		
		return sprite;
	}
	CC_SAFE_DELETE(sprite);
	return nullptr;
}
开发者ID:operatium,项目名称:Drup_App,代码行数:11,代码来源:Bird.cpp

示例6: Bird

void Scene::populate(int n, int size)
{
    for (int i = 0; i < n; ++i) {
        Bird * b = new Bird(size);

        // set a random position
        b->setPos(Rand::randPointF(sceneRect()));

        addItem(b);
    }
}
开发者ID:fela,项目名称:swarm-experiments,代码行数:11,代码来源:scene.cpp

示例7: setup

//--------------------------------------------------------------
void ofApp::setup(){
    
    // Number of Birds
    numBirds = 100;
    
    // Create all Birds.
    for (int i = 0; i < numBirds; i++) {
        Bird tempBird;                  // Create a Bird,
        tempBird.setup();               // Give this Bird all initial content,
        myBirds.push_back(tempBird);    // Put this Bird into myBirds Array.
    }
}
开发者ID:hungk901,项目名称:CreativeCoding_oF_F15_KuoJui_Hung,代码行数:13,代码来源:ofApp.cpp

示例8: Bird

Bird* Bird::createWithWorld( b2World* world )
{
	Bird* result = new Bird();
	if (result && result->initWithWorld(world))
	{
		result->autorelease();
		return result;
	} else {
		delete result;
		result = NULL;
		return NULL;
	}
}
开发者ID:HoaPham98,项目名称:TinyWingsDemo,代码行数:13,代码来源:Bird.cpp

示例9: main

int main(){
  Bird *b = new Bird();
  FlyingBird *f = new FlyingBird();
  Penguin *p = new Penguin();
  assert(b->f() == 21);
  assert(f->g() == 42);
  assert(p->f() == 42);
  assert(p->g() == 21);
  delete b;
  delete f;
  delete p;
  return 0;
}
开发者ID:ssvlab,项目名称:esbmc-gpu,代码行数:13,代码来源:main.cpp

示例10: BlueBird

void BlueBird::special()
{


    Bird *duplicate;
    b2Vec2 v = g_body->GetLinearVelocity();
    duplicate = new BlueBird(ratio,g_pixmap.pos()+QPointF(0,g_pixmap.pixmap().height()),g_pixmap.pixmap());
    duplicate->launch(b2Vec2(v.x,v.y-5));
    list->push_back(duplicate);
    duplicate = new BlueBird(ratio,g_pixmap.pos()-QPointF(0,g_pixmap.pixmap().height()),g_pixmap.pixmap());
    duplicate->launch(b2Vec2(v.x,v.y+5));
    list->push_back(duplicate);
}
开发者ID:yunxun,项目名称:pd2-Angrybird-1,代码行数:13,代码来源:bluebird.cpp

示例11: main

int main() {
  Bird b; 
  Cat c;
  Pet* p[] = { &b, &c, };
  for(int i = 0; i < sizeof p / sizeof *p; i++)
    cout << p[i]->type() << " je "
         << p[i]->eats()->foodType() << endl;
  // Funkcja moze zwrocic dokladny typ:
  Cat::CatFood* cf = c.eats();
  Bird::BirdFood* bf;
  // Funkcja nie moze zwrocic dokladnego typu:
//!  bf = b.eats();
  // Trzeba rzutowac w dol:
  bf = dynamic_cast<Bird::BirdFood*>(b.eats());
} ///:~
开发者ID:miodek,项目名称:Thinking_in_cpp_1,代码行数:15,代码来源:VariantReturn.cpp

示例12: BlueBird

void BlueBird::special()
{
    Bird *duplicate;
    b2Vec2 v = g_body->GetLinearVelocity();
    float angle=atan2f(v.y,v.x), spin=PI/18, dist=g_pixmap.pixmap().height();
    duplicate = new BlueBird(ratio,g_pixmap.pos()+QPointF(dist*cosf(angle+PI/2),dist*-sinf(angle+PI/2)),g_pixmap.pixmap());
    duplicate->launch(b2Vec2(v.x*cosf(spin)+v.y*-sinf(spin),v.x*+sinf(spin)+v.y*cosf(spin)));
    list->push_back(duplicate);

    duplicate = new BlueBird(ratio,g_pixmap.pos()+QPointF(dist*cosf(angle-PI/2),dist*-sinf(angle-PI/2)),g_pixmap.pixmap());
    duplicate->launch(b2Vec2(v.x*cosf(-spin)+v.y*-sinf(-spin),v.x*sinf(-spin)+v.y*cosf(-spin)));
    list->push_back(duplicate);


}
开发者ID:KJC1004,项目名称:pd2-Angrybird,代码行数:15,代码来源:bluebird.cpp

示例13: main

// bad code for demonstration purpose only!
int main(){
  cout << "(a)----------------------------\n";
        Hummingbird hummingbird;
        Bird        bird = hummingbird; // slicing
        Animal &    animal = hummingbird;
  cout << "(b)-----------------------------\n";
	    hummingbird.makeSound();
	    bird.makeSound();
	    animal.makeSound(); // non-virtual!
  cout << "(c)-----------------------------\n";
        hummingbird.move();
        bird.move();
        animal.move();
  cout << "(d)-----------------------------\n";
}
开发者ID:MattPD,项目名称:Prog3,代码行数:16,代码来源:main.cpp

示例14: doSomething

void doSomething(Flyable *obj)
{
    cout << typeid(*obj).name() <<endl;
    obj->takeoff();
    if(typeid(*obj) == typeid(Bird))
    {
        Bird *bird = dynamic_cast<Bird * >(obj);
        bird->foraging();
    }
    if(typeid(*obj) == typeid(Plane))
    {
        Plane *plane = dynamic_cast<Plane * >(obj);
        plane->carry();
    }
    obj->land();
}
开发者ID:whjkm,项目名称:project,代码行数:16,代码来源:main.cpp

示例15: doSomething

void doSomething(Flyable *obj)                 // 做些事情
{
    obj->takeoff();

    cout << typeid(*obj).name() << endl;        // 输出传入对象类型("class Bird" or "class Plane")

    if(typeid(*obj) == typeid(Bird))            // 判断对象类型
    {
        Bird *bird = dynamic_cast<Bird *>(obj); // 对象转化
        bird->foraging();
    }

    obj->land();

    return;
};
开发者ID:RongLi1986,项目名称:Algorithms,代码行数:16,代码来源:cpp_notes.cpp


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