Advertisement
WadeRollins2710

[Game] BINGO!!!!

Jan 12th, 2015
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 10.39 KB | None | 0 0
  1. {Only available on Turbo Pascal, don't play on Free Pascal}
  2. {This is a  2nd version, I will improve this game later}
  3. {Next update on January 30 2015}
  4. {This was made by Trần Việt Anh AKA Wade Rollins}
  5. {Any report pls send to my email pewdiepievietanh@gmail.com}
  6. Program Bingo;
  7. Uses crt;
  8. Var
  9.    A,B: Array [1..5,1..5] of Integer;
  10.    i,j,n,gt,x,y,dem,d,e,size: Integer;
  11.    C: String;
  12. Function Check: Boolean;
  13.    Var x,y,dem: Integer;
  14.    Begin
  15.     Dem:=0;
  16.     For i:=1 to 5 do
  17.      Begin
  18.       For j:=1 to 5 do
  19.        For x:=1 to 5 do
  20.         For y:=1 to 5 do
  21.          If A[i,j]=A[x,y] then dem:=dem+1;
  22.      End;
  23.     If dem>25 then Check:=true;
  24.    End;
  25. Function Up(m: String): String;
  26.    Begin
  27.      For i:=1 to length(m) do
  28.       m[i]:=Upcase(m[i]);
  29.      Up:=m;
  30.    End;
  31. Function Wrong(m,n,b,v,c: Integer):Boolean;
  32.    Begin
  33.     If (m<1) or (m>25) then Wrong:=true;
  34.     If (n<1) or (n>5*5) then Wrong:=true;
  35.     If (b<1) or (b>5*5) then Wrong:=true;
  36.     If (v<1) or (v>5*5) then Wrong:=true;
  37.     If (c<1) or (c>5*5) then Wrong:=true;
  38.    End;
  39. Procedure Enter_Name_Title;
  40.     Var A: String;
  41.     Begin
  42.      Write('Enter your name: ');  TextColor(14); Readln(A);
  43.      TextColor(7);
  44.      Write('Hello '); TextColor(14); Write(A);
  45.      TextColor(7); Writeln('! '); Delay(1000);
  46.      clrscr;
  47.      Writeln('Welcome to a very boring game!'); Delay(1500);
  48.      clrscr;
  49.      TextColor(14);
  50.      Write('B'); Delay(750); Write('I'); Delay(750);
  51.      Write('N'); Delay(750); Write('G'); Delay(750); Writeln('0');
  52.      TextColor(7);
  53.      Delay(2000);
  54.      Write('Press Enter to continue!'); Readln;
  55.     End;
  56. Procedure Make_Board;
  57.     Var C: String;
  58.         tg: Integer;
  59.     Begin
  60.      clrscr;
  61.      Write('Do you want to make board by manual or auto?: ');
  62.      Readln(C);
  63.      If Up(C)='AUTO' then
  64.       Begin
  65.        Randomize;
  66.        gt:=1;
  67.        For i:=1 to 5 do
  68.         Begin
  69.          For j:=1 to 5 do
  70.           Begin
  71.            A[i,j]:=gt; gt:=gt+1;
  72.           End;
  73.          End;
  74.        n:=5;
  75.        For i:=1 to 5 do
  76.         For j:=1 to 5 do
  77.          Begin
  78.           x:=Random(n)+1; y:=Random(n)+1;
  79.           tg:=A[i,j]; A[i,j]:=A[x,y]; A[x,y]:=tg;
  80.          End;
  81.       End
  82.       else
  83.      Begin
  84.       While Check=true do
  85.        Begin
  86.           clrscr;
  87.           Write('Input your first line of board: ');
  88.           Read(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5]);
  89.           While Wrong(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5])=true do
  90.            Begin
  91.           Write('Input your first line of board again: ');
  92.           Read(A[1,1],A[1,2],A[1,3],A[1,4],A[1,5]);
  93.            End;
  94.           Write('Input your second line of board: ');
  95.           Read(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5]);
  96.           While Wrong(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5])=true do
  97.            Begin
  98.           Write('Input your second line of board again: ');
  99.           Read(A[2,1],A[2,2],A[2,3],A[2,4],A[2,5]);
  100.            End;
  101.           Write('Input your third line of board: ');
  102.           Read(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5]);
  103.           While Wrong(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5])=true do
  104.            Begin
  105.           Write('Input your third line of board again: ');
  106.           Read(A[3,1],A[3,2],A[3,3],A[3,4],A[3,5]);
  107.            End;
  108.           Write('Input your fourth line of board: ');
  109.           Read(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5]);
  110.           While Wrong(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5])=true do
  111.            Begin
  112.           Write('Input your forth line of board again: ');
  113.           Read(A[4,1],A[4,2],A[4,3],A[4,4],A[4,5]);
  114.            End;
  115.           Write('Input your fifth line of board: ');
  116.           Read(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5]);
  117.           While Wrong(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5])=true do
  118.            Begin
  119.           Write('Input your fifth line of board again: ');
  120.           Read(A[5,1],A[5,2],A[5,3],A[5,4],A[5,5]);
  121.            End;
  122.       End;
  123.      End;
  124.      clrscr;
  125.      Writeln('So here is your board: ');
  126.      For i:=1 to 5 do
  127.       Begin
  128.        For j:=1 to 5 do
  129.         Write(A[i,j]:3);
  130.        Writeln;
  131.       End;
  132.      Readln;
  133.     End;
  134. Procedure COM_Board;
  135.      Var tg: Integer;
  136.      Begin
  137.       Randomize;
  138.       gt:=1;
  139.       For i:=1 to 5 do
  140.        Begin
  141.         For j:=1 to 5 do
  142.          Begin
  143.           B[i,j]:=gt; gt:=gt+1;
  144.          End;
  145.        End;
  146.       n:=5;
  147.         For i:=1 to n do
  148.          For j:=1 to n do
  149.           Begin
  150.            x:=Random(n)+1; y:=Random(n)+1;
  151.            tg:=B[i,j]; B[i,j]:=B[x,y]; B[x,y]:=tg;
  152.           End;
  153.     Write('Press enter to continue!'); Readln;
  154.     End;
  155. Procedure Loading_Screen;
  156.     Begin
  157.      For i:=1 to Random(n)+1 do
  158.       Begin
  159.        Delay(1000);
  160.        clrscr; Writeln('Loading');
  161.        Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
  162.        Delay(1000);
  163.        clrscr; Writeln('Loading.');
  164.        Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
  165.        Delay(1000);
  166.        clrscr; Writeln('Loading..');
  167.        Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
  168.        Delay(1000);
  169.        clrscr; Writeln('Loading...');
  170.        Writeln('This game was made by Tran Viet Anh AKA Wade Rollins');
  171.        Delay(500);
  172.       End;
  173.      clrscr; Write('Game Loaded!'); Delay(750);
  174.     End;
  175. Procedure Write_Board;
  176.      Begin
  177.       For i:=1 to 5 do
  178.       Begin
  179.        For j:=1 to 5 do
  180.         Begin
  181.          If A[i,j]=0 then
  182.           Begin
  183.            TextColor(14); Write(A[i,j]:3);
  184.            TextColor(7);
  185.           End else
  186.          Write(A[i,j]:3);
  187.         End;
  188.        Writeln;
  189.       End;
  190.      End;
  191. Procedure Write_COM_Board;
  192.      Begin
  193.       For i:=1 to 5 do
  194.       Begin
  195.        For j:=1 to 5 do
  196.         Begin
  197.          If B[i,j]=0 then
  198.           Begin
  199.            TextColor(14); Write(B[i,j]:3);
  200.            TextColor(7);
  201.           End else
  202.          Write(B[i,j]:3);
  203.         End;
  204.        Writeln;
  205.       End;
  206.      End;
  207. Procedure Check_me;
  208.      Begin
  209.       dem:=0;
  210.       gt:=0;
  211.       For i:=1 to 5 do
  212.        Begin
  213.         gt:=0;
  214.         For j:=1 to 5 do
  215.          If A[i,j]=0 then gt:=gt+1;
  216.         If gt=5 then dem:=dem+1;
  217.        End;
  218.       For j:=1 to 5 do
  219.        Begin
  220.         gt:=0;
  221.         For i:=1 to 5 do
  222.          If A[i,j]=0 then gt:=gt+1;
  223.         If gt=5 then dem:=dem+1;
  224.        End;
  225.       gt:=0;
  226.       For i:=1 to 5 do
  227.        Begin
  228.         j:=i;
  229.         If A[i,j]=0 then gt:=gt+1;
  230.        End;
  231.       If gt=5 then dem:=dem+1;
  232.       gt:=0;
  233.       For i:=1 to 5 do
  234.        Begin
  235.         j:=6-i;
  236.         If A[i,j]=0 then gt:=gt+1;
  237.        End;
  238.       If gt=5 then dem:=dem+1;
  239.      End;
  240. Procedure Check_COM;
  241.      Begin
  242.       d:=0;
  243.       gt:=0;
  244.       For i:=1 to 5 do
  245.        Begin
  246.         gt:=0;
  247.         For j:=1 to 5 do
  248.          If B[i,j]=0 then gt:=gt+1;
  249.         If gt=5 then d:=d+1;
  250.        End;
  251.       For j:=1 to 5 do
  252.        Begin
  253.         gt:=0;
  254.         For i:=1 to 5 do
  255.          If B[i,j]=0 then gt:=gt+1;
  256.         If gt=5 then d:=d+1;
  257.        End;
  258.       gt:=0;
  259.       For i:=1 to 5 do
  260.        Begin
  261.         j:=i;
  262.         If B[i,j]=0 then gt:=gt+1;
  263.         If gt=5 then d:=d+1;
  264.        End;
  265.       gt:=0;
  266.       For i:=1 to 5 do
  267.        Begin
  268.         j:=6-i;
  269.         If B[i,j]=0 then gt:=gt+1;
  270.         If gt=5 then d:=d+1;
  271.        End;
  272.      End;
  273. Function Repick2: Boolean;
  274.     Var q: Integer;
  275.     Begin
  276.      q:=0;
  277.      For i:=1 to 5 do
  278.       For j:=1 to 5 do
  279.        If e=A[i,j] then q:=q+1;
  280.      If q=0 then Repick2:=true;
  281.     End;
  282. Function Repick: Boolean;
  283.     Var q: Integer;
  284.     Begin
  285.      q:=0;
  286.      For i:=1 to 5 do
  287.       For j:=1 to 5 do
  288.        If B[i,j]=e then q:=q+1;
  289.      If q=0 then Repick:=true;
  290.     End;
  291. Procedure Play;
  292.      Begin
  293.       C:='BINGO';
  294.       clrscr; Randomize;
  295.       dem:=0; n:=25;
  296.       While (dem<5) do
  297.        Begin
  298.         Write_Board;
  299.         For x:=1 to dem do
  300.          Write(C[x]); Writeln;
  301.         Write('You choose: '); Readln(e);
  302.         While Repick2=true do
  303.          Begin
  304.           Write('hey choose again friend!: '); Readln(e);
  305.          End;
  306.         For i:=1 to 5 do
  307.          For j:=1 to 5 do
  308.           Begin
  309.            If A[i,j]=e then A[i,j]:=0;
  310.            If B[i,j]=e then B[i,j]:=0;
  311.           End;
  312.         Check_me; Check_COM;
  313.         If (dem=5) or (d=5) then Break;
  314.         clrscr; Write_Board;
  315.         For x:=1 to dem do
  316.          Write(C[x]); Writeln;
  317.         Write('Computer choose: '); Delay(1000);
  318.         e:=Random(n)+1;
  319.         While (Repick=true) do
  320.          Begin
  321.           e:=Random(n)+1;
  322.          End;
  323.         Writeln(e); Delay(1000);
  324.         For i:=1 to 5 do
  325.          For j:=1 to 5 do
  326.           Begin
  327.            If A[i,j]=e then A[i,j]:=0;
  328.            If B[i,j]=e then B[i,j]:=0;
  329.           End;
  330.         clrscr;
  331.         Check_me; Check_COM;
  332.        End;
  333.       Delay(1000); clrscr;
  334.       If (dem>=5) and (d>=5) then
  335.        Begin
  336.          Writeln('WOW! It''s a tie!');
  337.          Writeln('It''s so fun while playing with you !');
  338.          Writeln('Wish you luck every time!');
  339.          Write('Do you wanna see the COM''s board? '); Readln(C);
  340.          If Up(C)='YES' then
  341.           Begin
  342.            Writeln('Here is the COM"s board: ');
  343.            Write_COM_Board;
  344.           End
  345.           else
  346.            Writeln('OK! Bye!');
  347.            Readln;
  348.            Halt;
  349.        End;
  350.       If dem>=5 then
  351.        Begin
  352.         Write('You win!');
  353.         Delay(1000); Writeln('Congratulation!'); Delay(1000);
  354.         Writeln('It''s so fun while playing with you !'); Delay(1000);
  355.         Writeln('Wish you luck every time!'); Delay(1000);
  356.          Write('Do you wanna see the COM''s board? '); Readln(C);
  357.          If Up(C)='YES' then
  358.           Begin
  359.            Writeln('Here is the COM"s board: ');
  360.            Write_COM_Board;
  361.           End
  362.           else
  363.            Writeln('OK! Bye!');
  364.         Readln;
  365.        End;
  366.       If d>=5 then
  367.        Begin
  368.         Write('BINGO!! '); Delay(1000); Write('Sorry! You have lost!');
  369.         Writeln('It''s so fun while playing with you !');
  370.         Writeln('Wish you luck every time!');
  371.         Write('Do you wanna see the COM''s board? '); Readln(C);
  372.          If Up(C)='YES' then
  373.           Begin
  374.            Writeln('Here is the COM"s board: ');
  375.            Write_COM_Board;
  376.           End
  377.           else
  378.            Writeln('OK! Bye!');
  379.         Readln;
  380.         Halt;
  381.        End;
  382.      End;
  383. Begin
  384.      clrscr;
  385.      Enter_Name_Title;
  386.      Make_Board;
  387.      COM_Board;
  388.      Loading_Screen;
  389.      Play;
  390.      Readln;
  391. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement