Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Plz help a N00b out (flashcard generator)

Discussion in 'General Discussion' started by amandathorp, Feb 5, 2021.

  1. amandathorp

    amandathorp

    Joined:
    Nov 25, 2020
    Posts:
    8
    How would I make a customizable random flashcard generator? I want the user to be able to pick and choose which set(s) of flashcards are activated when they click the deck. Any ideas are appreciated!
     
  2. aer0ace

    aer0ace

    Joined:
    May 11, 2012
    Posts:
    1,511
    First, I'd forget about the customizable, and just get the flashcard generator working first with ONE set of flashcards. That's the core "game" mechanic. Once you have that established, you can then add multiple sets of flashcards, then add functionality to select and activate a set. Adding customizability becomes another layer on top of the core mechanic.

    I know I just blurted out a specific order to work on things, but you have to break down the work before you establish how those individual tasks are implemented. Then, there's plenty of material in learn.unity.com to accomplish each of those steps in one way or another, or you would ask more questions on the forums for those specific tasks to get specific answers for them. Otherwise, the description is far too broad, and one developer will have an idea how to make something that another developer will have a different vision for.
     
    angrypenguin and amandathorp like this.
  3. amandathorp

    amandathorp

    Joined:
    Nov 25, 2020
    Posts:
    8
    Thank you so much!
     
  4. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Make a List<Image>flashCardSet; of the faces of the flash cards. You only need one card back.
    Assuming you consume the deck so that you do not get repetitions and want a random order create a second List<Image> shuffledDeck; then iterate through the first list using a (int)Random.Range(0, flashCardSet.Count-1) to select random indexes of the set and shuffledDeck.Add( flashCardSet[randomIndex] ) to the List and lashCardSet.Remove(flashCardSet[randomIndex] ) it from the flashCardSet List<Image>. Make a button to cover the face down deck. Each time the button is clicked send that event to a function that selects that shuffledCard[index] and inserts the image into an Image holder to show and then increments the index value by one. When you have used all cards from that set then copy the List back to the now empty flashCardSet List and do it all over again. You can create any number of flashCardSets and copy them into the shuffledDeck. If there are correlated answers then create a matching indexed List<sting> for each set of cards.
     
    amandathorp likes this.
  5. amandathorp

    amandathorp

    Joined:
    Nov 25, 2020
    Posts:
    8
    Thank you for your expertise-I had to read through this many times but this is what I got:

    2 image lists: one for the flashcard faces and one for the SHUFFLED flashcard faces
    1 card back
    function to select random indexes of the flashcard face set
    function to add these random indexes to the shuffled deck
    function to delete the used random indexes from flashcard face deck
    button covering card back
    function on button click to insert image holder for random index images
    function to increase the selected index value by 1
    ? function to copy the whole thing over again?
    correlated answer list for each set of flashcard face sets

    I'm rephrasing what you wrote in an effort to understand it better. Please let me know if I am mistaken on any of those components...
     
  6. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Yes.
    Yes.. Except you insert the image into an image holder..
    imageHolder.image = shuffledDeck[randomIndex];
    You copy the List back when you consume the shuffled deck. That way you have the card set and that is now full and initialize the shuffledDeck List so it is empty when redoing the routine.
     
    amandathorp likes this.
  7. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Sometimes flashcards need two sides e.g. Question / Answer flashcards for driving tests.
     
    amandathorp and MadeFromPolygons like this.
  8. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,793
    Correlated answers can handle this by changing List<string> or List<int> etc. to an Image List. Then determine the mechanic that drives the input of the users answer and find a way to determine if there is a correct or incorrect answer. Most probably a string or number list, though it may be a choice of visual symbols.
     
    amandathorp likes this.