How do I make a typing game using construct 2

0 favourites
  • 9 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I am trying to make this game that feels a little like the typing maniac game on Facebook a long long time ago. Basically the words will be falling from the top of the screen and the player has to type in the letters in sequence to sort of clear the words. My question will sound very dumb but how do I let the game detect the player text input. Like I don't know how to make it possible for the player to type text in a text box..... After I do that do I compare the player text input with the instance variable on the object or...? Thanks in advance for helping!

  • Keyboard has an "OnAnyKeyPressed" event. Note that this returns a thing called a key code, which isn't the same as a string ; it provides a "String from Key code" function to give you a string.

  • Sorry I'm super new to all this but after getting the text, how do I compare the string that I get to the variable on the text? And when I don't know how to backspace the letters that are typed wrongly...

    Thanks for the help!

  • just a thought... TypingGame.capx

  • Well, the word you are typing in will have two variables. One is the actual word itself "elephant" (say), the other is the position in the word you are currently at , 4 (say).

    This means you want the fourth letter of elephant (the 'p') which you can compare against the letter that you have typed or clicked on.

    Note, unlike many BASIC type languages, the mid function counts from zero, so mid("elephant",4,1) is "h" *not* "p" as you might expect (e.g. "e" is index 0,"l" index 1 and so on)

  • guys i'm trying to make a typing game based on the typinggame.capx provided here by korbaach. but 2 problems for me there:

    • first, i would like to have every sprite letters disappear one bye one (in the correct order!) if i press the exact key.

    because i'm a noob with construct the only expression or formula i managed to find here is to compare the key pressed with "Keyboard.StringFromKeyCode(Keyboard.LastKeyCode)"

    and "uppercase(left(txtWord.Text,1))" with the action: destroy sprite.

    so with A pressed (conditions: animation frame = 0, and sprite visible on screen) the word "arachnids" will become "rchnids"

    so it does take off the first letter but also all A from word <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad" /> plus if i continue and press R it will not disappear. i tried to add conditions

    "uppercase(left(txtWord.Text,1))"=/= "uppercase(left(txtWord.Text,2))" ...text,3 text,4 etc with no succes. it becomes complicated for me...

    • second, if i make a mistake and press b for example nothing happens and if it's a very long sentence i will see the error way too late.

    i took the same formula above with action: sound+ right(SpriteFont.Text,len(SpriteFont.Text)-1) to erase the wrong key pressed

    but again it works perfectly for first letters but i don't know how to do it for the rest of the word.

    it would be nice of you all if you could give me some hints. thanks

    hope i didn't choose the worst method possible :p

    ps: i don't know if i can allready put links, it's my very first post so.

    "https://imgur.com/a/8z0dA"

    the modified capx: ufile.io/d0o5b "https://ufile.io/d0o5b"

  • Hey maxGfive!

    I adjusted the capx for you. Check the bookmarked block.

    https://www.dropbox.com/s/vrv5e2h7v6tro ... .capx?dl=0

    Hope it helps. Cheers!

  • just incredible, i could NEVER figure it out even a little ^^

    thank you soooo much.

    you rock bruno

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad to help, man! Good luck on your project!

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