Spawns and Clones help?

Hello , If you have an object or sprite or shape , how do you make lot of clones of it so that shape, sprite or object appears in many random locations without copying the same code lots of times ??How do you make spawns of something ??

@ewan Try this. Tap the screen to spawn.


displayMode(FULLSCREEN)

function setup()   
    spawn() 
end

function draw()
    background(40, 40, 50)
    for a,b in pairs(tab) do
        sprite("Planet Cute:Character Boy",b.x,b.y,50)
    end
    fill(255)
    text("tap screen to spawn again",WIDTH/2,HEIGHT/2)
end

function spawn()
    tab={}
    for a=1,100 do
        table.insert(tab,vec2(math.random(WIDTH),math.random(HEIGHT)))
    end
end

function touched(t)
    if t.state==BEGAN then
        spawn()
    end
end

@ewan - think of objects in Codea like those rubber stamps you use to dip in ink and press on the paper, as a kid. You can use one stamp as many times as you like.

Similarly in Codea, you can draw the same sprite in many different places on the screen.

It is not like normal software where a sprite can only be in one place on the screen. The Codea screen is just a bunch of pixels, and objects are drawn on it, but they don’t live on the screen.