need help to show images dynamicly from array

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
cocco
Posts: 17
Joined: Sat Feb 12, 2005 10:38 am

need help to show images dynamicly from array

Post by cocco »

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?
chaos
Posts: 135
Joined: Sun Apr 10, 2005 5:05 pm

Post by chaos »

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]
Chaosmachine Studios: High Quality Homebrew.
cocco
Posts: 17
Joined: Sat Feb 12, 2005 10:38 am

Post by cocco »

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)
Post Reply