I’d like to make a vocabulary game with the merge cube. For that I need a random number (which is in that case a random word). However, each number (or word) should only appear once and not a second time. Unfortunately, I am pretty stuck and some help would be greatly appreciated
Here’s the link to what I did. It is just a basic construction. The red word on floating panels are the words which the student has to find on the cube (which is also red but this is just done for testing matters)
you can generate array of numbers, that represents your questions, and then shuffle it. So you will have a random order and every question appear once.
//number of your questions
let N = 5;
//create an array
for (var ar=[],i=0;i<N;++i) ar[i]=i;
//shuffle it
for (var i = N - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
//now the array has numbers from 0 to N in a random order
The num variable stores the quantity of objects (questions in your project).
The object variable is a list of them.
I created additional list - listNum with numbers from 0 to (num - 1) and shuffle it.
Last repeat block takes the objects from the object variable in a random order (according to listNum) and move them forward.
Something really weird happened. I wanted to take the items in 5 second intervals from the list. When I used the greyed out timer, all worked. When I used the active timer with the loop this happens:
Let’s assume a random list with 5,3,2,1,0 got generated
The man says the first item in the list, in this case 0. Then nothing. When I use the greyed out timer, the man says every second the following item taken from the list. Is this bug?
The problem is, I need an interruptable timer because when a student clicks on the correct answer within the given time, the timer needs to reset and the student should get a score