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


C++ SolarSystem::Add方法代码示例

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


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

示例1: main

int main()
{
    ScreenManager::GetInstance().SetText("Testing");
    ScreenManager::GetInstance().DrawText();

    Material* quartz = new Material((char*)"Quartz", false, false);
    Material* granite = new Material((char*)"Granite", false, false);

    Clock* clock = new Clock();

    World* world = new World();

    SolarSystem* solar = new SolarSystem();
    //                          name,       mass,           diameter (mi),  radius (mi),    surf gravity (m/s2)
    solar->Add(new Star((char*)"Sun",       MASS(1.989,30), 864337.3,       432169,         274));
    solar->Add(new Planet((char*)"Mercury", MASS(3.285,23), 3032,           1516,           3.7));
    solar->Add(new Planet((char*)"Venus",   MASS(4.867,24), 7520.8,         3760,           8.87));
    solar->Add(new Planet((char*)"Earth",   MASS(5.972,24), 7917.5,         3959,           9.807));
    solar->Add(new Planet((char*)"Mars",    MASS(6.39,23),  4212,           2106,           3.711));
    solar->Add(new Planet((char*)"Jupiter", MASS(1.898,27), 86881.4,        43441,          24.79));
    solar->Add(new Planet((char*)"Saturn",  MASS(5.683,26), 72367.4,        36184,          10.44));
    solar->Add(new Planet((char*)"Uranus",  MASS(8.681,25), 31518,          15759,          8.87));
    solar->Add(new Planet((char*)"Neptune", MASS(1.024,26), 30599,          15299,          11.15));

    //                                  name               mass                diameter (mi)radius (mi)surf gravity (m/s2)
    Planet* earth    = new Planet(      (char*)"Earth",     MASS(5.972,24),    7917.5,      3959,   9.807);
    Satellite* moon  = new Satellite(   (char*)"Moon",      MASS(7.347,22),    2159,        1079,   1.62);
    earth->Add(moon);
    solar->Add(earth);

    sf::RenderWindow window(sf::VideoMode(WIDTH, HEIGHT), "Game");
    window.setFramerateLimit(60);

    srand(time(0));

    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    

    Hashtable hash;
    hash.Put("Test","Test2");
    int one = 1;
    hash.Put("one", &one);
    printf("Hashtable %s %d",(char *)hash.Get("Test"), *(int *)hash.Get("one"));

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        clock->Update();

        window.clear();
        window.draw(shape);
        window.display();
    }

    Engine egnine;
    return 0;
}
开发者ID:codedevmk,项目名称:zol,代码行数:65,代码来源:Game.cpp


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