Image Quiz

Hi,

I’m trying to create a quiz where there is an image on the screen and multiple options to choose from (see image attached). I have been able to code the questions for one image but cannot work out how to create multiple images?

Very much a beginner, any help appreciated!

@toby The easiest way to do what you want is to use a table to hold your questions. If you don’t understand tables, I suggest you look into how they’re used because you will use them extensively. The table can hold each individual picture and the questions that go with it.

@toby I’m not sure exactly what you’re going to do, but here a simple example of showing multiple images with questions. Of course there’s a lot more that needs to be done, but this will give you an idea of where to start.

EDIT: Added code to tap a specific spot for next image/questions and also to tap specific question area.

function setup()
    tab={}
    tab[1]={"Planet Cute:Character Horn Girl","question 1 a","question 2 a"}
    tab[2]={"Planet Cute:Character Pink Girl","question 1 b","question 2 b"}
    tab[3]={"Planet Cute:Character Boy","question 1 c","question 2 c"}
    tab[4]={"Planet Cute:Character Cat Girl","question 1 d","question 2 d"}
    tab[5]={"Planet Cute:Character Princess Girl","question 1 e","question 2 e"}
    offset=1
end

function draw()
    background(40, 40, 50)
    fill(255)
    text("Tap HERE for next image/questions.",WIDTH/2,HEIGHT-100)
    for a,b in pairs(tab[offset]) do
        if a==1 then
            sprite(tab[offset][1],WIDTH/2,HEIGHT/2)
        else
            text(tab[offset][a],WIDTH/2,HEIGHT/2-a*50)
        end
    end
end

function touched(t)
    if t.state==BEGAN then
        if t.y>HEIGHT-125 and t.y<HEIGHT-75 then
            offset=offset+1
            if offset>#tab then
                offset=1
            end
        end
        for z=2,#tab[offset] do
            if t.y>HEIGHT/2-25-z*50 and t.y<HEIGHT/2+25-z*50 then
                quest=z-1
                print("Question selected "..quest)
            end
        end
    end
end