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


C++ Timing::getTime方法代码示例

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


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

示例1: UpdateUserThread

void User::UpdateUserThread()
{
	
	LARGE_INTEGER grabCpuTicks;
	unsigned long long timeInterval = (unsigned long long)(USERUPDATE*1000000000.0f);
	
	LARGE_INTEGER cyclePerSecond;
	LARGE_INTEGER PreviousNanoSeconds;

	QueryPerformanceFrequency( &cyclePerSecond);

	QueryPerformanceCounter(&grabCpuTicks);
	PreviousNanoSeconds.QuadPart = grabCpuTicks.QuadPart;

	Timing loopTimer;
	loopTimer.setTime();

	int loopCount = ceil((1.0f/((float)USERUPDATE))*FRAMETIME);
	float timeCollector = 0.0f;
	int totalLoopCounter = 0;

	
	Timing globalTimer;
	globalTimer.setTime();

	while(!killThread)
	{
		
		for(int i = 0; i < loopCount; i++)
		{
			//Keyboard user input updates
			bool *keys = Input::GetKeys();
			bool *mouse = Input::GetClicks();
			Vector3D drawPos;
			Vector3D temp = GetAngPos();
	
			if(!mouse[0] && fire)
			{
				fire = !fire;
				fireTime->setTime();

				tempProjectileLoadHolder = new Object(*(this->sphere));
				//tempProjectileLoadHolder = new Object(*(this->rectangle));
			
			}
			else if(mouse[0] && !fire)
			{
				Vector3D pos(player->GetLinPos().getx(), player->GetLinPos().gety() - 3.0f*USERHEIGHT/4.0f, player->GetLinPos().getz());
				Vector3D angle = player->GetAngPos();
				//Vector3D pos((player->GetLinPos().getx() - 20.0f)*sin(angle.gety()*PI/180), player->GetLinPos().gety() + 20.0f, (player->GetLinPos().getz() - 20.0f)*cos(angle.gety()*PI/180));

				fireStrength = fireTime->getTime()*800.0f;
				/*if(fireStrength > MAXSPEED)
				{
					fireStrength = MAXSPEED;
				}*/
				if(tempProjectileLoadHolder != NULL)
				{
					//tempProjectileLoadHolder->SetTrajectory(pos,GetAngPos(),0.0f);
					tempProjectileLoadHolder->SetTrajectory(pos,GetAngPos(),fireStrength);
					tempProjectileLoadHolder->SetPartitionSector(player->GetObjects()[0]->GetPartitionSector());
					worldList->insertWOPartCheckPending(tempProjectileLoadHolder);
				}
				
				fire = !fire;
			}

			Vector3D currVel = player->GetLinVel();

			if(keys[DIK_W] || keys[DIK_S] || keys[DIK_D] || keys[DIK_A])
			{
				player->SetFrictionApplied(false);
				player->SetState(true);

				//Linear velocity controls 
				//Forward
				if((keys[DIK_W] && !keys[DIK_D] && !keys[DIK_S] && !keys[DIK_A])) 
				{
					Vector3D force(sin(degtorad*temp.gety()), 0.0f, -cos(degtorad*temp.gety()));
					if(keys[DIK_LSHIFT])
					{
						force = force*MAXPLAYERSPEED/2;
					}
					else
					{
						force = force*MAXPLAYERSPEED/4;
					}

					force.sety(currVel.gety());
					player->SetLinVel(force);
				}
				else if((keys[DIK_W] && keys[DIK_D] && !keys[DIK_S] && !keys[DIK_A])) 
				{
					Vector3D force(sin(degtorad*(temp.gety() + 45.0f)), 0.0f, -cos(degtorad*(temp.gety() + 45.0f)));
					
					if(keys[DIK_LSHIFT])
					{
						force = force*MAXPLAYERSPEED/2;
					}
					else
//.........这里部分代码省略.........
开发者ID:octopusprime314,项目名称:PhysicsEngineBuild,代码行数:101,代码来源:User.cpp


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