本文整理汇总了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;
};
示例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
}