I’m writing a music education game that allows a student to place a flashcard with a musical note on it in the correct place on a drawing of a violin fingerboard. As the levels get harder I want to allow random flashcards to show up just as if I held those flashcards in my hand; specifically, once that flashcard is picked it won’t be picked again.
If this is something that needs to be done in JavaScript I need to know 2 things:
1.) how to add JavaScript to the Events
2.) where to hire a piecemeal programmer to write the JavaScript for me
This sounds like it’s best done using an array. Put a card identifier/name into the array. Randomise the array items - easiest way is to remove* one at random from it’s location in the array and add it to the end. Then remove* the card at the first position.
* = When an array element is removed, all the others after it will move forward a spot to fill the gap. Think of it like a stack of books, with the first position being the bottom of the stack. If you pull out a book from the within the stack, the rest that were on top of it drop down.
Not sure how do you do your flash cards, but it may be possible to use a group of objects, each one with a secuencial value. Select random object and use that value to create your flash card, then delete the object so its value is not used again.
Repeat any times it is needed.
(I used that code for the jigsaw part of my next try of game, to make the pieces appear in a random fashion)