@dave1707 Hey, I want the option to keep none,1 or 2 sprites after the 1st round ends(talking about the sprites in the small slots) so how would I go about doing that? Right now the unused sprites disappear when the 2nd round starts, so the keep none is figured out. Btw when you tap the NEXT Button the 2nd starts, just a recap. I know how to get the unused sprites to stay on screen but not sure how to get the 2nd round sprites to load in the unused slots and not on top of the sprites I want to keep.
function setup()
et=ElapsedTime
count=0
count2=0
playerscore = text
playerscoredim = vec2(150,500)
startscore=false
score=0
round=0
s=require("socket")
readybuttonSize=vec2(500,500)
readybuttonSize2=vec2(700,500)
buttonSize=vec2(500,600)
discardslot={vec2(835,100),vec2(900, 100)}
slot = { vec2(835,335), vec2(835,265), vec2(835,195), vec2(900,335), vec2(900,265), vec2(900, 195) }
gameslot = { vec3(320,290,0), vec3(445,290,0), vec3(570,290,0), vec3(695,290,0), vec3(380,180,0), vec3(505,180,0), vec3(630,180,0) }
deck = {{n=asset.builtin.Planet_Cute.Character_Princess_Girl,
v=5,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Character_Boy,
v=6,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Character_Cat_Girl,
v=8,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Gem_Green,
v=9,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Gem_Orange,
v=10,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Gem_Blue,
v=2,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Star,
v=3,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Tree_Short,
v=4,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Heart,
v=5,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Chest_Closed,
v=1,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Enemy_Bug,
v=7,x1=0,y1=0,x2=0,y2=0,s=.5},
{n=asset.builtin.Planet_Cute.Ramp_South,
v=3,x1=0,y1=0,x2=0,y2=0,s=.5}}
pick()
imageSize = spriteSize(deck[1].n)
tabA={}
tabB={}
tabC={}
tabD={}
end
function pick()
st=s:gettime()
show={}
temp={}
for z=1,6 do -- temp table of small circles positions
table.insert(temp,slot[z])
end
for z=1,6 do -- pick random name and random circle
a=math.random(#deck)
b=math.random(#temp)
table.insert(show,{name=deck[a],pos=temp[b]}) -- update show table
table.remove(deck,a)
table.remove(temp,b)
end
round=round+1
print("Round ----------- "..round)
for k,v in pairs(show) do
print(v.name,v.pos)
end
for z=1,6 do
show[z].x1=show[z].pos.x
show[z].y1=show[z].pos.y
show[z].x2=show[z].pos.x
show[z].y2=show[z].pos.y
show[z].v=show[z].name.v
show[z].s=show[z].name.s
show[z].n=show[z].name.n
end
pickR2=true
end
function draw()
background(0)
text("round 1", 200, 300)
text("round 2", 250, 200)
timer(30)
if startscore==false then
playerscore(0,playerscoredim.x,playerscoredim.y)
end
if showmidscore==true then
playerscore(tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
fontSize(30)
if cc==4 then
rectMode(CENTER)
pushStyle()
noFill()
rect(readybuttonSize.x,readybuttonSize.y,100)
popStyle()
text("Ready",500,500)
if sc==true then
scoring()
end
end
if pickR2==true and cc==3 and sc==true then --Round 2 scoring
rectMode(CENTER)
pushStyle()
noFill()
rect(readybuttonSize2.x,readybuttonSize2.y,100)
popStyle()
text("Ready",700,500)
if sc2==true then
scoring2()
end
end
sprite(asset.builtin.Cargo_Bot.Next_Button,buttonSize.x,buttonSize.y)
fill(128)
strokeWidth(5)
for k,v in pairs(slot) do
ellipse(v.x, v.y, 50)
end
for k,v in pairs(gameslot) do
ellipse(v.x, v.y, 100)
end
for z=1,6 do
pushMatrix()
zLevel(.3)
sprite(show[z].n,show[z].x2,show[z].y2,imageSize*show[z].s)
popMatrix()
end
if boardstay==true then
for z=1,#tabA do
pushMatrix()
zLevel(.3)
sprite(tabA[z].n,tabA[z].x2,tabA[z].y2,imageSize*tabA[z].s)
popMatrix()
end
end
end
function touched(touch)
if touch.state==BEGAN and --READY BUTTON
touch.x>readybuttonSize.x-75 and touch.x<readybuttonSize.x+75 and touch.y>readybuttonSize.y-50 and touch.y<readybuttonSize.y+50 and cc==4 then
sc=true
board()
end
if touch.state==BEGAN and --READY BUTTON FOR ROUND 2
touch.x>readybuttonSize2.x-75 and touch.x<readybuttonSize2.x+75 and touch.y>readybuttonSize2.y-50 and touch.y<readybuttonSize2.y+50 and cc==3 then
sc2=true
end
if touch.state==BEGAN and --NEXT BUTTON
touch.x>buttonSize.x-75 and touch.x<buttonSize.x+75 and touch.y>buttonSize.y-50 and touch.y<buttonSize.y+50 and #deck>0 and not done then
pick()
end
if touch.state==BEGAN then
if touch.x>400-50 and touch.x<400+50 and touch.y>500-50 and touch.y<500+50 then
showScore=true
end
pos=0
for a,b in pairs(show) do
if touch.x>b.x2-40 and touch.x<b.x2+40 and touch.y>b.y2-40 and
touch.y<b.y2+40 then
b.s=1 -- scaler
pos=a
for c,d in pairs(gameslot) do
if b.x2==d.x and b.y2==d.y then
d.z=0
end
end
end
end
end
if pos==0 then
return
end
if touch.state==MOVING then
show[pos].x2=show[pos].x2+touch.deltaX
show[pos].y2=show[pos].y2+touch.deltaY
end
if touch.state==ENDED then
cc=0
showScore=false
for a,b in pairs(gameslot) do
if show[pos].x2>b.x-55 and show[pos].x2<b.x+55 and show[pos].y2>b.y-55 and show[pos].y2<b.y+55 and b.z==0 then
show[pos].x2=b.x
show[pos].y2=b.y
b.z=1
for c,d in pairs(show) do
if d.x1~=d.x2 and d.y1~=d.y2 then
score=score+d.v
cc=cc+1
end
end
return
end
end
show[pos].x2=show[pos].x1
show[pos].y2=show[pos].y1
show[pos].s=.5
end
end
function timer(max)
if st==nil then
return
end
if #deck>0 then
curr=s:gettime()-st
text(string.format("Time remaining %4.1f",max-curr),WIDTH/2,HEIGHT/2)
if curr>max then
pick()
end
end
end
function scoring() --SCORING FOR ROUND 1
startscore=true
if ElapsedTime-et>1 then
count = count + 1
et=ElapsedTime
end
for z=1,#show do
if show[z].y2==290 then
table.insert(tabB,show[z].v)
end
end
for z=1,#show do
if show[z].y2==290 then
if show[z].x2==320 then
tabB[1]=show[z].v
elseif show[z].x2==445 then
tabB[2]=show[z].v
elseif show[z].x2==570 then
tabB[3]=show[z].v
elseif show[z].x2==695 then
tabB[4]=show[z].v
end
end
end
if count==1 then
playerscore(tabB[1],playerscoredim.x,playerscoredim.y)
end
if count==2 then
playerscore(tabB[1]+tabB[2],playerscoredim.x,playerscoredim.y)
end
if count==3 then
playerscore(tabB[1]+tabB[2]+tabB[3],playerscoredim.x,playerscoredim.y)
end
if count>=4 then
playerscore(tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
if count>5 then
boardstay=true
showmidscore=true
end
end
function board()
for z=1,#show do
if show[z].y2==290 then
table.insert(tabA,show[z])
end
end
for z=1,#tabA do
print(tabA[z])
end
if boardstay==true then
for z=1,#tabA do
tabA[z].x1=gameslot[z].x
tabA[z].y1=gameslot[z].y
tabA[z].x2=gameslot[z].x
tabA[z].y2=gameslot[z].y
end
end
end
function scoring2() -- SCORING FOR ROUND 2
showmidscore=false
if ElapsedTime-et>1 then
count2 = count2 + 1
et=ElapsedTime
end
for z=1,#show do
if show[z].y2==180 then
table.insert(tabD,show[z].v)
end
end
for z=1,#show do
if show[z].y2==180 then
if show[z].x2==380 then
tabD[1]=show[z].v
elseif show[z].x2==505 then
tabD[2]=show[z].v
elseif show[z].x2==630 then
tabD[3]=show[z].v
end
end
end
if count2==1 then
playerscore(tabD[1]+tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
if count2==2 then
playerscore(tabD[1]+tabD[2]+tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
if count2==3 then
playerscore(tabD[1]+tabD[2]+tabD[3]+tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
if count2>=4 then
playerscore(tabD[1]+tabD[2]+tabD[3]+tabB[1]+tabB[2]+tabB[3]+tabB[4],playerscoredim.x,playerscoredim.y)
end
end
Comments
@dave1707 That worked, thanks!
@dave1707 Hey, I want the option to keep none,1 or 2 sprites after the 1st round ends(talking about the sprites in the small slots) so how would I go about doing that? Right now the unused sprites disappear when the 2nd round starts, so the keep none is figured out. Btw when you tap the NEXT Button the 2nd starts, just a recap. I know how to get the unused sprites to stay on screen but not sure how to get the 2nd round sprites to load in the unused slots and not on top of the sprites I want to keep.
Code posted below
Only if you do this:
Edited* Disregard