Black Jack Game
+4
113080213_ega
113071025_dblackfox
113080244_eizan adachi
113080237-male
8 posters
Page 1 of 1
Black Jack Game
program Devil_Black_Jack; { Devil_BJ }
(* All Rights Reserved To Me, But You Can Edit It As You Like, Just Remember That I Wrote
This Small, And Truly Simple Game, Not You! *)
uses crt; (* In section 6.2 we studied about the functions included inside the CRT file, well,
here we'll use them, functions like the "clrscr" and "textcolor", etc. *)
const (* Here we declaring some constant variable, or should I say Range *)
nums=[16..21];
var (* declaring variables for our game *)
comp,n,m,tot,tot_p_one,x,x2,z,z2: integer;
a,b,c,d,a2,b2,c2,e,f,g,h,e2,f2,g2,num,num_comp,mone,mone2,winning: integer;
title,title_comp,num_wr,num_wr_comp,cool,cool2: string;
game,enter,player,q1,q2,q3,q4,q5,q6: char;
T: boolean;
(* You see how many variables i used, you can easly use less variables, by edit the program
a little. *)
procedure card;
(* This procedure is using the ASCII code list, to build the card's sides, the "qX" variables are
the one which will include the value which will build the sides of each card *)
begin
q1:=chr(201);
q2:=chr(205);
q3:=chr(187);
q4:=chr(186);
q5:=chr(188);
q6:=chr(200);
end;
procedure p_one;
(* The Player's turn procedure *)
begin
textbackground(green);
clrscr;
(* If we'll use the "textbackground" function and then "clrscr", this will color the whole
screen with the color we used in "textbackground" *)
a:=0; b:=0; c:=0; d:=0; a2:=0; b2:=0; c2:=0; mone:=0;
tot_p_one:=0; (* This small variable is very important to the Winning or Losing progress,
the variable counts the Total-Sum of the Player's cards *)
player:='y';
textcolor(white); (* the color of the text is now white! *)
writeln('Your`s!');
while (player='y')and(tot_p_one<=18) do
(* This "While" loop will run while the variable "player" is 'y' AND the Total-Sum of the player
is under 19 (no including 19) *)
begin
x:=random(14+1-6)+6; (* the program will run a rundom number for the 'value' of the card *)
case x of (* The good old "Case" for the Card's Sign acording to the random number above!*)
6: num_wr:='6';
7: num_wr:='7';
8: num_wr:='8';
9: num_wr:='9';
10: num_wr:='10';
11: num_wr:='J';
12: num_wr:='Q';
13: num_wr:='K';
14: num_wr:='A';
end; (* the end of the case *)
case x of (* This is another "Case" on the same Random number, this "Case" we need to
determine the Card's value in the game... Like: King(K) is the number 13 but in
the game it's value will be 4, you can change a few thing here as well to make
the game more 'effective' *)
6: num:=6;
7: num:=7;
8: num:=8;
9: num:=9;
10: num:=10;
11: num:=2;
12: num:=3;
13: num:=4;
14: num:=11;
end; (* the end of the case *)
x2:=random(4)+1; (* Random number for the type of the card *)
if x2=1 then begin title:=chr(3); textcolor(red); end;
if x2=2 then begin title:=chr(4); textcolor(red); end;
if x2=3 then begin title:=chr(5); textcolor(black); end;
if x2=4 then begin title:=chr(6); textcolor(black); end;
inc(mone);
if mone=1 then a:=num;
if mone=2 then b:=num;
if mone=3 then c:=num;
if mone=4 then d:=num;
if mone=5 then a2:=num;
if mone=6 then b2:=num;
if mone=7 then c2:=num;
cool:=cool+num_wr+title+','; (* "cool" is a string of all card, this
variable will show you at the end
of the game the card you had, and
next to it the total sum of the cards
you had. *)
if (a+b in nums)and(c=11) then c:=1;
(* the "IN" sign checks if the sun of the (a+b) is in range of the "NUMS",
which we declared at the const! *)
(* the same are the rest of the "IN" using conditions *)
if (a+b+c in nums)and(d=11) then d:=1;
if (a+b+c+d in nums)and(a2=11) then a2:=1;
if (a+b+c+d+a2 in nums)and(b2=11) then b2:=1;
if (a+b+c+d+a2+b2 in nums)and(c2=11) then c2:=1;
tot_p_one:=a+b+c+d+a2+b2+c2; (* the total sum of the cards! *)
if (num_wr<>'10')then (* the '10' includes 'two chars', 1 and 0, this will move the one small
wall of the card, and mess it's struction, that why we need
to check the
card before printing the card's struction. *)
begin
writeln(q1,q2,q2,q2,q3);
writeln(q4,'':1,num_wr,title,q4);
writeln(q4,'':3,q4);
write(q6,q2,q2,q2,q5);
end
else (* the else here, will be only executed if the above "if"'s
condition isn't correct, in this case, if the variable "num_wr"
isn't isn't 10 ( <> ) *)
begin
writeln(q1,q2,q2,q2,q3);
writeln(q4,num_wr,title,q4);
writeln(q4,'':3,q4);
write(q6,q2,q2,q2,q5);
end;
textcolor(11);
write('MORE? '); (* here and in the next command the pragram asks you,
"if you like to take another card...", if you do like
to take another card, then press: 'y'. And if you don't
then just press: 'n'. *)
readln(player);
end;
T:=true;
end;
procedure computer;
(* This procedure is computer's turn of playing *)
begin
tot:=0;
comp:=0;
n:=1;
m:=40;
gotoXY(m,n);
textcolor(yellow);
writeln('Computer`s');
writeln;
inc(n);
e:=0; f:=0; g:=0; h:=0; e2:=0; f2:=0; g2:=0;
while (comp=0)and(tot<=16) do
begin
(* the random and checking of variables are pritty much the same as at
the player's fucntion *)
z:=random(14+1-6)+6;
case z of
6: num_wr_comp:='6';
7: num_wr_comp:='7';
8: num_wr_comp:='8';
9: num_wr_comp:='9';
10: num_wr_comp:='10';
11: num_wr_comp:='J';
12: num_wr_comp:='Q';
13: num_wr_comp:='K';
14: num_wr_comp:='A';
end;
case z of
6: num_comp:=6;
7: num_comp:=7;
8: num_comp:=8;
9: num_comp:=9;
10: num_comp:=10;
11: num_comp:=2;
12: num_comp:=3;
13: num_comp:=4;
14: num_comp:=11;
end;
z2:=random(4)+1;
if (z2=1) then begin title_comp:=chr(3); textcolor(red); end;
if (z2=2) then begin title_comp:=chr(4); textcolor(red); end;
if (z2=3) then begin title_comp:=chr(5); textcolor(black); end;
if (z2=4) then begin title_comp:=chr(6); textcolor(black); end;
inc(mone2);
if (mone2=1) then e:=num_comp;
if (mone2=2) then f:=num_comp;
if (mone2=3) then g:=num_comp;
if (mone2=4) then h:=num_comp;
if (mone2=5) then e2:=num_comp;
if (mone2=6) then f2:=num_comp;
if (mone2=7) then g2:=num_comp;
cool2:=cool2+num_wr_comp+title_comp+',';
if (e+f in nums)and(g=11) then g:=1;
if (e+f+g in nums)and(h=11) then h:=1;
if (e+f+g+h in nums)and(e2=11) then e2:=1;
if (e+f+g+h+e2 in nums)and(f2=11) then f2:=1;
if (e+f+g+h+e2+f2 in nums)and(g2=11) then g2:=1;
if (num_wr_comp<>'10') then
begin
gotoXY(m,n);
writeln(q1,q2,q2,q2,q3);
inc(n);
gotoXY(m,n);
writeln(q4,'':1,num_wr_comp,title_comp,q4);
inc(n);
gotoXY(m,n);
writeln(q4,'':3,q4);
inc(n);
gotoXY(m,n);
writeln(q6,q2,q2,q2,q5);
inc(n);
end (* you see no ; just like i told you at the start of the tutorial *)
else
begin
gotoXY(m,n);
writeln(q1,q2,q2,q2,q3);
inc(n);
gotoXY(m,n);
writeln(q4,num_wr_comp,title,q4);
inc(n);
gotoXY(m,n);
writeln(q4,'':3,q4);
inc(n);
gotoXY(m,n);
writeln(q6,q2,q2,q2,q5);
inc(n);
writeln;
end;
tot:=e+f+g+h+e2+f2+g2; (* the total sum of the computer's cards! *)
end;
end;
procedure exit;
(* just a stupid exit procedure for the game's main *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('You had played: The "Devil Black-Jack"!');
writeln('You played nice, thank you come again!');
writeln;
end;
procedure crediet;
(* the game's crediets procedure, also for the game's main! *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('This is version one (v1.0) of the "Devil Black-Jack"!');
writeln('The game was written by Devil Panther, with Pascal language, on the year 2001.');
writeln;
textcolor(yellow);
writeln('Press (g) to go to the Game!');
writeln('Or Press (e) to Exit the game!');
write('':3,'Press Now: ');
readln(enter);
if (enter='g') then
p_one;
if (enter='e') then
exit;
end;
procedure help;
(* the help procedure of the game, also used from the game's main *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('This is the most easier game in a world of cards, the rools are simple:');
writeln('All you need is no to pass the 21; By this numbers of cards:');
writeln('"6" => 6, "7" => 7, "8" => 8, "9" => 9, "10" => 10,');
writeln('"J" => 2, "Q" => 3, "K" => 4, "A" => 11');
textcolor(red);
writeln('(By when the sum of the before numbers is bigger than 15,');
writeln('then the next "ACE" will be "A" => 1)');
writeln;
textcolor(yellow);
writeln('To go to the Game Press (g)!');
writeln('Or Press (e) to Exit!');
write('':3,'Press Now: ');
readln(enter);
if (enter='g') then p_one;
if (enter='e') then exit;
end;
procedure main;
begin
repeat
clrscr;
textcolor(blue);
write('To the(');
textcolor(red);
write('g');
textcolor(blue);
write(')ame | (');
textcolor(red);
write('h'); textcolor(blue);
write(')elp | (');
textcolor(red);
write('c');
textcolor(blue);
write(')rediet | (');
textcolor(red);
write('e');
textcolor(blue);
writeln(')xit');
writeln;
write('Your Choice: ');
textcolor(black);
readln(enter);
until (enter='g')or(enter='h')or(enter='c')or(enter='e');
if (enter='g') then p_one;
if (enter='h') then help;
if (enter='c') then crediet;
if (enter='e') then exit;
end;
BEGIN
randomize; (* This is the randomize for the random, so the random numbers
won't repeat itselfs... *)
textbackground(green);
clrscr;
T:=false;
card;
main;
if T then (* while the T is true *)
begin
computer;
writeln;
textbackground(black);
textcolor(white);
inc(n);
gotoXY(m,n);
write('Your`s: ');
writeln(cool,': ',tot_p_one);
inc(n);
gotoXY(m,n);
textcolor(yellow);
write('Computer`s: ');
writeln(cool2,': ',tot);
inc(n);
gotoXY(m,n);
writeln;
inc(n);
gotoXY(m,n);
textcolor(red);
if (tot_p_one>21)and(tot<=21) then
writeln('You Lost!!');
if (tot_p_one<=21)and(tot<=21) then
begin
if (tot_p_one>tot) then writeln('You Won!');
if (tot_p_one<=21)and(tot>21) then
writeln('You Won!!');
if (tot_p_one>21)and(tot>21) then
writeln('Every one lost!!!');
writeln;
writeln;
textcolor(10);
end;
ENd;
end.
(* All Rights Reserved To Me, But You Can Edit It As You Like, Just Remember That I Wrote
This Small, And Truly Simple Game, Not You! *)
uses crt; (* In section 6.2 we studied about the functions included inside the CRT file, well,
here we'll use them, functions like the "clrscr" and "textcolor", etc. *)
const (* Here we declaring some constant variable, or should I say Range *)
nums=[16..21];
var (* declaring variables for our game *)
comp,n,m,tot,tot_p_one,x,x2,z,z2: integer;
a,b,c,d,a2,b2,c2,e,f,g,h,e2,f2,g2,num,num_comp,mone,mone2,winning: integer;
title,title_comp,num_wr,num_wr_comp,cool,cool2: string;
game,enter,player,q1,q2,q3,q4,q5,q6: char;
T: boolean;
(* You see how many variables i used, you can easly use less variables, by edit the program
a little. *)
procedure card;
(* This procedure is using the ASCII code list, to build the card's sides, the "qX" variables are
the one which will include the value which will build the sides of each card *)
begin
q1:=chr(201);
q2:=chr(205);
q3:=chr(187);
q4:=chr(186);
q5:=chr(188);
q6:=chr(200);
end;
procedure p_one;
(* The Player's turn procedure *)
begin
textbackground(green);
clrscr;
(* If we'll use the "textbackground" function and then "clrscr", this will color the whole
screen with the color we used in "textbackground" *)
a:=0; b:=0; c:=0; d:=0; a2:=0; b2:=0; c2:=0; mone:=0;
tot_p_one:=0; (* This small variable is very important to the Winning or Losing progress,
the variable counts the Total-Sum of the Player's cards *)
player:='y';
textcolor(white); (* the color of the text is now white! *)
writeln('Your`s!');
while (player='y')and(tot_p_one<=18) do
(* This "While" loop will run while the variable "player" is 'y' AND the Total-Sum of the player
is under 19 (no including 19) *)
begin
x:=random(14+1-6)+6; (* the program will run a rundom number for the 'value' of the card *)
case x of (* The good old "Case" for the Card's Sign acording to the random number above!*)
6: num_wr:='6';
7: num_wr:='7';
8: num_wr:='8';
9: num_wr:='9';
10: num_wr:='10';
11: num_wr:='J';
12: num_wr:='Q';
13: num_wr:='K';
14: num_wr:='A';
end; (* the end of the case *)
case x of (* This is another "Case" on the same Random number, this "Case" we need to
determine the Card's value in the game... Like: King(K) is the number 13 but in
the game it's value will be 4, you can change a few thing here as well to make
the game more 'effective' *)
6: num:=6;
7: num:=7;
8: num:=8;
9: num:=9;
10: num:=10;
11: num:=2;
12: num:=3;
13: num:=4;
14: num:=11;
end; (* the end of the case *)
x2:=random(4)+1; (* Random number for the type of the card *)
if x2=1 then begin title:=chr(3); textcolor(red); end;
if x2=2 then begin title:=chr(4); textcolor(red); end;
if x2=3 then begin title:=chr(5); textcolor(black); end;
if x2=4 then begin title:=chr(6); textcolor(black); end;
inc(mone);
if mone=1 then a:=num;
if mone=2 then b:=num;
if mone=3 then c:=num;
if mone=4 then d:=num;
if mone=5 then a2:=num;
if mone=6 then b2:=num;
if mone=7 then c2:=num;
cool:=cool+num_wr+title+','; (* "cool" is a string of all card, this
variable will show you at the end
of the game the card you had, and
next to it the total sum of the cards
you had. *)
if (a+b in nums)and(c=11) then c:=1;
(* the "IN" sign checks if the sun of the (a+b) is in range of the "NUMS",
which we declared at the const! *)
(* the same are the rest of the "IN" using conditions *)
if (a+b+c in nums)and(d=11) then d:=1;
if (a+b+c+d in nums)and(a2=11) then a2:=1;
if (a+b+c+d+a2 in nums)and(b2=11) then b2:=1;
if (a+b+c+d+a2+b2 in nums)and(c2=11) then c2:=1;
tot_p_one:=a+b+c+d+a2+b2+c2; (* the total sum of the cards! *)
if (num_wr<>'10')then (* the '10' includes 'two chars', 1 and 0, this will move the one small
wall of the card, and mess it's struction, that why we need
to check the
card before printing the card's struction. *)
begin
writeln(q1,q2,q2,q2,q3);
writeln(q4,'':1,num_wr,title,q4);
writeln(q4,'':3,q4);
write(q6,q2,q2,q2,q5);
end
else (* the else here, will be only executed if the above "if"'s
condition isn't correct, in this case, if the variable "num_wr"
isn't isn't 10 ( <> ) *)
begin
writeln(q1,q2,q2,q2,q3);
writeln(q4,num_wr,title,q4);
writeln(q4,'':3,q4);
write(q6,q2,q2,q2,q5);
end;
textcolor(11);
write('MORE? '); (* here and in the next command the pragram asks you,
"if you like to take another card...", if you do like
to take another card, then press: 'y'. And if you don't
then just press: 'n'. *)
readln(player);
end;
T:=true;
end;
procedure computer;
(* This procedure is computer's turn of playing *)
begin
tot:=0;
comp:=0;
n:=1;
m:=40;
gotoXY(m,n);
textcolor(yellow);
writeln('Computer`s');
writeln;
inc(n);
e:=0; f:=0; g:=0; h:=0; e2:=0; f2:=0; g2:=0;
while (comp=0)and(tot<=16) do
begin
(* the random and checking of variables are pritty much the same as at
the player's fucntion *)
z:=random(14+1-6)+6;
case z of
6: num_wr_comp:='6';
7: num_wr_comp:='7';
8: num_wr_comp:='8';
9: num_wr_comp:='9';
10: num_wr_comp:='10';
11: num_wr_comp:='J';
12: num_wr_comp:='Q';
13: num_wr_comp:='K';
14: num_wr_comp:='A';
end;
case z of
6: num_comp:=6;
7: num_comp:=7;
8: num_comp:=8;
9: num_comp:=9;
10: num_comp:=10;
11: num_comp:=2;
12: num_comp:=3;
13: num_comp:=4;
14: num_comp:=11;
end;
z2:=random(4)+1;
if (z2=1) then begin title_comp:=chr(3); textcolor(red); end;
if (z2=2) then begin title_comp:=chr(4); textcolor(red); end;
if (z2=3) then begin title_comp:=chr(5); textcolor(black); end;
if (z2=4) then begin title_comp:=chr(6); textcolor(black); end;
inc(mone2);
if (mone2=1) then e:=num_comp;
if (mone2=2) then f:=num_comp;
if (mone2=3) then g:=num_comp;
if (mone2=4) then h:=num_comp;
if (mone2=5) then e2:=num_comp;
if (mone2=6) then f2:=num_comp;
if (mone2=7) then g2:=num_comp;
cool2:=cool2+num_wr_comp+title_comp+',';
if (e+f in nums)and(g=11) then g:=1;
if (e+f+g in nums)and(h=11) then h:=1;
if (e+f+g+h in nums)and(e2=11) then e2:=1;
if (e+f+g+h+e2 in nums)and(f2=11) then f2:=1;
if (e+f+g+h+e2+f2 in nums)and(g2=11) then g2:=1;
if (num_wr_comp<>'10') then
begin
gotoXY(m,n);
writeln(q1,q2,q2,q2,q3);
inc(n);
gotoXY(m,n);
writeln(q4,'':1,num_wr_comp,title_comp,q4);
inc(n);
gotoXY(m,n);
writeln(q4,'':3,q4);
inc(n);
gotoXY(m,n);
writeln(q6,q2,q2,q2,q5);
inc(n);
end (* you see no ; just like i told you at the start of the tutorial *)
else
begin
gotoXY(m,n);
writeln(q1,q2,q2,q2,q3);
inc(n);
gotoXY(m,n);
writeln(q4,num_wr_comp,title,q4);
inc(n);
gotoXY(m,n);
writeln(q4,'':3,q4);
inc(n);
gotoXY(m,n);
writeln(q6,q2,q2,q2,q5);
inc(n);
writeln;
end;
tot:=e+f+g+h+e2+f2+g2; (* the total sum of the computer's cards! *)
end;
end;
procedure exit;
(* just a stupid exit procedure for the game's main *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('You had played: The "Devil Black-Jack"!');
writeln('You played nice, thank you come again!');
writeln;
end;
procedure crediet;
(* the game's crediets procedure, also for the game's main! *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('This is version one (v1.0) of the "Devil Black-Jack"!');
writeln('The game was written by Devil Panther, with Pascal language, on the year 2001.');
writeln;
textcolor(yellow);
writeln('Press (g) to go to the Game!');
writeln('Or Press (e) to Exit the game!');
write('':3,'Press Now: ');
readln(enter);
if (enter='g') then
p_one;
if (enter='e') then
exit;
end;
procedure help;
(* the help procedure of the game, also used from the game's main *)
begin
clrscr;
textbackground(white);
textcolor(black);
writeln('This is the most easier game in a world of cards, the rools are simple:');
writeln('All you need is no to pass the 21; By this numbers of cards:');
writeln('"6" => 6, "7" => 7, "8" => 8, "9" => 9, "10" => 10,');
writeln('"J" => 2, "Q" => 3, "K" => 4, "A" => 11');
textcolor(red);
writeln('(By when the sum of the before numbers is bigger than 15,');
writeln('then the next "ACE" will be "A" => 1)');
writeln;
textcolor(yellow);
writeln('To go to the Game Press (g)!');
writeln('Or Press (e) to Exit!');
write('':3,'Press Now: ');
readln(enter);
if (enter='g') then p_one;
if (enter='e') then exit;
end;
procedure main;
begin
repeat
clrscr;
textcolor(blue);
write('To the(');
textcolor(red);
write('g');
textcolor(blue);
write(')ame | (');
textcolor(red);
write('h'); textcolor(blue);
write(')elp | (');
textcolor(red);
write('c');
textcolor(blue);
write(')rediet | (');
textcolor(red);
write('e');
textcolor(blue);
writeln(')xit');
writeln;
write('Your Choice: ');
textcolor(black);
readln(enter);
until (enter='g')or(enter='h')or(enter='c')or(enter='e');
if (enter='g') then p_one;
if (enter='h') then help;
if (enter='c') then crediet;
if (enter='e') then exit;
end;
BEGIN
randomize; (* This is the randomize for the random, so the random numbers
won't repeat itselfs... *)
textbackground(green);
clrscr;
T:=false;
card;
main;
if T then (* while the T is true *)
begin
computer;
writeln;
textbackground(black);
textcolor(white);
inc(n);
gotoXY(m,n);
write('Your`s: ');
writeln(cool,': ',tot_p_one);
inc(n);
gotoXY(m,n);
textcolor(yellow);
write('Computer`s: ');
writeln(cool2,': ',tot);
inc(n);
gotoXY(m,n);
writeln;
inc(n);
gotoXY(m,n);
textcolor(red);
if (tot_p_one>21)and(tot<=21) then
writeln('You Lost!!');
if (tot_p_one<=21)and(tot<=21) then
begin
if (tot_p_one>tot) then writeln('You Won!');
if (tot_p_one<=21)and(tot>21) then
writeln('You Won!!');
if (tot_p_one>21)and(tot>21) then
writeln('Every one lost!!!');
writeln;
writeln;
textcolor(10);
end;
ENd;
end.
113080237-male- Posts : 1
Join date : 2008-12-06
Re: Black Jack Game
wuich, udh bs jlan blm??pgn dunk bljr?
113080213_ega- Posts : 25
Join date : 2008-11-26
Age : 34
Location : Kopo District of Traffic
Re: Black Jack Game
Tu apaan??????
Tu ngopas atau bikin sendiri??????
Tu ngopas atau bikin sendiri??????
113080208_danu- Posts : 38
Join date : 2008-12-04
Age : 32
Location : Bandung
Re: Black Jack Game
ini apa sih??
ada yg mau jelasin?
ada yg mau jelasin?
113080211_danc- Posts : 8
Join date : 2008-12-03
Age : 32
Location : Bandung
Re: Black Jack Game
stuju .
paan c tu ?
tubes atw iseng" bikin atw co-pas?
paan c tu ?
tubes atw iseng" bikin atw co-pas?
113080202_dEeNa- Posts : 10
Join date : 2008-12-13
Age : 33
Re: Black Jack Game
ni program paan...
kok ga bisa dimaenin....
kok ga bisa dimaenin....
113080208_danu- Posts : 38
Join date : 2008-12-04
Age : 32
Location : Bandung
paan c????
tu program kog panjang bgt? tubes ya? aduh, daripada tubes mendingan pada bikin rangkuman prokom aja, nt diposting di sini terus kita copas bareng2. tapi siapa yang bikin??? danu aja gimana? apa doni? hahaha
113080240_mitha- Posts : 17
Join date : 2008-12-10
Re: Black Jack Game
lah....knapa mesti danu??????
113080208_danu- Posts : 38
Join date : 2008-12-04
Age : 32
Location : Bandung
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|