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


C++ ITimer::setTime方法代码示例

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


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

示例1: main

int main() {
	state.phase = GameState::PHASE_ENTERING;
	state.state = GameState::STATE_INGAME; // asdf
	try {
		UserConfig = ConfigFile(get_userdata_path() + "user.cfg");
	}
	catch (ConfigFile::file_not_found) {
		printf("No user config file found, creating...\n");
		boost::filesystem::create_directories(get_userdata_path());
		FILE *f;
		f = fopen((get_userdata_path() + "user.cfg").c_str(), "w");
		if (f == NULL) {
			printf("Could not create user config file. Aborting. Please check that the path to the user config file is available: %s", (get_userdata_path() + "user.cfg").c_str());
			exit(-1);
		}
		fclose(f);
		UserConfig = ConfigFile(get_userdata_path() + "user.cfg");
	}

	IrrlichtDevice *device = setupDevice(receiver, &UserConfig);
	if (!device) {
		printf("Could not create device.\n");
	}

	device->setWindowCaption(L"Licht Raiders");
	device->setResizable(false);

	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();
	collMan = smgr->getSceneCollisionManager();

/* Set up GUI */
//	gui::IGUISkin* skin = env->getSkin();
	setup_GUI();

/* Set up camera */

	scene::ISceneNode *cam_base = smgr->addEmptySceneNode(0, DEFAULT_ID);
	scene::ICameraSceneNode *cam = smgr->addCameraSceneNode(cam_base, vector3df(0, 20, -2), vector3df(0, 0, 0), DEFAULT_ID);
	cam->setTarget(core::vector3df(0,0,0));
	cam->setFarValue(42000.0f);
	cam->setNearValue(0.0625f);

	vector3df rotatedCamMove;

	vector3df camPos = cam->getPosition();
	vector3df camTarget = cam->getTarget();
	vector3df tempVec; // Used for miscellaneous things, just as a temporary vec3df storage

/* Map */
	FILE *mapfile;
	mapfile = fopen("data/maps/test.map", "rb");
	if (mapfile == NULL) {
		bork("Could not open test map");
	}
	map = new Map;
	map->load(mapfile);
	fclose(mapfile);

/* Set up lighting */

	smgr->setAmbientLight(SColor(0x404040));
	scene::ILightSceneNode *light = smgr->addLightSceneNode(0, vector3df(0,30,0), SColor(0xffffff), 160.0f, DEFAULT_ID);
	scene::ILightSceneNode *light2 = smgr->addLightSceneNode(0, vector3df(0,30,0), SColor(0xffffff), 160.0f, DEFAULT_ID);

/* Set up skybox */

	const io::path skyboxFilename ("data/textures/skybox/top.png");
	video::ITexture *sb_tex = driver->getTexture(skyboxFilename);
	smgr->addSkyBoxSceneNode(sb_tex, sb_tex, sb_tex, sb_tex, sb_tex, sb_tex, 0, DEFAULT_ID);

/* T-Minus ten! */
	ITimer* timer = device->getTimer();
	timer->setTime(0);
	unsigned int now = 0;
	unsigned int lastUpdate = 0;
	int frame = 0;
	vector3df mousething;

	core::line3df ray;
	core::triangle3df dummyTri;

	int skips = 0;
#ifdef DETAILED_PERFORMANCE
	float average_skips = -1;
	int max_skips = 0;
#endif
	int slowness_count = 0;
	Entity randomEntity(vector2df(1, 1));
/* We have liftoff! */
	while (device->run()) {
		now = timer->getTime();
		if (now >= lastUpdate + 1000.0/MAX_FPS) {
			// Performance data collection
#ifdef DETAILED_PERFORMANCE
			average_skips = (average_skips*frame + skips) / (frame+1);
			if (skips > max_skips) max_skips = skips;
#endif
			if (skips == 0) slowness_count++;
//.........这里部分代码省略.........
开发者ID:lheckemann,项目名称:licht-raiders,代码行数:101,代码来源:main.cpp


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