int main(int argc, char** argv) { initEngineGlut(argc,argv); Airplane avion; avion.draw(); cin.ignore(); return 0; }
int main() { Airport seoul("Seoul"); Airplane *pa = new ModelA; pa->fly(seoul); Airplane *pa1 = new ModelB; pa1->fly(seoul); Airplane *pa2 = new ModelC; pa2->fly(seoul); return 0; }
void GamePlayer::addAirPlane(uint32 id, bool isBuy) { Airplane *air = m_player.add_airplanelist(); air->set_id(id); if (isBuy) { m_player.set_currentairplane(id); } uint32 position_num = TableManager::getInstance().getTable("PlaneProperty")->asInt(id, "position_number"); if (position_num != IMPOSSIBLE_RETURN) { switch (position_num) { case 5: air->mutable_slotfive()->set_isopen(true); case 4: air->mutable_slotfour()->set_isopen(true); case 3: air->mutable_slotthree()->set_isopen(true); case 2: air->mutable_slottwo()->set_isopen(true); case 1: air->mutable_slotone()->set_isopen(true); default: break; } } }
void main() { /* Vector : 크기 , 방향 */ // x, y, z, w // 데이터 저장용 XMFLOAT4 vf4 = XMFLOAT4(0,0,0,0); FLOAT fx = vf4.x; FLOAT fy = vf4.y; FLOAT fz = vf4.z; FLOAT fw = vf4.w; // 32bit x 4 = 128bit // x, y, z, w // 데이터 연산용 , 128bit XMVECTOR vxm = XMVectorZero(); fx = XMVectorGetX(vxm); fy = XMVectorGetY(vxm); fz = XMVectorGetZ(vxm); fw = XMVectorGetW(vxm); vxm = XMVectorSet(1, 1, 1, 1); // XMFLOAT4 -> XMVECTOR 변환 XMVECTOR vnew = XMLoadFloat4(&vf4); // XMVECTOR -> XMFLOAT4 변환 XMStoreFloat4(&vf4, vnew); /* ( 5, 100, -4 ) Airplane 클래스 만들고, XMFLOAT3 멤버변수로 넣고, XMVECTOR 변환 출력 Airplane 클래스 { Setposition(XMFLOAT3) SetpositionXM(XMVECTOR) Show() } */ /* 부모 클래스 소멸자에 virtual 을 붙이는 이유 */ //Airplane ap; Transform * pt = new Airplane; //Airplane* pap = (Airplane*)(pt); Airplane* pap = dynamic_cast<Airplane*>(pt); XMVECTOR appos = XMVectorSet(1, 2, 3, 4); pap->setPositionXM(appos); pap->Show(); delete pt; pt = nullptr; }
int main(int argc, char** argv) { FGFDM fdm; // Read try { readXML(argv[1], fdm); } catch (const sg_exception &e) { printf("XML parse error: %s (%s)\n", e.getFormattedMessage().c_str(), e.getOrigin()); } Airplane* airplane = fdm.getAirplane(); PropEngine* pe = airplane->getThruster(0)->getPropEngine(); Propeller* prop = pe->getPropeller(); Engine* eng = pe->getEngine(); pe->init(); pe->setMixture(1); pe->setFuelState(true); eng->setBoost(1); float alt = (argc > 2 ? atof(argv[2]) : 0) * FT2M; pe->setAir(Atmosphere::getStdPressure(alt), Atmosphere::getStdTemperature(alt), Atmosphere::getStdDensity(alt)); float speed = (argc > 3 ? atof(argv[3]) : 0) * KTS2MPS; float wind[3]; wind[0] = -speed; wind[1] = wind[2] = 0; pe->setWind(wind); printf("Alt: %f\n", alt / FT2M); printf("Spd: %f\n", speed / KTS2MPS); printf("-----------------\n"); printf("Throt RPM thrustlbs HP eff %% torque\n"); for(int i=0; i<COUNT; i++) { float throttle = i/(COUNT-1.0); pe->setThrottle(throttle); pe->stabilize(); float rpm = pe->getOmega() * (1/RPM2RAD); float tmp[3]; pe->getThrust(tmp); float thrust = Math::mag3(tmp); float power = pe->getOmega() * eng->getTorque(); float eff = thrust * speed / power; printf("%5.3f %7.1f %8.1f %8.1f %7.1f %8.1f\n", throttle, rpm, thrust * N2LB, power * (1/HP2W), 100*eff, eng->getTorque()); } printf("\n"); printf("Propeller vs. RPM\n"); printf("-----------------\n"); printf("RPM thrustlbs HP eff %% torque\n"); for(int i=0; i<COUNT; i++) { float thrust, torque, rpm = 3000 * i/(COUNT-1.0); float omega = rpm * RPM2RAD; prop->calc(Atmosphere::getStdDensity(alt), speed, omega, &thrust, &torque); float power = torque * omega; float eff = (thrust * speed) / power; printf("%7.1f %11.1f %10.1f %7.1f %11.1f\n", rpm, thrust * N2LB, power * (1/HP2W), 100*eff, torque); } }
int main(void) { //while (true) //{ // int key = _getch(); // cout << hex << key << endl; //} //return 0; const int width = 70; const int height = 20; char board[height*width]; for (int i = 0; i < width*height; i++) { board[i] = ' '; } std::list<Bullet*> bulletDepot; int nPointCount = 0; //Circle one; //Square two; Airplane three; Shape* myShip[3] = {&three};//, &two, &three}; TypeA a; TypeB b; TypeC c; Enemy* enemies[3] = {&a,&b,&c}; a.SetPosition(Point(5, 5)); b.SetPosition(Point(15, 7)); c.SetPosition(Point(50, 5)); int x = width/2; int y = height/2; int dx = 1; int dy = 1; //one.SetRadius(5); //one.SetPosition(x, y); //two.SetSize(15,15); //two.SetPosition(x, y); three.SetPosition(Point(x,18)); three.SetSize(3); while (true) { // input if (_kbhit()) { int key = _getch(); if (key == SPECIAL) { key = _getch(); if (key == LEFT) { three.Move(Point(-1, 0)); } if (key == RIGHT) { three.Move(Point(1, 0)); } if (key == UP) { three.Move(Point(0, -1)); } if (key == DOWN) { three.Move(Point(0, 1)); } } else if (key == SPACE) { Bullet* pBullet = NULL; pBullet = new Bullet; pBullet->SetPosition(three.GetPosition()); bulletDepot.push_back(pBullet); } } // if (_kbhit()) // update for (int i = 0; i < 3; i++) { if (myShip[i]) myShip[i]->Update(); } for (int i = 0; i < 3; i++) { if (enemies[i]) enemies[i]->Update(); } std::list<Bullet*>::iterator it; for (it = bulletDepot.begin(); it != bulletDepot.end();) { (*it)->Update(); Point pt = (*it)->GetPosition(); if (pt.gety() < 0) { delete *it; it = bulletDepot.erase(it); } else { it++; } } // draw // board 에 그리기 for (int i = 0; i < width*height; i++) { board[i] = ' '; } for (int i = 0; i < 3; i++) { if (myShip[i]) { (*myShip[i]) >> board; } } for (int i = 0; i < 3; i++) { if (enemies[i]) { (*enemies[i]) >> board; } } for (it = bulletDepot.begin(); it != bulletDepot.end(); it++) { *(*it) >> board; } //one.Draw(board); //two.Draw(board); // board의 내용을 화면에 출력. zero(); for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { cout << board[y*width + x]; } cout << endl; } cout << "current bullet count : "; cout << setw(2) << setfill('0') << bulletDepot.size() << endl; cout << "current point : "; cout << setw(5) << setfill('0') << nPointCount << endl; } _getch(); return 0; }
int main() { Airport seoul("Seoul"); Airplane *pa = new ModelA; pa->fly(seoul); }
int main(int argc, char** argv) { FGFDM* fdm = new FGFDM(); Airplane* a = fdm->getAirplane(); if(argc < 2) return usage(); // Read try { string file = argv[1]; readXML(file, *fdm); } catch (const sg_exception &e) { printf("XML parse error: %s (%s)\n", e.getFormattedMessage().c_str(), e.getOrigin()); } // ... and run a->compile(); if(a->getFailureMsg()) printf("SOLUTION FAILURE: %s\n", a->getFailureMsg()); if(!a->getFailureMsg() && argc > 2 && strcmp(argv[2], "-g") == 0) { float alt = 5000, kts = 100; for(int i=3; i<argc; i++) { if (std::strcmp(argv[i], "-a") == 0) alt = std::atof(argv[++i]); else if(std::strcmp(argv[i], "-s") == 0) kts = std::atof(argv[++i]); else return usage(); } yasim_graph(a, alt, kts); } else { float aoa = a->getCruiseAoA() * RAD2DEG; float tail = -1 * a->getTailIncidence() * RAD2DEG; float drag = 1000 * a->getDragCoefficient(); float cg[3]; a->getModel()->getBody()->getCG(cg); a->getModel()->getBody()->recalc(); float SI_inertia[9]; a->getModel()->getBody()->getInertiaMatrix(SI_inertia); printf("Solution results:"); printf(" Iterations: %d\n", a->getSolutionIterations()); printf(" Drag Coefficient: %f\n", drag); printf(" Lift Ratio: %f\n", a->getLiftRatio()); printf(" Cruise AoA: %f\n", aoa); printf(" Tail Incidence: %f\n", tail); printf("Approach Elevator: %f\n", a->getApproachElevator()); printf(" CG: x:%.3f, y:%.3f, z:%.3f\n\n", cg[0], cg[1], cg[2]); printf(" Inertia tensor : %.3f, %.3f, %.3f\n", SI_inertia[0], SI_inertia[1], SI_inertia[2]); printf(" [kg*m^2] %.3f, %.3f, %.3f\n", SI_inertia[3], SI_inertia[4], SI_inertia[5]); printf(" Origo at CG %.3f, %.3f, %.3f\n", SI_inertia[6], SI_inertia[7], SI_inertia[8]); } delete fdm; return 0; }
bool Base::hasColidedWithRightBase(Airplane plane){ return plane.getXPosition() + plane.getWidth() > this->windowWidth/2 - 100; }
bool Base::hasColidedWithLeftBase(Airplane plane){ return plane.getXPosition() - plane.getWidth() < -this->windowWidth/2 + 100; }
int main(int argc, char* argv[]) { A a0; A a1 = a0; //use copy ctor beause here is a new object being defined. A a2; a2 = a0; //use copy assign ctor beause here isn't a new object being defined. enum {array_size = 10}; int iarry[array_size]; //enum hack const char* p_ch;//const occur at the left of aster means pointed data is const char* const cch = NULL;//const occur at the right of aster means pointer itself is const const char* const cp_ch = NULL; AudiCar audi; std::cout << "Timeline::innerVal:" << Timeline::innerVal << std::endl; std::cout << "Timeline::innerF:" << Timeline::innerF << std::endl; //A tempA = 2; bad_use_of_define(); callWithMax(88, 10); Timeline tl; tl.print(); char* testch = tl.getTag(); testch[0] = 'H';//const member function return value has been modified here. tl.print(); local_static_fun(); local_static_fun(); //std::tr1::shared_ptr<A> apA; boost::shared_ptr<A> apA; int ax = 2; int ay = 3; std::swap(ax, ay); std::cout << "ax:" << ax << " ay:" << ay << std::endl; //two old-style casts. //C-style cast // (T)expression; //function-style //T(expression); //new-style(four C++-style casts) // const_cast<T>(expression); //cast away the constness // dynamic_cast<T>(expression); //safe downcasting. // reinterpret_cast<T>(expression); // // static_cast<T>(expression);//implicit conversion Derived d; d.mf1(); d.mf2(); d.mf3(); d.mf4(); Base* base = new Derived; base->mf1(); base->Base::mf1();//when called be explicitly tell the name of the class. base->mfB();// delete base; Airplane* pAirplane = new ModeC_Airplane; Airport aport; pAirplane->fly(aport); delete pAirplane; Student student; Person person; //eat(student); //error: ‘Person’ is an inaccessible base of ‘Student’ eat(person); student.snap(); test_trait("abc", t_trait_A()); Alloc_T* alloc = new Alloc_T;//will use Alloc_T::operator new(std::size_t size); Alloc_T* alloc2 = new (std::cout) Alloc_T;//use placement new, need a same signature placement delete when this throw exception. Alloc_T* alloc3 = new (std::nothrow) Alloc_T;//use nothrow new delete alloc; delete alloc2; delete alloc3; return EXIT_SUCCESS; }