var pos_x_player : int := 0
var pos_x_dealer : int := 0
var player, dealer : int
var c1, c2, c3 : int
var d1, d2, d3 : int
var acecount : int := 0
var doneace, doneace2 : int := 0
%Dealer Cards
proc dealercards
d1 := Rand.Int (1, 52)
d2 := Rand.Int (1, 52)
if d2 = d1 then
d2 := Rand.Int (1, 52)
end if
dealer := cardtotal (d1)
locate (4, 30)
colorback (120)
color (40)
put dealer ..
Pic.Draw (cards (d1), 250, 320, picCopy)
Pic.Draw (cards (53), 300, 320, picCopy)
end dealercards
%Player Cards
proc playercards
c1 := Rand.Int (1, 52)
c2 := Rand.Int (1, 1)
if c2 = c1 then
c2 := Rand.Int (1, 52)
end if
player := cardtotal (c1) + cardtotal (c2)
locate (15, 37)
colorback (120)
color (40)
put player ..
Pic.Draw (cards (c1), 250, 120, picCopy)
Pic.Draw (cards (c2), 300, 120, picCopy)
end playercards
%Player Hit Cards
proc playerhit
c3 := Rand.Int (1, 52)
pos_x_player := pos_x_player + 50
player := player + cardtotal (c3)
locate (15, 37)
colorback (120)
color (40)
put player ..
Pic.Draw (cards (c3), 300 + pos_x_player, 120, picCopy)
end playerhit
%Dealer Hit Cards
proc dealerhit
var d1 : int
d1 := Rand.Int (1, 52)
pos_x_dealer := pos_x_dealer + 50
dealer := dealer + cardtotal (d1)
locate (4, 30)
colorback (120)
color (40)
put dealer ..
Pic.Draw (cards (d1), 300 + pos_x_dealer, 320, picCopy)
end dealerhit
%Setting the Ace value at 1 and 11
proc oneor11c1
if c1 = 1 or c1 = 14 or c1 = 27 or c1 = 40 then
acecount := 1
player := 11 + cardtotal (c2)
end if
locate (15, 37)
colorback (120)
color (40)
put player ..
end oneor11c1
proc oneor11c2
if c2 = 1 or c2 = 14 or c2 = 27 or c2 = 40 and acecount not= 1 then
player := cardtotal (c1) + 11
end if
locate (15, 37)
colorback (120)
color (40)
put player ..
end oneor11c2
%Turning 11 to 1 if total > 21
proc acecheck1
if player > 21 and c1 = 1 or c1 = 14 or c1 = 27 or c1 = 40 and doneace = 1then
player := player - 10
doneace := 0
end if
locate (15, 37)
colorback (120)
color (40)
put player ..
end acecheck1
proc acecheck2
if player > 21 and c2 = 1 or c2 = 14 or c2 = 27 or c2 = 40 and doneace2 = 1 then
player := player - 10
doneace2 := 0
end if
locate (15, 37)
colorback (120)
color (40)
put player ..
end acecheck2
%Main Program
proc main
var x, y, button : int
loop
mousewhere (x, y, button)
if x >= 400 and x <= 449 and y >= 10 and y <= 55 and button = 1 then
pos_x_player := 0
pos_x_dealer := 0
Pic.Draw (table, 0, 0, picCopy)
Pic.Draw (buttons (1), 400, 10, picCopy)
Pic.Draw (buttons (2), 450, 10, picCopy)
Pic.Draw (buttons (3), 500, 10, picCopy)
Pic.Draw (buttons (4), 550, 10, picCopy)
playercards
oneor11c1
oneor11c2
acecheck1
acecheck2
dealercards
acecount := 0
delay (200)
elsif x >= 450 and x <= 499 and y >= 10 and y <= 55 and button = 1 then
playerhit
acecheck1
acecheck2
delay (200)
elsif x >= 500 and x <= 549 and y >= 10 and y <= 55 and button = 1 then
end if
exit when x >= 550 and x <= 599 and y >= 10 and y <= 55 and button = 1
end loop
cls
end main |