本文整理汇总了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;
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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.
}
}
示例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;
}
}
示例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;
}
示例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);
}
示例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());
} ///:~
示例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);
}
示例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";
}
示例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();
}
示例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;
};