How would I add text in a circle and also shuffle my questions?

Viewed 66

Link to code for reference: https://editor.p5js.org/tpant963/sketches/Ft9fBLlRU

Hi! So I've been trying to make a review game on Java OOP concepts on p5.js, but I'm beginning to get a bit overwhelmed because this is my very first p5.js project. How the game works is that there is a question printed on the screen with bubbles floating around that are supposed to have word associations on them. If the correct bubble is clicked then it will turn green and if it is incorrect, it will turn red. The round ends when all the correct bubbles are clicked.

My first problem is that I can't make the text appear on the bubbles. I tried doing it like this (using the correct array as an example) but it resulted in my bubbles and text one the screen getting very messed up, not to mention, the text never showed up.

textAlign(CENTER, CENTER);
    for (let i = 0; i < correct.length; i++) {
    ellipse(correct[i].x, correct[i].y, 
            correct[i].r, correct[i].r);
    textSize(correct[i].r);
    text(correct[i].q1C, correct[i].x, correct[i].y);   }

My second issue lies in the fact that I'm unsure of how to shuffle the questions and keep the game going until all the questions are done.

Thanks!

1 Answers

Well, for the shuffling you could use the built in p5.js function:

shuffle(Arr)

and then just keep count of how many questions you have:

let questionCount

function newQuestion(){
questionCount++
questionArr[questionCount]
}

or something close to that; haven't looked thru your project all that much

Related