本文整理汇总了C++中GridMap::toGridCenterX方法的典型用法代码示例。如果您正苦于以下问题:C++ GridMap::toGridCenterX方法的具体用法?C++ GridMap::toGridCenterX怎么用?C++ GridMap::toGridCenterX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GridMap
的用法示例。
在下文中一共展示了GridMap::toGridCenterX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_test
void build_test() {
enum {GRID_SIZE = 32};
// build map
GridMap *gm = new GridMap(30, 30, GRID_SIZE);
gm->setTarget(5 * GRID_SIZE, 5 * GRID_SIZE);
for (int i = 0; i < 20; ++i) {
gm->setWalkableAt(10 * GRID_SIZE, i * GRID_SIZE, false);
}
for (int i = 10; i < 20; ++i) {
gm->setWalkableAt(i * GRID_SIZE, 10 * GRID_SIZE, false);
}
gm->updateRoute();
// test route
gm->printRoute();
gm->clearCreepsInfo();
gm->addCreepsAt(1 * GRID_SIZE, 1 * GRID_SIZE);
canBuildAt(gm, 1 * GRID_SIZE, 1 * GRID_SIZE);
canBuildAt(gm, 10 * GRID_SIZE, 10 * GRID_SIZE);
canBuildAt(gm, 20 * GRID_SIZE, 20 * GRID_SIZE);
// clear grids again
puts("Clear grids again");
gm->clearCreepsInfo();
canBuildAt(gm, 1 * GRID_SIZE, 1 * GRID_SIZE);
printf("Center of (5, 15) : (%d, %d)\n",
gm->toGridCenterX(5), gm->toGridCenterY(15));
CreepFactory *factory = new CreepFactory();
Creep *creep = factory->getCreep(creep::NORMAL);
creep->setX(500.0);
creep->setY(500.0);
creep->setGridMap(gm);
printf("%d, %d\n", gm->getNextX(193, 193), gm->getNextY(193, 193));
}