0 Favourites

How do I create a list of letters for a word?

  • Hi,

    I'm developing a web-based game, in that an user (student) has to identify missing letters of a word. Initially, an user (a teacher) will insert few words then the game has to display the word provided by the teacher on the screen by missing few letters. Student has to identify the word and fill the gaps by dragging letters provided on the bottom of the screen.

    I'm not able to understand how to split the letters of a word inserted by a teacher and make them appear on the screen with missing few letters.

    For example, a teacher inserts a word 'HAPPY' then the game moves to the next screen where the student can see only few letters like H_ _P_. Student will fill the gaps by dragging the letters provided on the bottom of the screen. I'm not sure how to make the game to identify the letters of the word and display only few letters in it.

    https://www.dropbox.com/s/v8ilh07jj80dnb3/Screenshot%202016-04-23%2021.24.31.png?dl=0

    Please help.

    Thanks.

  • This one is a little bit tricky. Everything you need to manipulate individual characters in a string can be found in the text section of system expressions.

    https://www.scirra.com/manual/126/system-expressions

    You need each individual character of a word. The logic would go something like this:

    Get the first letter of your word with left(word,1). You'll want to store that in a manner of your choosing, but I recommend pushing it into an array.

    Then you need to take that letter out of the original word by setting text to right(word,len(word)-1). This means to set the text to the rightmost characters of the word length minus one.

    Repeat until your word has no more letters (conditions- WHILE, len(word)>0).Now you have all the letters of your word individually in order in an array to work with.

    Try working with that and ask again of you don't know how to proceed, as displaying the word again in pieces that can be manipulated and multiplayer are pretty complicated too.

  • That's one way to do it! Or you could use mid() to pull out one character at a time to the array by just doing

    2 variables: whatWord, whatIndex (initial value 0)

    array, for each X element: set value to mid(whatWord, whatIndex, 1), add 1 to whatIndex

    Haven't tested but that's what I'd try. Then all you have to do is pull whichever letters out of the array however you want the game logic to work

  • I didn't even notice that expression! That is a much better solution: all done with one event.

  • 1Pic_1Word.capx

    ..............................................................................................................................................................................

    dragLetters.capx

    ................................................................................................................................................................................

    drag2Swap.capx

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • >

    >

    1Pic_1Word.capx

    ..............................................................................................................................................................................

    dragLetters.capx

    ................................................................................................................................................................................

    drag2Swap.capx

    Thanks!!!

    Greats examples

  • korbaach Very helpful. Thank you so much.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)