i'm trying to make blackjack
and so i us
colors ={a,b,c,d} --for spade heart....
numders {2,3,4,5,6,7,8,9,10,j,q,k,a} //for number of card
i load all picture
d2d = Image.load("cardspng/2d.png")
d3d = Image.load("cardspng/3d.png")
d4d = Image.load("cardspng/4d.png")
d5d = Image.load("cardspng/5d.png")
d6d = Image.load("cardspng/6d.png")
where the first and the last letter is color and the middle number is the cardnumber
after load i have to show the cards on screen
i do
random colors and numbers
and here is my prob
cardtoload = color .. number .. color (so example cardtoload = a2a)
screen:blit(x, y, cardtoload)
i get error (try to send image as string ... not possible)
what can i do to show the png dynamicly?
need help to show images dynamicly from array
Moderators: Shine, Insert_witty_name
you can't concatenate variable names. something like this should work:
cardImage = {}
cardImage["2d"] = Image.load("cardspng/2d.png")
cardImage["3d"] = Image.load("cardspng/3d.png")
cardImage["4d"] = Image.load("cardspng/4d.png")
cardImage["5d"] = Image.load("cardspng/5d.png")
cardImage["6d"] = Image.load("cardspng/6d.png")
then you can reference them like this:
cardImage[number .. suit]
cardImage = {}
cardImage["2d"] = Image.load("cardspng/2d.png")
cardImage["3d"] = Image.load("cardspng/3d.png")
cardImage["4d"] = Image.load("cardspng/4d.png")
cardImage["5d"] = Image.load("cardspng/5d.png")
cardImage["6d"] = Image.load("cardspng/6d.png")
then you can reference them like this:
cardImage[number .. suit]
Chaosmachine Studios: High Quality Homebrew.
thank you ... it works fins
but now i have another problem
local oldpad = Controls.read()
while true do
pad = Controls.read()
if pad ~= oldpad then
if pad:triangle() then
cash = cash + bet
bet = 0
end
end
this funktion is to made the buttons act like a button
but it does not work
if i press 1 button it's like i press it 5 times ;o)
but now i have another problem
local oldpad = Controls.read()
while true do
pad = Controls.read()
if pad ~= oldpad then
if pad:triangle() then
cash = cash + bet
bet = 0
end
end
this funktion is to made the buttons act like a button
but it does not work
if i press 1 button it's like i press it 5 times ;o)