本文整理汇总了C++中MovableObject::setcollisionable方法的典型用法代码示例。如果您正苦于以下问题:C++ MovableObject::setcollisionable方法的具体用法?C++ MovableObject::setcollisionable怎么用?C++ MovableObject::setcollisionable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MovableObject
的用法示例。
在下文中一共展示了MovableObject::setcollisionable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadmap
/**
* FUNCTION Map::loadmap(std::string path)
* Loads a map from a file and creates all surfaces
* and sets the right settings for all tiles on the map
*
* Every map tile is then stored in a vector (mapdata) that
* is later used when rendering the map to screen
*/
void Map::loadmap(std::string path) {
MovableObject* stall = new MovableObject();
stall->setx(190);
stall->sety(100);
stall->settexture("graphics/stall.png");
stall->setmovable(true);
stall->setcollisionable(true);
stall->setsurface(draw_engine->load_image(stall->gettexture()));
int tiles_per_row = (DrawEngine::get_screen_width() / 128);
int y = -33;
int x_off = 0;
int counter = 0;
// create grass
for (int i = 0; i < 300; i++) {
WorldObject* grass = new WorldObject();
grass->setx(x_off + ((counter - 1) * 128));
grass->sety(y);
grass->settexture("graphics/grass3.png");
grass->setmovable(false);
grass->setcollisionable(false);
SDL_Surface* surf_grass = draw_engine->load_image(grass->gettexture());
grass->setsurface(surf_grass);
mapdata.push_back(grass);
if ((counter >= tiles_per_row && x_off == 0) || (counter
>= (tiles_per_row) + 1)) {
y += 32;
x_off = (x_off == 0) ? -(64 * 1) : 0;
counter = 0;
}
counter++;
}
this->setwidth(tiles_per_row);
this->setheight(y);
mapdata.push_back(stall);
}