forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

need help to show images dynamicly from array

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
cocco



Joined: 12 Feb 2005
Posts: 17

PostPosted: Fri Sep 16, 2005 12:12 am    Post subject: need help to show images dynamicly from array Reply with quote

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?
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Fri Sep 16, 2005 1:47 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
cocco



Joined: 12 Feb 2005
Posts: 17

PostPosted: Fri Sep 16, 2005 2:26 am    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group