Generating a menu for trivia/flashcard type gameplay?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Generating a menu for trivia/flashcard type gameplay?

Post by sheamkennedy »

I've been learning Japanese and thought it may be interesting to make a flashcard style game in which a card is shown with a Japanese character and below it a menu is generated with 4 possible answer choices (one of which is the correct answer.

So for example a flashcard will display the character: �
Then a menu will display showing possible answers:
1) I
2) E
3) A <--- the correct answer will be somewhere in this generated menu (in a randomized menu slot)
4) O
Then once the player selects the correct answer a sound will play, or a bad sound if it's wrong...

What's the easiest way to go about doing this? I assume I will have to write out a list of all my flashcards in my code by number and maybe use an enemy battle picture to display them on screen. Then I will have to write out my list of possible answers and use tags to set whether or not the player has already "unlocked" these character (so as to increase the difficulty of the game as new characters are learned).
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

Interesting concept. I think I would use the slice editor for this

You could have all the answers stored and ranked by difficulty, just made non-visible if they are not being used.
You could use a grid slice with all the answers stored in it.
Then you have your potential answers to your question (including the right answer) jump to the front of their siblings.
To hide answers that are not being used, you could put it all in a slice that clips children.

Then the player presses a number key corresponding to options which are visible on the screen.

The extra data fields would be used like this:
0 - the identity of the answer
1 - whether it is the answer to the question or not
2 - the rank of the answer
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

This idea reminds me a bit of Kana Learning by Ysoft http://www.castleparadox.com/gamelist-d ... p?game=967

So how to shuffle a menu or some slices?

Suppose you have just created a menu with four items, and now you want to shuffle it up randomly:

Code: Select all

variable&#40;i, a, b&#41;
for&#40;i, 0, 50&#41; do&#40;
  a &#58;= menu item by true slot&#40;random&#40;0, 3&#41;&#41;
  b &#58;= menu item by true slot&#40;random&#40;0, 3&#41;&#41;
  swap menu items&#40;a, b&#41;
&#41;
The end result will be a very well-shuffled version of your menu.

How to know which is the correct answer in the menu? You could store that in the menu item extra data with the "set menu item extra" command. For example, you could leave extra slot 0 with the value 0 for the wrong answers and set it to 1 for the correct answer.

As for slices, making them children of a grid is a good idea. You could swap-shuffle them like the menu items, but it might be easier to give each answer-holder slice a random value with the "set sort order" command, and then call "sort children" on the parent grid.

Again, just like with menu items, storing a value in the slice extra data is probably the easiest way to track which holds the correct answer.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Thanks for the help, both.

Knowing about that Kana game will come in handy. That's similar to what I had in mind however I'd like to have something visually happening at the same time to mark the players progress. Maybe an animation that looks like a platforming game, or maybe a game with wanderlust-like gameplay where you discover new kana in chests hidden around an island and monster battles are replaced with answering kana flashcards. I'm not sure how I want to go about doing it yet.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

The "swap menu items" command is broken - it swaps the first menu items in the menu, ignoring the first argument. I never got around to fixing it. I just had another look, and it took me about 20 minutes to spot the simple typo. Sigh.
James' script will work regardless, because ironically it's a brute force method which only produces a 99.9% evenly shuffled menu and hence is more robust than an efficient algorithm to perfectly shuffle the menu items. Programmers always seem to get shuffling wrong - if only they were familiar with generators of the symmetric groups they'd know how to uniformly generate a permutation as a string of at most n-1 transpositions!
Last edited by TMC on Fri Apr 13, 2018 2:05 pm, edited 3 times in total.
Post Reply