Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program Hang_Man;
- Uses crt;
- Var
- Word, Answer, Hi: String;
- Wrong, WrongTms, i: Integer;
- Hint: Boolean;
- Procedure Pout(S: String; De: Integer; Bool: Boolean);
- Begin
- If Bool=true then
- Begin
- Write(S);
- Delay(De);
- End;
- If Bool=false then
- Begin
- Writeln(S);
- Delay(De);
- End;
- End;
- Procedure Intro;
- Begin
- clrscr;
- Pout('What would you do...',2000,true);
- Pout('when a man''s life is dependent on you???',2000,false);
- Pout('Would you do your best?...',2000,false);
- Pout('...Or you just gonna scared and run???',2000,false);
- End;
- Procedure Title;
- Begin
- clrscr; TextColor(White); Gotoxy(36,1);
- Write('H'); Delay(1000);
- Write('A'); Delay(1000);
- Write('N'); Delay(1000);
- Write('G '); Delay(1000);
- Write('M'); Delay(1000);
- Write('A'); Delay(1000);
- Write('N'); Delay(1000);
- clrscr;
- Gotoxy(35,1); TextColor(150);
- Write('Press Enter!');
- Readln;
- TextColor(White);
- End;
- Function Up(m: String): String;
- Var
- i: Integer;
- Begin
- For i:=1 to length(m) do
- m[i]:=Upcase(m[i]);
- Up:=m;
- End;
- Procedure Loading_Screen;
- Var
- i: Integer;
- Begin
- clrscr;
- For i:=1 to Random(2)+1 do
- Begin
- clrscr;
- Gotoxy(33,1);
- Write('Loading'); Delay(500);
- clrscr;
- Gotoxy(33,1);
- Write('Loading.'); Delay(500);
- clrscr;
- Gotoxy(33,1);
- Write('Loading..'); Delay(500);
- clrscr;
- Gotoxy(33,1);
- Write('Loading...'); Delay(500);
- End;
- End;
- Procedure Draw1;
- Var i: Integer;
- Begin
- Gotoxy(3,20);
- Write('******************');
- Gotoxy(1,5);
- For i:=1 to 15 do
- Writeln(' * ');
- End;
- Procedure Draw2;
- Var i: Integer;
- Begin
- Gotoxy(4,5);
- Write('**********************');
- Gotoxy(24,6); Write('*');
- Gotoxy(22,7); Write(' ***');
- Gotoxy(22,8); Write('* *');
- Gotoxy(22,9); Write('* *');
- Gotoxy(22,10); Write('* *');
- Gotoxy(23,11);Write('***');
- End;
- Procedure Draw3;
- Var
- i, x: Integer;
- Begin
- x:=24;
- For i:=12 to 15 do
- Begin
- Gotoxy(24,i); Write('*');
- End;
- End;
- Procedure Draw4;
- Var
- x, y ,z: Integer;
- Begin
- x:=12;
- y:=25;
- For z:=1 to 3 do
- Begin
- Gotoxy(y,x); Write('*');
- inc(x); inc(y);
- End;
- End;
- Procedure Draw5;
- Var
- x, y ,z: Integer;
- Begin
- x:=16;
- y:=25;
- For z:=1 to 3 do
- Begin
- Gotoxy(y,x); Write('*');
- inc(x); inc(y);
- End;
- End;
- Procedure Draw6;
- Var
- x, y ,z: Integer;
- Begin
- x:=12;
- y:=23;
- For z:=1 to 3 do
- Begin
- Gotoxy(y,x); Write('*');
- inc(x); dec(y);
- End;
- End;
- Procedure Draw7;
- Var
- x, y ,z: Integer;
- Begin
- x:=16;
- y:=23;
- For z:=1 to 3 do
- Begin
- Gotoxy(y,x); Write('*');
- inc(x); dec(y);
- End;
- End;
- Procedure Check;
- Begin
- Case WrongTms of
- 1: Draw1;
- 2: Draw2;
- 3: Draw3;
- 4: Draw4;
- 5: Draw5;
- 6: Draw6;
- 7: Draw7;
- End;
- End;
- Procedure Play;
- Var
- i, d: Integer;
- Correct: Boolean;
- Begin
- Word:='BJANRE STROUSTRUP';
- clrscr; Delay(2000); WrongTms:=0;
- For i:=1 to length(Word) do
- Begin
- If Word[i]<>' ' then
- Write('_')
- else
- Write(' ');
- End;
- Writeln;
- Write('Input option: ');
- Readln(Answer);
- While (Up(Answer)<>Word) and (WrongTms<7) do
- Begin
- If Up(Answer)='HINT' then
- Begin
- Writeln;
- Writeln('A man who is very famous in programming industry');
- inc(WrongTms);
- Check;
- End;
- If Up(Answer)='EXIT' then Halt;
- If (Up(Answer)<>'HINT') and (Up(Answer)<>'EXIT') then
- Begin
- If length(Up(Answer))=1 then
- Begin
- d:=0;
- For i:=1 to length(Word) do
- If Word[i]=Up(Answer) then
- Begin
- Gotoxy(i,1); Write(Word[i]);
- d:=d+1;
- End;
- If d<>0 then
- Begin
- Gotoxy(1,3);
- Write('There are ',d,' "',Up(Answer),'"!!! ');
- End;
- If d=0 then
- Begin
- Gotoxy(1,3); Write('There are none of "',Up(Answer),'"');
- inc(WrongTms);
- End;
- End;
- If length(Up(Answer))<>1 then
- If Up(Answer)=Word then
- Begin
- Gotoxy(1,3); Write('CORRECT!!! ');
- End
- else
- Begin
- Gotoxy(1,3); Write('WRONG!!! ');
- inc(WrongTms);
- End;
- End;
- Check;
- Gotoxy(1,2); Write('Input option: ');
- Gotoxy(14,2);
- If WrongTms=7 then
- Begin
- Delay(500);
- exit;
- End;
- Readln(Answer);
- End;
- End;
- Procedure Lost;
- Begin
- clrscr;
- Delay(1000);
- Pout('Sorry! You lose!',1000,false);
- Writeln('The word is ',Word); Delay(1000);
- Pout('Better luck next time!',1000,false);
- End;
- Procedure Victory;
- Begin
- clrscr;
- Writeln(Word,'!!!');
- Writeln('CONGRATULATION!');
- Readln;
- End;
- Begin
- Intro;
- Title;
- Loading_Screen;
- Play;
- If WrongTms<7 then
- Victory
- else
- Lost;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement