Random photos code

Pleas i want a code to help me take a random pictures to play on it

Random photo code

Put all the possible filenames in a table photos = {“photo1”,“photo2”,“photo3”} then do a idx =math.random(1,#photos) then display photos[idx]

Pleas i wnat eazy code the code dosnot run

I’m not going to code it for you simply because I don’t know how to, not to mention I have no idea what you’re saying.

Could you please explain a little bit more what you’re saying and try to correct your English because it’s hard to read what you’re saying.

Also note, that most people will help you in the right direction, not just code it straight up for you.

I dosnt talk with you

Can you explian for me how to make a random photos code

I just did, give it a go yourself and I’ll help if you get stuck.

This is what @Briarfox meant @Mohammad_abumoosa. Try this code. Hope you understand it


--# Main
function setup()
    photo = {}
    photo[1] = readImage("Cargo Bot:Cargo Bot Title")
    photo[2] = readImage("Planet Cute:Character Boy")
    photo[3] = readImage("Platformer Art:Guy Look Right")
    photo[4] = readImage("Small World:Beam")
    photo[5] = readImage("Space Art:Icon")
    photo[6] = readImage("SpaceCute:Beetle Ship")
    photo[7] = readImage("Tyrian Remastered:Rock Boss Right")
    t = 120
    i = 1
    previousi = 1
end

function draw()
    background(255, 255, 255, 255)
    t = t-1
    if t==0 then
        i = math.random(1,7)
        if i==previousi then t=1 else
            t = 120
            previousi = i
        end
    end
    sprite(photo[i],WIDTH/2,HEIGHT/2)
end