本文整理汇总了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
//.........这里部分代码省略.........