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


C++ Level::add方法代码示例

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


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

示例1: initNewGame

hax::Level* hax::initNewGame(){
    //create objects
    Level* test = new Level();
    Area* borg = new Castle("Hogwarts");
    Area* kth = new School("KTH");
    Area* skog = new Forest("FoReSt Of DoOm");
    Area* tysk = new Shop("IKEA");

    Character* albus = new Wizard("Albus");
    Character* voldy = new Wizard("Voldy");
    Character* conan = new Barbarian("Conan");
    Character* snape = new Wizard("Snape");
    Character* necro = new Necromancer("Sauron");

    Key* nyckel = new Key();
    Container* sack = new Backpack();

    //build level
    test->add(borg);
    test->add(kth);
    test->add(skog);
    test->add(tysk);
    test->add(albus);
    test->add(voldy);
    test->add(conan);
    test->add(necro);
    borg->addRoute(new Road("north", borg, kth));
    borg->addRoute(new Road("west", borg, skog));
    kth->addRoute(new Road("south", kth, borg));
    kth->addRoute(new Door("southwest", kth, skog, nyckel));
    kth->addRoute(new Door("in", kth, tysk));
    skog->addRoute(new Road("east", skog, borg, new Tree()));
    skog->addRoute(new Road("northeast", skog, kth, snape));
    tysk->addRoute(new Door("out", tysk, kth));

    //add Character to Area
    borg->enter(albus);
    borg->enter(necro);
    kth->enter(conan);
    kth->enter(voldy);

    //add Object to Area
    kth->pick_up(nyckel);
    borg->pick_up(sack);

    //add Object to Character

    return test;
};
开发者ID:Jim-Holmstroem,项目名称:Hax---The-Game,代码行数:49,代码来源:game_debug.cpp

示例2: main

int main(int argc, char ** argv) {
    try {
        // game engine subsystems
        Graphics graphics;
        Level level;
        Time time;

        // load level
        level.setLevel(graphics.load("levels/mountains.bmp"));
        level.setBackground(graphics.load("levels/summer_sky.bmp"));
        auto player1 = Ship();
        auto player2 = Ship(Player::Two);
        player1.setSpawn(Point(50, 250));
        player1.respawn();
        player2.setSpawn(Point(100, 250));
        player2.respawn();
        player1.setImage(graphics.load("ships/ship2.bmp"));
        player2.setImage(graphics.load("ships/ship3.bmp"));
        level.add(player1);
        level.add(player2);

        // rendering loop
        bool quit{ false };
        while(!quit) {
            // calculate framerate
            int frameTime = time.frame();
            int fps = (int)round(1000.f / frameTime);
            Input::Event e;
            do { // handle input
                e = Input::nextInput();
                if(e == Input::QUIT) quit = true;
                level.notify(e);
            } while(e != Input::NO_EVENT);
            graphics.clear();
            level.update(frameTime);
            level.draw(graphics);
            graphics.draw(std::to_string(fps) + " fps", Point(25, graphics.getHeight() - 20.f));
            graphics.present();
        }

    } catch(std::exception e) {
        return EXIT_FAILURE; // error return code
    }
    return EXIT_SUCCESS; // normal program exit
}
开发者ID:alexpogue,项目名称:SpacePirates,代码行数:45,代码来源:main.cpp


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