Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {Only available on Turbo Pascal, don't play on Free Pascal}
- {This is a 2nd version, I will improve this game later}
- {Next update on January 30 2015}
- {This was made by Trần Việt Anh AKA Wade Rollins}
- {Any report pls send to my email pewdiepievietanh@gmail.com}
- Program Bingo;
- Uses crt;
- Var
- A,B: Array [1..5,1..5] of Integer;
- i,j,n,gt,x,y,dem,d,e,size: Integer;
- C: String;
- Function Check: Boolean;
- Var x,y,dem: Integer;
- Begin
- Dem:=0;
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- For x:=1 to 5 do
- For y:=1 to 5 do
- If A[i,j]=A[x,y] then dem:=dem+1;
- End;
- If dem>25 then Check:=true;
- End;
- Function Up(m: String): String;
- Begin
- For i:=1 to length(m) do
- m[i]:=Upcase(m[i]);
- Up:=m;
- End;
- Function Wrong(m,n,b,v,c: Integer):Boolean;
- Begin
- If (m<1) or (m>25) then Wrong:=true;
- If (n<1) or (n>5*5) then Wrong:=true;
- If (b<1) or (b>5*5) then Wrong:=true;
- If (v<1) or (v>5*5) then Wrong:=true;
- If (c<1) or (c>5*5) then Wrong:=true;
- End;
- Procedure Enter_Name_Title;
- Var A: String;
- Begin
- Write('Enter your name: '); TextColor(14); Readln(A);
- TextColor(7);
- Write('Hello '); TextColor(14); Write(A);
- TextColor(7); Writeln('! '); Delay(1000);
- clrscr;
- Writeln('Welcome to a very boring game!'); Delay(1500);
- clrscr;
- TextColor(14);
- Write('B'); Delay(750); Write('I'); Delay(750);
- Write('N'); Delay(750); Write('G'); Delay(750); Writeln('0');
- TextColor(7);
- Delay(2000);
- Write('Press Enter to continue!'); Readln;
- End;
- Procedure Make_Board;
- Var C: String;
- tg: Integer;
- Begin
- clrscr;
- Write('Do you want to make board by manual or auto?: ');
- Readln(C);
- If Up(C)='AUTO' then
- Begin
- Randomize;
- gt:=1;
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- Begin
- A[i,j]:=gt; gt:=gt+1;
- End;
- End;
- n:=5;
- For i:=1 to 5 do
- For j:=1 to 5 do
- Begin
- x:=Random(n)+1; y:=Random(n)+1;
- tg:=A[i,j]; A[i,j]:=A[x,y]; A[x,y]:=tg;
- End;
- End
- else
- Begin
- While Check=true do
- Begin
- clrscr;
- Write('Input your first line of board: ');
- Read(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5]);
- While Wrong(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5])=true do
- Begin
- Write('Input your first line of board again: ');
- Read(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5]);
- End;
- Write('Input your second line of board: ');
- Read(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5]);
- While Wrong(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5])=true do
- Begin
- Write('Input your second line of board again: ');
- Read(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5]);
- End;
- Write('Input your third line of board: ');
- Read(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5]);
- While Wrong(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5])=true do
- Begin
- Write('Input your third line of board again: ');
- Read(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5]);
- End;
- Write('Input your fourth line of board: ');
- Read(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5]);
- While Wrong(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5])=true do
- Begin
- Write('Input your forth line of board again: ');
- Read(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5]);
- End;
- Write('Input your fifth line of board: ');
- Read(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5]);
- While Wrong(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5])=true do
- Begin
- Write('Input your fifth line of board again: ');
- Read(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5]);
- End;
- End;
- End;
- clrscr;
- Writeln('So here is your board: ');
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- Write(A[i,j]:3);
- Writeln;
- End;
- Readln;
- End;
- Procedure COM_Board;
- Var tg: Integer;
- Begin
- Randomize;
- gt:=1;
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- Begin
- B[i,j]:=gt; gt:=gt+1;
- End;
- End;
- n:=5;
- For i:=1 to n do
- For j:=1 to n do
- Begin
- x:=Random(n)+1; y:=Random(n)+1;
- tg:=B[i,j]; B[i,j]:=B[x,y]; B[x,y]:=tg;
- End;
- Write('Press enter to continue!'); Readln;
- End;
- Procedure Loading_Screen;
- Begin
- For i:=1 to Random(n)+1 do
- Begin
- Delay(1000);
- clrscr; Writeln('Loading');
- Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
- Delay(1000);
- clrscr; Writeln('Loading.');
- Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
- Delay(1000);
- clrscr; Writeln('Loading..');
- Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
- Delay(1000);
- clrscr; Writeln('Loading...');
- Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
- Delay(500);
- End;
- clrscr; Write('Game Loaded!'); Delay(750);
- End;
- Procedure Write_Board;
- Begin
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- Begin
- If A[i,j]=0 then
- Begin
- TextColor(14); Write(A[i,j]:3);
- TextColor(7);
- End else
- Write(A[i,j]:3);
- End;
- Writeln;
- End;
- End;
- Procedure Write_COM_Board;
- Begin
- For i:=1 to 5 do
- Begin
- For j:=1 to 5 do
- Begin
- If B[i,j]=0 then
- Begin
- TextColor(14); Write(B[i,j]:3);
- TextColor(7);
- End else
- Write(B[i,j]:3);
- End;
- Writeln;
- End;
- End;
- Procedure Check_me;
- Begin
- dem:=0;
- gt:=0;
- For i:=1 to 5 do
- Begin
- gt:=0;
- For j:=1 to 5 do
- If A[i,j]=0 then gt:=gt+1;
- If gt=5 then dem:=dem+1;
- End;
- For j:=1 to 5 do
- Begin
- gt:=0;
- For i:=1 to 5 do
- If A[i,j]=0 then gt:=gt+1;
- If gt=5 then dem:=dem+1;
- End;
- gt:=0;
- For i:=1 to 5 do
- Begin
- j:=i;
- If A[i,j]=0 then gt:=gt+1;
- End;
- If gt=5 then dem:=dem+1;
- gt:=0;
- For i:=1 to 5 do
- Begin
- j:=6-i;
- If A[i,j]=0 then gt:=gt+1;
- End;
- If gt=5 then dem:=dem+1;
- End;
- Procedure Check_COM;
- Begin
- d:=0;
- gt:=0;
- For i:=1 to 5 do
- Begin
- gt:=0;
- For j:=1 to 5 do
- If B[i,j]=0 then gt:=gt+1;
- If gt=5 then d:=d+1;
- End;
- For j:=1 to 5 do
- Begin
- gt:=0;
- For i:=1 to 5 do
- If B[i,j]=0 then gt:=gt+1;
- If gt=5 then d:=d+1;
- End;
- gt:=0;
- For i:=1 to 5 do
- Begin
- j:=i;
- If B[i,j]=0 then gt:=gt+1;
- If gt=5 then d:=d+1;
- End;
- gt:=0;
- For i:=1 to 5 do
- Begin
- j:=6-i;
- If B[i,j]=0 then gt:=gt+1;
- If gt=5 then d:=d+1;
- End;
- End;
- Function Repick2: Boolean;
- Var q: Integer;
- Begin
- q:=0;
- For i:=1 to 5 do
- For j:=1 to 5 do
- If e=A[i,j] then q:=q+1;
- If q=0 then Repick2:=true;
- End;
- Function Repick: Boolean;
- Var q: Integer;
- Begin
- q:=0;
- For i:=1 to 5 do
- For j:=1 to 5 do
- If B[i,j]=e then q:=q+1;
- If q=0 then Repick:=true;
- End;
- Procedure Play;
- Begin
- C:='BINGO';
- clrscr; Randomize;
- dem:=0; n:=25;
- While (dem<5) do
- Begin
- Write_Board;
- For x:=1 to dem do
- Write(C[x]); Writeln;
- Write('You choose: '); Readln(e);
- While Repick2=true do
- Begin
- Write('hey choose again friend!: '); Readln(e);
- End;
- For i:=1 to 5 do
- For j:=1 to 5 do
- Begin
- If A[i,j]=e then A[i,j]:=0;
- If B[i,j]=e then B[i,j]:=0;
- End;
- Check_me; Check_COM;
- If (dem=5) or (d=5) then Break;
- clrscr; Write_Board;
- For x:=1 to dem do
- Write(C[x]); Writeln;
- Write('Computer choose: '); Delay(1000);
- e:=Random(n)+1;
- While (Repick=true) do
- Begin
- e:=Random(n)+1;
- End;
- Writeln(e); Delay(1000);
- For i:=1 to 5 do
- For j:=1 to 5 do
- Begin
- If A[i,j]=e then A[i,j]:=0;
- If B[i,j]=e then B[i,j]:=0;
- End;
- clrscr;
- Check_me; Check_COM;
- End;
- Delay(1000); clrscr;
- If (dem>=5) and (d>=5) then
- Begin
- Writeln('WOW! It''s a tie!');
- Writeln('It''s so fun while playing with you !');
- Writeln('Wish you luck every time!');
- Write('Do you wanna see the COM''s board? '); Readln(C);
- If Up(C)='YES' then
- Begin
- Writeln('Here is the COM"s board: ');
- Write_COM_Board;
- End
- else
- Writeln('OK! Bye!');
- Readln;
- Halt;
- End;
- If dem>=5 then
- Begin
- Write('You win!');
- Delay(1000); Writeln('Congratulation!'); Delay(1000);
- Writeln('It''s so fun while playing with you !'); Delay(1000);
- Writeln('Wish you luck every time!'); Delay(1000);
- Write('Do you wanna see the COM''s board? '); Readln(C);
- If Up(C)='YES' then
- Begin
- Writeln('Here is the COM"s board: ');
- Write_COM_Board;
- End
- else
- Writeln('OK! Bye!');
- Readln;
- End;
- If d>=5 then
- Begin
- Write('BINGO!! '); Delay(1000); Write('Sorry! You have lost!');
- Writeln('It''s so fun while playing with you !');
- Writeln('Wish you luck every time!');
- Write('Do you wanna see the COM''s board? '); Readln(C);
- If Up(C)='YES' then
- Begin
- Writeln('Here is the COM"s board: ');
- Write_COM_Board;
- End
- else
- Writeln('OK! Bye!');
- Readln;
- Halt;
- End;
- End;
- Begin
- clrscr;
- Enter_Name_Title;
- Make_Board;
- COM_Board;
- Loading_Screen;
- Play;
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement