Пример #1
0
int FileRet(int sock, uint64_t *elapsed)
{
  int res;
  sendFile(TEMPFILE, sock);
  getTimeElapsed();

  res=receiveFile(TEMPFILE, sock);
  *elapsed = getTimeElapsed();
  cout<<"Time elapsed:  "<< *elapsed << "\t res: " << res <<endl;

  return res;
}
Пример #2
0
Файл: sprite.c Проект: wKLV/puun
void updateNrender(){
    float a, b;
    float time;
    u32 ms;
    getTimeElapsed(&ms);
    time = ms / 1000.f;
    getMousePosition(&a, &b);
    paddleX = s2p(a);
    paddleRot = s2p(b);
    static float rotate = 0;
    static float vx = 0, vy = -1, px = 0, py = 0, av =0;
    static char hasBounced = 0;

    rotate += av*time;
    px += time*vx, py += time*vy;
    square_rotateTo(ball, rotate);
    square_traslateTo(ball, px, py);

    square_traslateTo(paddle, paddleX, paddleY);
    square_rotateTo(paddle, paddleRot);

    squareList_update_pos(Sprites.squareList, buffer);

    //CHECK COLLISION :)
    if(hasBounced!= 1 && px <-1){ bounce(TAU/4, &vx, &vy, &av, 1.);hasBounced = 1; }
    if(hasBounced!=2 && px> 1){ bounce(-TAU/4, &vx, &vy, &av, 1.);hasBounced = 2;}
    if(hasBounced!=3 && py >1){ bounce(-TAU/2, &vx, &vy, &av, 1.); hasBounced = 3; }
    if(py <-1){
        game_die();
    }
    if(hasBounced!=4 && px<= paddleX+0.4 && px>=paddleX-0.4  && py<=paddleY+0.05 && py>=paddleY-0.05) {
        bounce(3/4*TAU-paddleRot, &vx, &vy, &av, 1.2);
        hasBounced = 4;
        score++;
    }
    puun_MouseClick click;
    getMouseClick(&click);
    puun_KEY key;
    getKeyboardKey(&key);
    if(click)
        printf("MOUSE CLICKED\n");
    if(key.isPressed) printf("%c\n", key.key);




    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    renderSpriteList(Sprites);
    //uniImg.id = ballId;
    //uniImg.texnum = 0;
    //render_squareList(Squares, (Data)&uniImg, 1);


    puun_SWAP_BUFFERS();
    //SDL_GL_SwapBuffers();
}
Пример #3
0
  void Stopwatch::Print (std::ostream &out) const
  {
    long time = getTimeElapsed ();
    long h = time/3600000000L;
    long m = time/60000000L - h*60;
    float s = ((float)time/1000000L) - m*60 - h*3600;

    if (h > 0) out << h << "h";
    if (m > 0) out << m << "m";
    out << s << "s";
  }  
Пример #4
0
bool ApplicationManager::step()
{
   float timeElapsed = getTimeElapsed();
   m_globalTimeController->update(timeElapsed);

   switch(onStep())
   {
   case APC_SYSTEM:      return true;
   case APC_APPLICATION: break;
   case APC_EXIT:        return false;
   }

   int numRunning = 0;
   int numActive = 0;

   for (AppsMap::iterator appIt = m_apps.begin(); 
        appIt != m_apps.end(); ++appIt)
   {
      ApplicationNode& currNode = appIt->second;
      dispatchAppSignals(currNode);

      switch(currNode.state)
      {
      case AS_UNINITIALIZED:
         {
            // do nothing
            break;
         }

      case AS_BEING_HIBERNATED:
         {
            currNode.app.hibernate();
            currNode.state = AS_HIBERNATED;
            break;
         }

      case AS_HIBERNATED:
         {
            break;
         }

      case AS_BEING_DEHIBERNATED:
         {
            currNode.app.dehibernate();
            currNode.state = AS_RUNNING;
            break;
         }

      case AS_SCHEDULED:
         {
            currNode.app.initialize();
            currNode.state = AS_RUNNING;
            break;
         }

      case AS_RUNNING:
         {
            currNode.app.update(timeElapsed);
            break;
         }

      case AS_FINISHED:
         {
            currNode.app.deinitialize();
            currNode.state = AS_UNINITIALIZED;
            break;
         }
      }

      if (currNode.state == AS_RUNNING) { numRunning++; }     
      if (currNode.state != AS_UNINITIALIZED) { numActive++; }    
      if (numRunning > 1)
      {
         ASSERT_MSG( false, "Only one application can be running at a time");
      }
   }

   return (numActive > 0);
}
Пример #5
0
PULSE_TIME PulseTimer::stop() {
    return getTimeElapsed();
}
Пример #6
0
bool challengeResponse(int sock, unsigned long l, uint64_t *diffNano)
{
  verifier(l);

  FILE* fp = fopen("ctmp","wb");

	fprintf(fp, "%lu\n", (unsigned long)l);
	for (int i = 0; i<l; i++)
		fprintf(fp, "%lu\n", indices[i]);

  char strCff[1024] = {0};
  for(int i=0; i<l; i++)
  {
   	mpz_get_str(strCff, 62, coeff[i]);
   	fprintf(fp, "%s\n", strCff);
  	bzero(strCff, 1024);
  }
  fclose(fp);

	sendFile("ctmp", sock);
  getTimeElapsed();
    /* Buffers for response generated by server (prover) */
	receiveFile("ctmpr", sock);

	*diffNano = getTimeElapsed();
  cout<<"Time elapsed:  "<< *diffNano <<endl;

  mpz_t servSigma,meu[s];
  fp = fopen("ctmpr","rb");
  for(int i=0; i<s; i++)
  {
  	mpz_init(meu[i]);
   	fgets(strCff, sizeof(strCff), fp);
   	mpz_set_str(meu[i], strCff, 62);
   	bzero(strCff, 1024);
  }

	mpz_init(servSigma);
	fgets(strCff, sizeof(strCff), fp);
	mpz_set_str(servSigma, strCff, 62);
	fclose(fp);

  mpz_t cliSigma;
  mpz_init(cliSigma);

  verify(meu, l, &cliSigma);

  bzero(strCff, 1024);
  mpz_get_str(strCff, 10, cliSigma);
	cout << "Sigma at client: " << strCff<< endl;

	free(indices);

  if(mpz_cmp(cliSigma, servSigma)==0)
  {
    cout<<"@@@@@@@@@@@ Data verified........................"<< endl << endl;
    return true;
  }
  else
  {
    cout<<"########### Data lost............................"<< endl << endl;
    return false;
  }
}