home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_C / FGIN131.ZIP / SOURCE.ZIP / KEYDELAY.C < prev    next >
C/C++ Source or Header  |  1994-01-21  |  771b  |  35 lines

  1. #include "\keys\keys.h"
  2. #include <time.h>
  3.  
  4. /****************************************************************************\
  5.  
  6. \****************************************************************************/
  7.  
  8. /****************************************************************************\
  9.  
  10.     int key_delay(int seconds)
  11.  
  12.             This function will wait a specified number of seconds or until
  13.         a key is pressed.  It returns the key pressed, -1 if time expired.
  14.  
  15. \****************************************************************************/
  16. int delay_key(int seconds)
  17. {
  18.  
  19.     clock_t start_time=clock();
  20.     int key;
  21.  
  22.     clear_key();
  23.  
  24.     do {
  25.  
  26.         if ((key=check_key())>=0)     //if key pressed
  27.             break;
  28.  
  29.     }while(clock()<start_time+(seconds*18));
  30.  
  31.     return(key);
  32.  
  33. }
  34.  
  35.