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

Get help using Construct 2

Post » Sat Apr 23, 2016 4:08 pm

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.
B
24
S
7
Posts: 337
Reputation: 2,224

Post » Sat Apr 23, 2016 6:02 pm

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.
Mistakes were made.
B
55
S
28
G
115
Posts: 1,709
Reputation: 65,116

Post » Sat Apr 23, 2016 6:21 pm

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 :)
Image



Coming soon on Steam!
B
16
S
9
G
3
Posts: 209
Reputation: 3,476

Post » Sat Apr 23, 2016 6:55 pm

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

Image
Mistakes were made.
B
55
S
28
G
115
Posts: 1,709
Reputation: 65,116

Post » Mon Apr 25, 2016 12:57 pm

sudeep98 wrote:Image



Image

1Pic_1Word.capx

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

Image

dragLetters.capx

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

Image

drag2Swap.capx
B
67
S
24
G
7
Posts: 1,519
Reputation: 11,084

Post » Mon Apr 25, 2016 2:00 pm

korbaach wrote:
sudeep98 wrote:Image



Image

1Pic_1Word.capx

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

Image

dragLetters.capx

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

Image

drag2Swap.capx



Thanks!!!
Greats examples
B
43
S
12
G
3
Posts: 111
Reputation: 4,418

Post » Fri May 06, 2016 6:20 am

@korbaach Very helpful. Thank you so much. :D
B
24
S
7
Posts: 337
Reputation: 2,224


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests