home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / DOORDR50.ZIP / NUMDOOR.PAS < prev    next >
Pascal/Delphi Source File  |  1991-10-10  |  2KB  |  73 lines

  1. { EXAMPLE DOOR: Number Guess                                              }
  2. {               By Scott Baker                                            }
  3. {                                                                         }
  4. { This is a simple number guessing game.                                  }
  5.  
  6. program numdoor;
  7.  
  8. uses doordriv;
  9.  
  10. procedure DoTheTitle;
  11. begin;
  12.  sclrscr;
  13.  swriteln('Hello, '+user_first_name+
  14.           ' '+user_last_name+
  15.           '. Welcome to NumDoor!');
  16.  swriteln('');
  17. end;
  18.  
  19. procedure playgame;
  20. var
  21.  thenum: word;
  22.  playerguess: word;
  23.  guessnum: byte;
  24.  done: boolean;
  25.  tempstr: string;
  26. begin;
  27.  swriteln('I''m thinking of a number.'+
  28.           ' Can you guess what it is?');
  29.  swriteln('');
  30.  guessnum:=0;
  31.  randomize;
  32.  thenum:=random(100)+1;
  33.  done:=false;
  34.  while not done do begin;
  35.   inc(guessnum);
  36.   swrite('Guess #');
  37.   str(guessnum,tempstr);
  38.   swrite(tempstr);
  39.   swrite(': ');
  40.   sread_num_word(playerguess);
  41.   if playerguess>thenum then swriteln('Lower!') else
  42.     if playerguess<thenum then swriteln('Higher!') else
  43.     if playerguess=thenum then begin;
  44.      swriteln('Correct!');
  45.      done:=true;
  46.     end;
  47.   if guessnum=10 then done:=true;
  48.  end; {while}
  49.  if thenum<>playerguess then begin;
  50.   swriteln('You Lost!');
  51.   str(thenum,tempstr);
  52.   swriteln('The number was '+tempstr+'.');
  53.  end;
  54. end;
  55.  
  56. procedure waitforkey;
  57. var
  58.  ch: char;
  59. begin;
  60.  swriteln('');
  61.  swriteln('Press any key to continue.');
  62.  sread_char(ch);
  63. end;
  64.  
  65. begin;
  66.  initdoordriver('DOORDRIV.CTL');
  67.  dothetitle;
  68.  playgame;
  69.  waitforkey;
  70. end.
  71.  
  72.  
  73.