Advertisement
WadeRollins2710

[Game] Hang Man

Mar 5th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 9.09 KB | None | 0 0
  1. Program Hang_Man;
  2. Uses crt;
  3. Var
  4.    Word, Answer, Hi: String;
  5.    Wrong, WrongTms, i: Integer;
  6.    Hint: Boolean;
  7. Procedure Pout(S: String; De: Integer; Bool: Boolean);
  8.           Begin
  9.                If Bool=true then
  10.                   Begin
  11.                        Write(S);
  12.                        Delay(De);
  13.                   End;
  14.                If Bool=false then
  15.                   Begin
  16.                        Writeln(S);
  17.                        Delay(De);
  18.                   End;
  19.           End;
  20. Procedure Intro;
  21.           Begin
  22.                clrscr;
  23.                Pout('What would you do...',2000,true);
  24.                Pout('when a man''s life is dependent on you???',2000,false);
  25.                Pout('Would you do your best?...',2000,false);
  26.                Pout('...Or you just gonna scared and run???',2000,false);
  27.           End;
  28. Procedure Title;
  29.           Begin
  30.                clrscr; TextColor(White); Gotoxy(36,1);
  31.                Write('H'); Delay(1000);
  32.                Write('A'); Delay(1000);
  33.                Write('N'); Delay(1000);
  34.                Write('G '); Delay(1000);
  35.                Write('M'); Delay(1000);
  36.                Write('A'); Delay(1000);
  37.                Write('N'); Delay(1000);
  38.                clrscr;
  39.                Gotoxy(35,1); TextColor(150);
  40.                Write('Press Enter!');
  41.                Readln;
  42.                TextColor(White);
  43.           End;
  44. Function Up(m: String): String;
  45.          Var
  46.             i: Integer;
  47.          Begin
  48.               For i:=1 to length(m) do
  49.                   m[i]:=Upcase(m[i]);
  50.               Up:=m;
  51.          End;
  52. Procedure Loading_Screen;
  53.           Var
  54.              i: Integer;
  55.           Begin
  56.                clrscr;
  57.                For i:=1 to Random(2)+1 do
  58.                    Begin
  59.                         clrscr;
  60.                         Gotoxy(33,1);
  61.                         Write('Loading'); Delay(500);
  62.                         clrscr;
  63.                         Gotoxy(33,1);
  64.                         Write('Loading.'); Delay(500);
  65.                         clrscr;
  66.                         Gotoxy(33,1);
  67.                         Write('Loading..'); Delay(500);
  68.                         clrscr;
  69.                         Gotoxy(33,1);
  70.                         Write('Loading...'); Delay(500);
  71.                    End;
  72.           End;
  73. Procedure Draw1;
  74.         Var i: Integer;
  75.         Begin
  76.                 Gotoxy(3,20);
  77.                 Write('******************');
  78.                 Gotoxy(1,5);
  79.                 For i:=1 to 15 do
  80.                         Writeln('     *     ');
  81.         End;
  82. Procedure Draw2;
  83.         Var i: Integer;
  84.         Begin
  85.                 Gotoxy(4,5);
  86.                 Write('**********************');
  87.                 Gotoxy(24,6); Write('*');
  88.                 Gotoxy(22,7); Write(' ***');
  89.                 Gotoxy(22,8); Write('*   *');
  90.                 Gotoxy(22,9); Write('*   *');
  91.                 Gotoxy(22,10); Write('*   *');
  92.                 Gotoxy(23,11);Write('***');
  93.  
  94.  
  95.         End;
  96. Procedure Draw3;
  97.         Var
  98.                 i, x: Integer;
  99.         Begin
  100.                 x:=24;
  101.                 For i:=12 to 15 do
  102.                         Begin
  103.                                 Gotoxy(24,i); Write('*');
  104.                         End;
  105.         End;
  106. Procedure Draw4;
  107.         Var
  108.                 x, y ,z: Integer;
  109.         Begin
  110.                 x:=12;
  111.                 y:=25;
  112.                 For z:=1 to 3 do
  113.                         Begin
  114.                                 Gotoxy(y,x); Write('*');
  115.                                 inc(x); inc(y);
  116.                         End;
  117.         End;
  118. Procedure Draw5;
  119.         Var
  120.                 x, y ,z: Integer;
  121.         Begin
  122.                 x:=16;
  123.                 y:=25;
  124.                 For z:=1 to 3 do
  125.                         Begin
  126.                                 Gotoxy(y,x); Write('*');
  127.                                 inc(x); inc(y);
  128.                         End;
  129.         End;
  130. Procedure Draw6;
  131.         Var
  132.                 x, y ,z: Integer;
  133.         Begin
  134.                 x:=12;
  135.                 y:=23;
  136.                 For z:=1 to 3 do
  137.                         Begin
  138.                                 Gotoxy(y,x); Write('*');
  139.                                 inc(x); dec(y);
  140.                         End;
  141.         End;
  142. Procedure Draw7;
  143.         Var
  144.                 x, y ,z: Integer;
  145.         Begin
  146.                 x:=16;
  147.                 y:=23;
  148.                 For z:=1 to 3 do
  149.                         Begin
  150.                                 Gotoxy(y,x); Write('*');
  151.                                 inc(x); dec(y);
  152.                         End;
  153.         End;
  154. Procedure Check;
  155.           Begin
  156.                 Case WrongTms of
  157.                         1: Draw1;
  158.                         2: Draw2;
  159.                         3: Draw3;
  160.                         4: Draw4;
  161.                         5: Draw5;
  162.                         6: Draw6;
  163.                         7: Draw7;
  164.                 End;
  165.           End;
  166. Procedure Play;
  167.           Var
  168.              i, d: Integer;
  169.              Correct: Boolean;
  170.           Begin
  171.                Word:='BJANRE STROUSTRUP';
  172.                clrscr; Delay(2000); WrongTms:=0;
  173.                For i:=1 to length(Word) do
  174.                    Begin
  175.                         If Word[i]<>' ' then
  176.                            Write('_')
  177.                            else
  178.                                Write(' ');
  179.                    End;
  180.                Writeln;
  181.                Write('Input option: ');
  182.                Readln(Answer);
  183.                While (Up(Answer)<>Word) and (WrongTms<7) do
  184.                      Begin
  185.                           If Up(Answer)='HINT' then
  186.                              Begin
  187.                                   Writeln;
  188.                                   Writeln('A man who is very famous in programming industry');
  189.                                   inc(WrongTms);
  190.                                   Check;
  191.                              End;
  192.                           If Up(Answer)='EXIT' then Halt;
  193.                           If (Up(Answer)<>'HINT') and (Up(Answer)<>'EXIT') then
  194.                              Begin
  195.                                   If length(Up(Answer))=1 then
  196.                                      Begin
  197.                                           d:=0;
  198.                                           For i:=1 to length(Word) do
  199.                                               If Word[i]=Up(Answer) then
  200.                                                  Begin
  201.                                                       Gotoxy(i,1); Write(Word[i]);
  202.                                                       d:=d+1;
  203.                                                  End;
  204.                                           If d<>0 then
  205.                                              Begin
  206.                                                   Gotoxy(1,3);
  207.                                                   Write('There are ',d,' "',Up(Answer),'"!!!                             ');
  208.                                              End;
  209.                                           If d=0 then
  210.                                              Begin
  211.                                                   Gotoxy(1,3); Write('There are none of "',Up(Answer),'"');
  212.                                                   inc(WrongTms);
  213.                                              End;
  214.                                      End;
  215.                                   If length(Up(Answer))<>1 then
  216.                                      If Up(Answer)=Word then
  217.                                         Begin
  218.                                              Gotoxy(1,3); Write('CORRECT!!!                                 ');
  219.                                         End
  220.                                             else
  221.                                                 Begin
  222.                                                 Gotoxy(1,3); Write('WRONG!!!                               ');
  223.                                                 inc(WrongTms);
  224.                                                 End;
  225.                              End;
  226.                           Check;
  227.                           Gotoxy(1,2); Write('Input option:                           ');
  228.                           Gotoxy(14,2);
  229.                           If WrongTms=7 then
  230.                                 Begin
  231.                                         Delay(500);
  232.                                         exit;
  233.                                 End;
  234.                           Readln(Answer);
  235.                      End;
  236.           End;
  237. Procedure Lost;
  238.         Begin
  239.                 clrscr;
  240.                 Delay(1000);
  241.                 Pout('Sorry! You lose!',1000,false);
  242.                 Writeln('The word is ',Word); Delay(1000);
  243.                 Pout('Better luck next time!',1000,false);
  244.         End;
  245.  
  246. Procedure Victory;
  247.           Begin
  248.                clrscr;
  249.                Writeln(Word,'!!!');
  250.                Writeln('CONGRATULATION!');
  251.                Readln;
  252.           End;
  253. Begin
  254.      Intro;
  255.      Title;
  256.      Loading_Screen;
  257.      Play;
  258.      If WrongTms<7 then
  259.         Victory
  260.         else
  261.                 Lost;
  262. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement