Jump to content

fill the gap game


chrpoulman
 Share

Recommended Posts

I want to build a fill the gap game. This mean that i have a text with some words missing. All the words are in a area and the user will be able to drag and drop the words in the text. If the word is in the right position then the user want be able to move it again. Is there any helpful demo to start?

Thank you in advance!!!

Link to comment
Share on other sites

I don't know of any demos, but my first thought on implementing something like this is to have 3 key elements. First would be the complete phrase as a single string. Second would be a string of the word that is suppose to be missing. Third would be a list of possible words to complete the phrase.

Displaying this would be easy enough. If you know what word is suppose to be missing from the phrase, then you can string.split() and pass the word as the delimiter. This will give you an array of either side of phrase.

 

Before split:

 

"This is my game phrase"

 

After split on 'my':

"This is "    " game phrase"

Then you just need to have 2 text fields to show either part of the phrase and a drop area in between. So when the player drops a word in the drop area, you can piece together the phrase and check if it's correct.

Example player drops "your" (which is wrong):

attempt = "This is " + dropWord + " game phrase"

Then just check if attempt === "This is my game phrase" and determine if the player won.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...