You can see below my attempt to make a Card class. I’m not really sure what I need to do. The idea was that p in Card:init(X,y,p) would be used as a key into the array of pictures, and then I would concatenate that key onto the string “Documents:” to make it grab the right picture. You can see my attempt in the main setup
Card = class()
--array containing diamond, spade, heart, clubs pictures
--p is the key to pictures, appearing in sprite("Documents:
pictures = {dK,dQ,dJ,d10,d9,d8,d7,d6,d5,d4,d3,d2,dA,
sK,sQ,sJ,s10,s9,s8,s7,s6,s5,s4,s3,s2,sA,
hK,hQ,hJ,h10,h9,h8,h7,h6,h5,h4,h3,h2,hA,
cK,cQ,cJ,c10,c9,c8,c7,c6,c5,c4,c3,c2,cA}
function Card:init(x,y,p)
self.x = x
self.y = y
self.pic = "Documents:"..pictures[p]
end
function Card:draw()
sprite(pic,self.x,self.y)
end
and here is main
--Main
function setup()
Setup:init()
deal = Card(40,40,1)
end
function draw()
background(black)
--deal:draw()
end