collisions and restart

i need help to restatrt this code if the circle hit the ground the game should be restarted

gp=display.newGroup( )

qtde=20

vida = 3

local physics = require( “physics” )

physics.start();

physics.setDrawMode(“hybrid”)

local chao=display.newRect( display.contentCenterX, display.contentCenterY+260, 350, 50 )

physics.addBody(chao, “static”)

chao.myName =“chao”

local alvo=display.newRect( 20, display.contentCenterY+200, 30, 70 )

alvo:setFillColor (00, 0, 128)

alvo.myName =“alvo”

physics.addBody( alvo,“static”)

local function woodenblockAnimation()

local animUp = function()

transition.to(alvo, {gp, time=1000, x=295, onComplete=woodenblockAnimation })

end

transition.to(alvo, {gp, time=1000, x=20, onComplete=animUp })

end

woodenblockAnimation()

local rect=display.newRect( display.contentCenterX, display.contentCenterY-100, 120, 50 )

local function anm1()

local anm2 = function()

transition.to(rect, {gp, time=1000, math.random( display.contentWidth ), onComplete=anm1 })

end

transition.to(rect, { gp,time=1000, x=math.random( display.contentWidth ), onComplete=anm2 })

end

anm1()

local function tapListener( event )

local c=display.newCircle( 10, 10, 10, 10 )

c.x=rect.x

c.y=rect.y

c:setFillColor(255, 255, 0)

c.myName =“c”

physics.addBody( c, { density=1.0, friction=0.0, bounce=0.2, radius=10 } )

local function onLocalCollision( self, event )

print( “colidiu” )

  

  if event.phase == “began” then 

if event.target.myName == “c” and event.other.myName == “chao” then 

–local collidedText = display.newText( “Collided!”, display.contentCenterX, display.contentCenterY, native.systemFontBold, 20 )

display.remove( c,1 )

qtde=qtde-1

print( qtde )

if (qtde<=0) then

–display.remove(alvo )

–display.remove(chao )

–display.remove(rect )function scene:create( event )

  


  qtde=20

vida=3

local alvo=display.newRect( 20, display.contentCenterY+200, 30, 70 )

alvo:setFillColor (00, 0, 128)

alvo.myName =“alvo”

physics.addBody( alvo,“static”)

local function woodenblockAnimation()

local animUp = function()

transition.to(alvo, {gp, time=1000, x=295, onComplete=woodenblockAnimation })

end

transition.to(alvo, {gp, time=1000, x=20, onComplete=animUp })

end

woodenblockAnimation()

end

end

end

  

  if event.phase == “began” then 

if event.target.myName == “c” and event.other.myName == “alvo” then 

–local collidedText = display.newText( “Collided!alvo”, display.contentCenterX, display.contentCenterY, native.systemFontBold, 20 )

display.remove( c,1 )

–local att=1

vida=vida-1

if (vida==0) then

display.remove( alvo )

–physics.removeBody(alvo)

–transition.cancel( alvo )

–transition.cancel( )

end

print( vida )

end

end

end

c.collision = onLocalCollision

c:addEventListener( “collision” )

end

rect:addEventListener( “tap”, tapListener )

Please take note of Ed’s advice in your other thread - https://forums.coronalabs.com/topic/72472-code-minigame-to-exercise/ 

Please take note of Ed’s advice in your other thread - https://forums.coronalabs.com/topic/72472-code-minigame-to-exercise/