void Game::UpdateMoves() { // decrement moves moves--; // update moves label stringstream stream; stream << "Moves: " << moves; movesLabel->setString(stream.str().c_str()); movesLabel->setPositionX(Director::getInstance()->getVisibleSize().width - movesLabel->getContentSize().width/2 - Letter::PADDING); // check for game over GameOverCheck(); }
void MainLoop() { //QueryPerformanceFrequency(&nFreq); //QueryPerformanceCounter(&nBefore); DWORD StartTime,EndTime,PassTime; double l_StartTime,l_EndTime,l_PassTime; #ifdef _WIN32 StartTime=timeGetTime(); #else l_StartTime=gettimeofday_sec(); #endif ARUint8 *image; ARMarkerInfo *marker_info; int marker_num; int j,k; if( (image = (ARUint8*)arVideoGetImage() )==NULL){ arUtilSleep(2); return; } argDrawMode2D(); argDispImage(image, 0, 0); if(arDetectMarker(image, thresh, &marker_info, &marker_num) < 0){ CleanUp(); exit(0); } arVideoCapNext(); k=-1; for(j=0;j<marker_num;j++){ if(patt_id==marker_info[j].id){ k = (k==-1) ? j : k; k = (marker_info[k].cf < marker_info[j].cf) ? j: k; } } if(k!=-1) { if(isFirst==true) nyar_NyARTransMat_O2_transMat(nyobj,&marker_info[k],patt_center,patt_width,patt_trans); else nyar_NyARTransMat_O2_transMatCont(nyobj,&marker_info[k],patt_trans,patt_center,patt_width,patt_trans); isFirst=false; if(GameOver==false){ if(arUtilTimer()>1.0){ MovePiece(3,f,p); score+=f.ShiftPiece(f.deletePiece()); arUtilTimerReset(); GameOver=GameOverCheck(f,p); } } else{ if(arUtilTimer()>15.0) InitGame(); } DrawObject(); } argSwapBuffers(); #ifdef _WIN32 EndTime=timeGetTime(); PassTime=EndTime-StartTime; (1000/FPS>PassTime)?Wait(1000/FPS-PassTime):Wait(0); FPSCount(&fps); printf("FPS=%d\n",fps); #else l_EndTime=gettimeofday_sec(); l_PassTime=l_EndTime-l_StartTime; ((double)(1000/FPS)>l_PassTime)?Wait((double)1000/FPS-l_PassTime):Wait(0); FPSCount(&fps); printf("FPS=%d\n",fps); #endif }