I have here a PGM that deals 4 cards to 4 players, I’m trying to figure out a way to get the 2nd text under the 1st 1…right now the text prints 1 on top of the other and looks sloppy…
~~ Shuffle
displayMode(FULLSCREEN)
function setup()
suit={“??”,“??”,“??”,“??”}
value={“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“J”,“Q”,“K”,“A”}
Shuffled=shuffleCards(5)
n=50
end
function draw()
background(32, 95, 43)
font(“Copperplate-Bold”)
fontSize(30)
card=0
fill(255)
text(“Player 1”,WIDTH/2,HEIGHT-30) – Player 1 Location
text(“Player 2”,WIDTH/2+250,HEIGHT-170) – Player 2 Location
text(“Player 3”,WIDTH/2,HEIGHT-250) – Player 3 Location
text(“Player 4”,WIDTH/2-250,HEIGHT-170) – Player 4 Location
font(“AmericanTypewriter-Bold”) – Change the font
fontSize(30) – Size of card font
for round=1,r do
for player=1,4 do
card=card+1
s=math.ceil(Shuffled[card]/13) – get suit value
v=Shuffled[card]%13+1 – get card value
str=value[v]…“of”…suit[s] – print card
fill(0)
if s>2 then
fill(255,0,0)
end
–====================================
if r>1 then
n=n+2
–end
–==================================
end
if player==1 then
text(str,WIDTH/2+5,HEIGHT/2+(n+85)*round)
end
if player==2 then
text(str,WIDTH/2+250,HEIGHT/2+(n-56)*round)
end
if player==3 then
text(str,WIDTH/2+10,HEIGHT/2+(n-138)*round)
end
if player==4 then
text(str,WIDTH/2-240,HEIGHT/2+(n-58)*round)
end
end
end
fill(0) – this fills the bottom rect with Blk
rect(0,0,WIDTH,42) – this is the red highliteer
– This is the Shuffle button
fill(255, 255, 255, 255)
stroke(255, 0, 8, 255)
strokeWidth(4)
ellipse(565,275,100)
fill(0, 0, 0, 255)
font(“Copperplate-Bold”)
fontSize(40)
text(“Shuffle”,WIDTH/2+230,HEIGHT-30)
-- This is the Deal button
fill(255, 255, 255, 255)
stroke(255, 0, 8, 255)
strokeWidth(4)
ellipse(80,275,100)
fill(0, 0, 0, 255)
font("Copperplate-Bold")
fontSize(50)
text("Deal",WIDTH/2-250,HEIGHT-30)
end
function touched(t)
if t.state==BEGAN then
if t.x>40 and t.x<140 and t.y>275 and t.y<375 then
sound(asset.documents.Card_Deal,.5)
r=r+1
if r>5 then
r=5
end
elseif t.x>465 and t.x<665 and t.y>275 and t.y<375 then
sound(asset.documents.Card_Shuffle,.5)
Shuffled=shuffleCards(5)
r=0
end
end
end
function shuffleCards(x)
r=0
local d1, d2, s, y, z = {}, {}
for z=1,52 do
d2[z]=z – fill table with numbers 1 to 52
end
for y=1,x do – shuffle x number of times
d1,d2=d2,{}
for z=1,52 do
s=math.random(1,#d1) – get a random number from table d1
table.insert(d2,d1[s]) – insert it in table d2
table.remove(d1,s) – remove it from table d1
end
end
return d2 – return shuffled deck
end ~~