home *** CD-ROM | disk | FTP | other *** search
/ The CIA World Factbook 1992 / k3bimage.iso / sel / 04 / 0009 / precog.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-12-02  |  2.1 KB  |  66 lines

  1. /* precog.c -- precognition function for Targ-Hurt ESP Trainer
  2.  
  3.    History: rhs 18-mar-87
  4. */
  5.  
  6. #include "mancon.h"
  7. #include "declares.h"
  8.  
  9. void mode_precognition()
  10. {  int keypress, machine_sel, dummy;
  11.    static int delay=10;
  12.  
  13.    disp_cls();
  14.    disp_top("Precognition");
  15.    disp_pbot();
  16.    srand( (unsigned)readclock(&dummy) ); /* Randomize first random number */
  17.                                          /* readclock is a function which
  18.                                             reads the system clock.  In this
  19.                                             application, its output is 
  20.                                             suitable for seeding a random
  21.                                             number generator because it
  22.                                             seldom returns the same value. */
  23.    disp_cursor(OFF);                     /* Make cursor invisible. */
  24.    keypress = START;
  25.    while(keypress != QUIT)
  26.    {
  27.       keypress = pf_getcode();         /* Get user input, then wait. */
  28.       if(keypress==NORTH || keypress==SOUTH || keypress==EAST
  29.          || keypress==WEST || keypress==PASS)
  30.       {  
  31.          pf_waitmsg(ON, (keypress==PASS) ? "     Pass Noted" :
  32.                                            "   Selection Noted");        
  33.          wait(delay/2);
  34.          pf_waitmsg(OFF,"");
  35.          wait(delay/2);
  36.  
  37.          machine_sel = rand()%4;       /* Get random number from 0 to 3 */
  38.       }
  39.  
  40.       switch(keypress)
  41.       {  case PASS:  thud();
  42.                      pf_newdirec(machine_sel);
  43.                      pf_display();
  44.                      break;
  45.          case QUIT:  pf_resetscore();
  46.                      disp_cls();   /* Clear the screen. */
  47.                      disp_cursor(ON);
  48.                      break;
  49.          case RESET: pf_resetscore();
  50.                      pf_display();
  51.                      break;
  52.          case CHANGE:pf_change_delay(&delay);
  53.                      break;
  54.          default:    thud();
  55.                      pf_newscore(keypress, machine_sel);
  56.                      pf_display();
  57.                      break;
  58.       }
  59.    }
  60. } /* end mode_precognition() */
  61.  
  62.  
  63.  
  64.  
  65.  
  66.