Advertisement
Trollkemada

Untitled

Jul 19th, 2011
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. char leerTecla(char &tecla,int retardo)
  2. {
  3.      int ms=0;
  4.      clock_t t1,t2;
  5.      while (ms<retardo)
  6.      {
  7.          cout<<endl<<ms;
  8.          t1=time(NULL);
  9.          if (kbhit())
  10.          {
  11.                switch(getch())
  12.                {
  13.                     case 'W':
  14.                     case 'w':
  15.                          tecla='w';
  16.                          break;
  17.                     case 'S':
  18.                     case 's':
  19.                           tecla='s';
  20.                           break;
  21.                     case 'D':
  22.                     case 'd':
  23.                          tecla='d';
  24.                          break;
  25.                     case 'A':
  26.                     case 'a':
  27.                          tecla='a';
  28.                          break;
  29.                }
  30.          t2=time(NULL);
  31.          ms=ms+1000* (t2-t1)/CLOCKS_PER_SEC;
  32.          
  33.          }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement