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


C++ WorldObject::setcollisionable方法代码示例

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


在下文中一共展示了WorldObject::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);
}
开发者ID:seivan,项目名称:zombie_cpp_sdl,代码行数:51,代码来源:Map.cpp


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