Here I have a card game, BlackJack…When I press Play in the lower right corner, it doesent even go to the background… Can anyone take a peek and see whats wrong ? I see no error MSG’s…P.S. I’ve insereted 2 text() lines after the print() lines…
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
function setup()
suit={??,??,??,??}
value={" 2"," 3"," 4"," 5"," 6"," 7"," 8",
" 9","10","J","Q","K","A"}
font("Georgia-BoldItalic")
fontSize(30)
textMode(CORNER)
showKeyboard()
output.clear()
player,dealer={},{}
for z=1,2 do
table.insert(player,math.random(11))
table.insert(dealer,math.random(11))
end
showPlayer(1)
end
function draw()
background(0)
fill(255)
--if answer is Stay, then
if ans=="s" then
output.clear()
showDealer()
showPlayer(2)
showWinner()
--if answer is Hit, then
elseif ans=="h" then
output.clear()
table.insert(player,math.random(11))
showPlayer(1)
--if answer is Play again, then
elseif ans=="a" then
setup()
end
ans=""
end
--================================
function showDealer()
dealerSum=0
for a=1,#dealer do
dealerSum=dealerSum+dealer[a]
end
while dealerSum<17 do
dealerSum=0
table.insert(dealer,math.random(11))
for a=1,#dealer do
dealerSum=dealerSum+dealer[a]
end
end
--Print out to compiler
print("The dealer has a total of "..dealerSum)
print("from these cards "..table.concat(dealer," "))
text("The dealer has a total of "..dealerSum,100,HEIGHT-100)
text("from these cards "..table.concat(dealer," "),100,HEIGHT-130)
end
--================================
function showPlayer(a)
playerSum=0
for a=1,#player do
playerSum=playerSum+player[a]
end
--Print out to compiler
print("You have a total of "..playerSum)
print("From these Cards "..table.concat(player," "))
text("You have a total of "..playerSum,100,HEIGHT-200)
text("From these Cards "..table.concat(player," "),100,HEIGHT-230)
if playerSum>21 then
showWinner()
elseif a==1 then
--Print out to compiler
print("\
\
Do you want to stay(s) or hit(h)")
text("\
\
Do you want to stay(s) or hit(h)",100,HEIGHT-330)
end
end
function showWinner()
if playerSum>21 then
print("Dealer wins!")
text("Dealer wins!",100,HEIGHT-430)
elseif dealerSum>21 then
print("You win!")
text("You win!",100,HEIGHT-430)
elseif playerSum>dealerSum then
print("You win!")
text("You win!",100,HEIGHT-430)
else
print("Dealer wins!")
text("Dealer wins!",100,HEIGHT-430)
end -- end if loop
print("Play again ?(a)")
text("Play again ?(a)",100,HEIGHT-430)
end
function keyboard(k)
ans=k
end