这篇教程C++ GetTicks函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetTicks函数的典型用法代码示例。如果您正苦于以下问题:C++ GetTicks函数的具体用法?C++ GetTicks怎么用?C++ GetTicks使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetTicks函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ScheduleEvent// This must be run ONLY from within the CPU thread// cyclesIntoFuture may be VERY inaccurate if called from anything else// than Advancevoid ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata){ _assert_msg_(POWERPC, Core::IsCPUThread() || Core::GetState() == Core::CORE_PAUSE, "ScheduleEvent from wrong thread"); Event *ne = GetNewEvent(); ne->userdata = userdata; ne->type = event_type; ne->time = GetTicks() + cyclesIntoFuture; // If this event needs to be scheduled before the next advance(), force one early if (!globalTimerIsSane) ForceExceptionCheck(cyclesIntoFuture); AddEventToQueue(ne);}
开发者ID:Abrahamh08,项目名称:dolphin,代码行数:20,
示例2: GetTicksvoid LetterDisplayAnimation::Animate(){ unsigned int elapsed = GetTicks() - mStartTime; float t = elapsed/(float)mDuration; if(t > 1.0f) { GameMessage msg; msg.mEventName = "FINISHED"; msg.mSender = mID; SendOutMessage(msg); return; } IvVector3 pos = Lerp(t, mStartPos, mEndPos); //Add noise to movement IvVector3 normDir = mEndPos - mStartPos; normDir.z = 0; normDir.Normalize(); float x = normDir.x; float y = normDir.y; normDir.x = -y; normDir.y = x; float noise = Perlin::Noise(pos.x*0.01f,pos.y*0.01f); //ramp noise based on proximity to endpoints float s = 1.0f; if(t <= 0.1f) s = Perlin::lerp(t*10.0f,0.0f,1.0f); else if( t >= 0.9f) s = Perlin::lerp((t-0.9f)*10.0f,1.0f,0.0f); normDir *= noise*5.0f * s; pos += normDir; IvVector3 intPos; intPos.x = (int)pos.x; intPos.y = (int)pos.y; intPos.z = mStartPos.z; SetPosition(intPos); IvVector3 vel(0,201,0); mMetaballGrid->ObjectMoved(mID, intPos,vel); }
开发者ID:kristofe,项目名称:GameEngine,代码行数:45,
示例3: assertbool CPositionHandler::HandleMovement(uint8 x, uint8 y, uint8 *pPath, uint32 map){ std::vector<uint8> nodes; uint32 count = pPath[0] & 0x0f; for(int32 i = 1; i < 8; ++i) /* calculating roadpath nodes */ { if(nodes.size() < count) { nodes.push_back((pPath[i] & 0xf0) / 0x10); } if(nodes.size() < count) { nodes.push_back(pPath[i] & 0x0f); } } assert(nodes.size() == count); std::vector<CPositionHandler::MovePoint> new_path; new_path.reserve(count + 1); /* reserve space immediately, it must be faster i think */ MovePoint origin; origin.x = x; origin.y = y; origin.time = GetTicks(); new_path.push_back(origin); uint8 tx = x; uint8 ty = y; for(uint32 i = 0; i < nodes.size(); ++i) /* building path from client data and checking it for walkability */ { tx += RoadX[nodes.at(i)]; ty += RoadY[nodes.at(i)]; if(!WorldMap[map].FreeToMove(tx, ty)) { return false; } MovePoint pt; pt.time = origin.time + 300 * (i + 1); /* time is constant (reversed speed), need calculate it later */ pt.x = tx; pt.y = ty; new_path.push_back(pt); } this->mtx.lock(); /* applying new path, also storing backup of previous */ this->cache = this->path; this->path = new_path; this->mtx.unlock(); return true;}
开发者ID:Goresome,项目名称:orange,代码行数:45,
示例4: GetTicksconst CPositionHandler::MovePoint CPositionHandler::GetPosition(){ uint32 current_time = GetTicks(); CPositionHandler::MovePoint pt; this->mtx.lock(); for(uint32 i = 0; i < this->path.size(); ++i) { if(this->path.at(i).time > current_time) { pt = this->path.at(i - 1); this->mtx.unlock(); return pt; } } pt = this->path.at(this->path.size() - 1); this->mtx.unlock(); return pt;}
开发者ID:Goresome,项目名称:orange,代码行数:18,
示例5: init_genrandGUID_HIGH CObjectManager::CreateGuid(){ init_genrand(GetTicks()); GUID_HIGH guid = 0; uint32 count = 0; while(count < RETRIES) { count++; guid = GUID_HIGH(genrand_int32()); MapType::iterator it = this->container.find(guid); if(it == this->container.end()) { break; } } assert(count != RETRIES); return guid;}
开发者ID:Goresome,项目名称:orange,代码行数:18,
示例6: SEND_W3GS_STOP_LAGBYTEARRAY CGameProtocol :: SEND_W3GS_STOP_LAG( CGamePlayer *player, bool loadInGame ){ BYTEARRAY packet; packet.push_back( W3GS_HEADER_CONSTANT ); // W3GS header constant packet.push_back( W3GS_STOP_LAG ); // W3GS_STOP_LAG packet.push_back( 0 ); // packet length will be assigned later packet.push_back( 0 ); // packet length will be assigned later packet.push_back( player->GetPID( ) ); if( loadInGame ) UTIL_AppendByteArray( packet, (uint32_t)0, false ); else UTIL_AppendByteArray( packet, GetTicks( ) - player->GetStartedLaggingTicks( ), false ); AssignLength( packet ); // DEBUG_Print( "SENT W3GS_STOP_LAG" ); // DEBUG_Print( packet ); return packet;}
开发者ID:brunobnb,项目名称:ghostcb,代码行数:19,
示例7: CGamePlayerCGamePlayer :: CGamePlayer( CGameProtocol *nProtocol, CBaseGame *nGame, CTCPSocket *nSocket, unsigned char nPID, string nJoinedRealm, string nName, BYTEARRAY nInternalIP, bool nReserved ) : CPotentialPlayer( nProtocol, nGame, nSocket ){ m_PID = nPID; m_Name = nName; m_InternalIP = nInternalIP; m_JoinedRealm = nJoinedRealm; m_TotalPacketsSent = 0; m_TotalPacketsReceived = 0; m_LeftCode = PLAYERLEAVE_LOBBY; m_LoginAttempts = 0; m_SyncCounter = 0; m_JoinTime = GetTime( ); m_LastMapPartSent = 0; m_LastMapPartAcked = 0; m_StartedDownloadingTicks = 0; m_FinishedDownloadingTime = 0; m_FinishedLoadingTicks = 0; m_StartedLaggingTicks = 0; m_StatsSentTime = 0; m_StatsDotASentTime = 0; m_LastGProxyWaitNoticeSentTime = 0; m_Score = -100000.0; m_LoggedIn = false; m_Spoofed = false; m_Reserved = nReserved; m_WhoisShouldBeSent = false; m_WhoisSent = false; m_DownloadAllowed = false; m_DownloadStarted = false; m_DownloadFinished = false; m_FinishedLoading = false; m_Lagging = false; m_DropVote = false; m_KickVote = false; m_Muted = false; m_LeftMessageSent = false; m_GProxy = false; m_GProxyDisconnectNoticeSent = false; m_GProxyReconnectKey = GetTicks( ); m_LastGProxyAckTime = 0; m_PlayerId = 0; m_LeftTime = 0;}
开发者ID:PLEASE-EXCUSE-MY-DOPE-ASS-SWAG,项目名称:GHost,代码行数:43,
示例8: GetTicksvoid HangingLetterSign::AnimateWind(){ unsigned int time = GetTicks(); unsigned int elapsed = time - mStartTime; IvVector3 pos; this->GetLocalPosition(pos); float t = elapsed/(float)mWindDuration; if(t > 1.0f) { //this->ResetLocalTransform();//Start with identity //this->Translate(pos); IdleAnimate(); return; /*GameMessage msg; msg.mEventName = "FINISHED"; msg.mSender = mID; SendOutMessage(msg); return;*/ } float noise = 0.2f* Perlin::Noise(time*0.001f,pos.x*0.01f); float hiFreqNoise = Perlin::Noise(time*0.007f,pos.x*0.01f); //ramp noise based on proximity to start and end animation //have to start with 1.0f times noise because that is what was driving the position and motion of the sign before //this animation... if you didn't start with the regular noise value then you would get a hitch in position. float s = 2.0f; if(t <= 0.25f) s = LERP(t*4.0f,1.0f,2.0f); else if( t >= 0.75f) s = LERP((t-0.75f)*4.0f,2.0f,1.0f); mLastUpdateTime = time; this->ResetLocalTransform();//Start with identity this->Translate(pos); float negNoise = -(0.5f*noise + 0.5f); this->Rotate(s*noise*0.3,s*hiFreqNoise*0.5f,s*negNoise*0.5); }
开发者ID:kristofe,项目名称:GameEngine,代码行数:42,
示例9: ScheduleEventvoid ScheduleEvent(s64 cycles_into_future, EventType* event_type, u64 userdata, FromThread from){ ASSERT_MSG(POWERPC, event_type, "Event type is nullptr, will crash now."); bool from_cpu_thread; if (from == FromThread::ANY) { from_cpu_thread = Core::IsCPUThread(); } else { from_cpu_thread = from == FromThread::CPU; ASSERT_MSG(POWERPC, from_cpu_thread == Core::IsCPUThread(), "A /"%s/" event was scheduled from the wrong thread (%s)", event_type->name->c_str(), from_cpu_thread ? "CPU" : "non-CPU"); } if (from_cpu_thread) { s64 timeout = GetTicks() + cycles_into_future; // If this event needs to be scheduled before the next advance(), force one early if (!s_is_global_timer_sane) ForceExceptionCheck(cycles_into_future); s_event_queue.emplace_back(Event{timeout, s_event_fifo_id++, userdata, event_type}); std::push_heap(s_event_queue.begin(), s_event_queue.end(), std::greater<Event>()); } else { if (Core::WantsDeterminism()) { ERROR_LOG(POWERPC, "Someone scheduled an off-thread /"%s/" event while netplay or " "movie play/record was active. This is likely to cause a desync.", event_type->name->c_str()); } std::lock_guard<std::mutex> lk(s_ts_write_lock); s_ts_queue.Push(Event{g.global_timer + cycles_into_future, 0, userdata, event_type}); }}
开发者ID:AdmiralCurtiss,项目名称:dolphin,代码行数:42,
示例10: GetTicksvoid ScreenFader::Update(){ if(!mActive) return; unsigned int elapsed = GetTicks() - mStartTime; float t = elapsed/(float)mDuration; mCurrentColor = Lerp(t,mStartColor,mEndColor); SetColor(mCurrentColor); if(elapsed >= mDuration) { GameMessage msg; msg.mEventName = "FINISHED"; msg.mSender = mID; SendOutMessage(msg); }}
开发者ID:kristofe,项目名称:GameEngine,代码行数:20,
示例11: QueryPerformanceFrequency// Constructor// begin of a profile sectionVSProfileLib::VSProfileLib(std::string name, bool profileGL) { int found; pTime w; sCurrLevel++;#if VSPL_CLOCK == VSPL_WIN_HIGH_PERFORMANCE_COUNTER QueryPerformanceFrequency(&sFreq);#endif GetTicks(&w); // create new level if (sCurrLevel == sTotalLevels) { sLevels[sCurrLevel].cursor = -1; createNewSection(name, w, profileGL); // store the size of the largest section name int aux = name.size() ; if (aux > sDisp) sDisp = aux; sTotalLevels++; } else { // search for name and parent found = searchSection(name); if (found != -1) updateSection(found, w); else { // create new section inside current level createNewSection(name, w, profileGL); // store the size of the largest section name // for report formatting purposes int aux = name.size() ; if (aux > sDisp) sDisp = aux; } }}
开发者ID:v3c70r,项目名称:sph-fluids,代码行数:42,
示例12: QueryPerformanceCounterinline void Platform::update_time(){ /* u64 t; QueryPerformanceCounter((LARGE_INTEGER *) &t); f32 newTime = (f32) (((f64) t) / timer_freq); */ f32 f; i32 t; double ticks; ticks = GetTicks(); t = ticks; //printf("update ticks %f, %d/n",ticks, t); f = ((f32) t) * 0.001f; // deviceState.timeStep = f - deviceState.time;// deviceState.time = f; deviceState.timeStep = ticks - deviceState.time; deviceState.time = ticks;}
开发者ID:aronsoderling,项目名称:high-perfomance-cg,代码行数:23,
示例13: GetWorldPositionvoid HangingLetterSign::SetChar(char c){ mUseWindAnimation = false; IvVector3 pos; GetWorldPosition(pos); pos.x = (int) pos.x; pos.y = (int) pos.y; this->SetWorldPosition(pos); //LetterDisplay::SetChar(c); if(mLetterDisplay == NULL) { mLetterDisplay = new LetterDisplay(mFont); IvVector3 disp; //GetWorldPosition(disp); disp.z += 2.55f; disp.y -= 27; mLetterDisplay->Translate(disp); //Hack! for letter "i" it is too sharp and thin if(c == 'I') { IvVector3 s(1.25f,1.0f,1.0f); mLetterDisplay->Scale(s); } this->AddChild(mLetterDisplay); } mPendingChar = c; mStartTime = GetTicks(); int randTime = (rand()/(float)RAND_MAX)*1000; mStartTime += randTime; //mLetterDisplay->SetChar(c); }
开发者ID:kristofe,项目名称:GameEngine,代码行数:37,
示例14: GetTimequint32 GetTime(){ return GetTicks( ) / 1000;}
开发者ID:svn2github,项目名称:ghostplusplus,代码行数:4,
示例15: Draw_skill_iconsstatic void Draw_skill_icons (SDL_Surface *screen, struct character *player) { SDL_Rect rect= {350 * scale, (top ? 0 : (practise ? ky - (double)kx/1920 * 150 : ky - (double)kx/1920 * 90)) , skill_icons[0][0]->w, skill_icons[0][0]->h }; if(!top && kyBottom > rect.y - 10*scale) kyBottom = rect.y - 10*scale; int i,j; for(j=0; j < (practise ? 2 : 1); j++) { for(i=0; i<skill_num; i++) { if(j == 0) BlitSurface(skill_bg, NULL, screen, &rect); BlitSurface(skill_icons[j][i], NULL, screen, &rect); // A Cooldownok kirajzolása if(j == 0) { int time = GetTicks(); int percent = 0; bool available = false; bool current = false; switch (i) { case skill_a_melee: if(player->act == a_walk) available = true; if(player->act == a_melee) current = true; if(player->melee.a_cd > time) percent = ((player->melee.a_cd - time) * 100) / player->a_melee_cd; break; case skill_s_melee: if(player->act == a_walk || player->act == jump || player->act == air) available = true; if(player->act == s_melee) current = true; if(player->melee.s_cd > time) percent = ((player->melee.s_cd - time) * 100) / player->s_melee_cd; break; case skill_s_walk: if( (player->act == a_walk || player->act == jump) && player->jump.second == false) available = true; if(player->act == s_walk) current = true; if(player->walk.cd > time) percent = ((player->walk.cd - time) * 100) / player->s_walk_cd; break; case skill_def: if(player->act == a_walk || player->act == a_melee) available = true; if(player->act == def) current = true; if(player->def.cd > time) percent = ((player->def.cd - time) * 100) / player->def_cd; break; case skill_jump_attack1: if(player->act == jump && player->jump.second == false) available = true; if(player->act == jump_attack) current = true; if(player->jump.cd1 > time) percent = ((player->jump.cd1 - time) * 100) / player->jump_attack_cd; break; case skill_jump_attack2: if(player->act == jump && player->jump.second == false) available = true; if(player->act == jump_attack2) current = true; if(player->jump.cd2 > time) percent = ((player->jump.cd2 - time) * 100) / player->jump_attack_cd; break; case skill_counter: if(player->act == a_walk || player->act == hit || player->act == a_melee || player->act == ground) available = true; if(player->act == counter) current = true; if(player->counter.cd > time) percent = ((player->counter.cd - time) * 100) / player->counter_cd; break; case skill_a_ranged: if(player->act == a_walk) available = true; if(player->act == a_ranged) current = true; if(player->ranged.a_cd > time) percent = ((player->ranged.a_cd - time) * 100) / player->a_cast_cd; break; case skill_s_ranged: if(player->act == a_walk) available = true; if(player->act == s_ranged) current = true; if(player->ranged.s_cd > time) percent = ((player->ranged.s_cd - time) * 100) / player->s_cast_cd; break; default: break; } if(!available && !current) boxRGBA(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, 0, 0, 0, 125); if(percent != 0 && !current) { // A hátralév C++ GetTile函数代码示例 C++ GetTickCount64函数代码示例
|