#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# How to make circles disappear and reappear.

edited June 2013 Posts: 4

Hello! I'm completely new to this and I need some help. I want to make a game where a white circle pops up in a random place and you have to try to touch it before it disappears. I really appreciate for the help! Thank you!

• Mod
edited June 2013 Posts: 8,739

. @Jenny_Se See this program I wrote back in November.

http://twolivesleft.com/Codea/Talk/discussion/1874#Item_12

• Posts: 4

Thank you so much! That was really helpful! If you don't mind, can I ask you another question? How did you make the circles disappear and can they disappear faster as well?

• Mod
Posts: 8,739

In this section of code, I keep subtracting 1 from showLimit. If showLimit <=1, I stop drawing the circle else I draw the circle with the ellipse command. Each time you tap the circle in time, I draw another circle with the size 1 less than the previous one. So as you keep tapping the circles, they get smaller and you have less time to tap them. If you don't tap a circle in time, the game is over.

``````    if start then
if mainLoop==0 then
limit=limit-1
xc=math.random(limit,WIDTH-limit)
yc=math.random(limit,HEIGHT-limit)
showLimit=limit
mainLoop=100
else
mainLoop=mainLoop-1
if  showLimit<=1 then
if xc~=-100 then
highScore=true
start=false
end
else
showLimit=showLimit-1
stroke(0,255,0)
strokeWidth(2)
noFill()
ellipse(xc,yc,limit*2,limit*2)
fill(0,255,0)
strokeWidth(0)
ellipse(xc,yc,showLimit*2,showLimit*2)
end
end
end

``````
• edited June 2013 Posts: 4

Thank you! You were really helpful!!

• Mod
edited June 2013 Posts: 8,739

.@Jenny_Se Here is a simpler version. Maybe this will help more.

``````displayMode(FULLSCREEN)

function setup()
hit=0
missed=0
createCircle()
end

function draw()
background(40, 40, 50)
fontSize(40)
fill(255)
else
createCircle()
missed = missed + 1
end
str=string.format("Hit  %d     Missed  %d",hit,missed)
text(str,WIDTH/2,HEIGHT-50)
text("Try to hit the circle",WIDTH/2,HEIGHT-100)
end

function touched(t)
if t.state==BEGAN then
createCircle()
hit = hit + 1
end
end
end

function createCircle()