Please help

I am planning on making a game which involves dropping things but when I tap on the screen to drop a meteor instead of dropping one it drops a continuous line. Is there any way to make just one meteor drop

function setup()

 x=400
 y=600
 speedY=-7

 end

-- This function gets called once every frame
function draw()

background(220, 174, 23, 255)



sprite("Tyrian Remastered:Boss A", 400, 300)

    end

    function touched (touch)
    x=touch.x
    y=touch.y

if touch.state == BEGAN then 
  
function draw()
    sprite("Space Art:Asteroid Large",x, y)
    y=y+speedY 

end
      end
           end

because you call the draw function once you touch the screen, don’t ever do this! you can’t exit the draw function! I know you’re here to learn, so please don’t see this as breaking your program down, but more like giving advice :wink:

this would be better

function setup()

 x=400
 y=600
 speedY=-7

 end

-- This function gets called once every frame
function draw()

background(220, 174, 23, 255)



sprite("Tyrian Remastered:Boss A", 400, 300)

    end

    function touched (touch)
    x=touch.x
    y=touch.y

end


--this is a function that gets called uppon touching the screen/moving your finger around
-- or when pulling finger off screen (the 3 states...)
function touched(touch)

    if touch.state == BEGAN then 

    sprite("Space Art:Asteroid Large",x, y)
    y=y+speedY 

    end

end

```

Tho this is not what you’re looking for, for it to drop a meteor, you need to make a class, that can create new objects, every time the screen gets touched, then you give that object physical properties, put all object in an array, and loop through them within the draw function

@newow Try this code.


displayMode(FULLSCREEN)
    
function setup()
    x=0
    y=-50
    speedY=-7
end

function draw()
    background(220, 174, 23, 255)
    sprite("Tyrian Remastered:Boss A", 400, 300)
    if y>-50 then
        sprite("Space Art:Asteroid Large",x, y)
        y=y+speedY
    end
end

function touched (touch)
    if touch.state==BEGAN and y<0 then
        x=touch.x
        y=touch.y
    end
end