How to make this variable

0 favourites
  • 8 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I already have asked similar question, and I hope that someone can help again.

    I made piano pattern which player need to repeat it.. if a player succeed in that..I have implemented text which say Good Job,

    [attachment=0:sdqjf36b][/attachment:sdqjf36b]

    and here is a photo of my Event sheet

    [attachment=1:sdqjf36b][/attachment:sdqjf36b]

    but now I wish to make variable where player make mistake, but I don't wish to write every single combination in which he can mistake...can someone help me and tell me how to write variable which will instantly recognize wrong input and start game from beginning.

    And one more thing If I don't asking to much...I would like to implement variable where will player receive a new sequence of tunes when he remember and repeat the first sequence.

    I hope that I don't ask to much!!

    Thanks

  • Do you have the full licence? Sorry it's off topic. I guess you don't or you could use a Family and more than halve those events.

  • There is a way for you to do it much simpler. First of all, use the same sprite for all the white keys, and also just one sprite for all the black keys.

    That way, when you want to compare if the player has clicked on the correct key you can just check with the UID. Also, this example takes that animation frame0 is the original and frame1 is the image of it being played in the replay and frame2 is the image for when the player has clicked on the key.

    WhiteKeySprite frame = 1--->set varkey = WhiteKeySprite.UID

    Mouse on left clicked WhiteKeySprite-->whiteKeySprite set frame to 2

    subevent

    Pick WhiteKeySprite with UID = varkey

    subevent

    WhiteKeySprite frame =2--> do your actions since for the correct key pressed

    Else--> do your actions for wrong key pressed

    As for a sequences, you can do that with arrays. It will be perfect for your situation, so if you are not familiar with it, now is a great time to start learning about it.

  • Do you have the full licence? Sorry it's off topic. I guess you don't or you could use a Family and more than halve those events.

    No, and don't worry about asking it is totally fine to ask, and I am sorry, I don't have full license! only this free version. First of all I wish to see am I able to work at all with this program and to learn it how to make some basic things, like this one with piano. What is the purpose of buying a license and to drop it after couple of weeks when you see that you are not able to overcome some basic problems, if I see that I learn good and easy, I 'll be more than happy to buy full version of this software. and I guess that is why scirra gave a free version of this software

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a way for you to do it much simpler. First of all, use the same sprite for all the white keys, and also just one sprite for all the black keys.

    That way, when you want to compare if the player has clicked on the correct key you can just check with the UID. Also, this example takes that animation frame0 is the original and frame1 is the image of it being played in the replay and frame2 is the image for when the player has clicked on the key.

    WhiteKeySprite frame = 1--->set varkey = WhiteKeySprite.UID

    Mouse on left clicked WhiteKeySprite-->whiteKeySprite set frame to 2

    subevent

    Pick WhiteKeySprite with UID = varkey

    subevent

    WhiteKeySprite frame =2--> do your actions since for the correct key pressed

    Else--> do your actions for wrong key pressed

    As for a sequences, you can do that with arrays. It will be perfect for your situation, so if you are not familiar with it, now is a great time to start learning about it.

    Rekjl,

    Thank you so much on your time and effort to help me out, that is how I made my first piano

    but I totally understand your point.

    I will give my best to apply your example on my project...and soon as I do that I will come back to show what I did and maybe to ask something more

    Thank you very much for your help

  • No problem maxer006. Best of luck!

  • I' am so sorry, and I am totally beginner .....I am totally confused now and stuck...

    I will attach my file here, and if you can show me on my example, how do I need to do that...I have no similar tutorial which I can look on, so I have to ask for a little help on my example.

    About arrays....that is totally strange for me, and I don't even know what those guys on tutorials even talking about...for me totaly confusing

    this is my file: if you can look it and show me!!

    if I ask to much, I apologize

    [attachment=0:p63n03qq][/attachment:p63n03qq]

  • I'll try to explain how I would do it...

    You make all the piano keys instances of the same sprite with an instance variable note to store the name of the note.

    Then you have two variables: solution to store the answer and input to store the player input.

    So at the start you set solution to a random sequence of notes.

    solution = "cdecd"

    When the player clicks a key then you add its note value to the input string.

    Say the player clicks the c key:

    input = "c"

    Using the text expressions: len(text) and left(text, count) you compare the input to the solution.

    The length of the input is 1 so you compare it to the first character of the solution.

    Then the player clicks "d". You add that to the input so the input is now "cd" - length 2. Compare to the first two characters of the solution.

    Keep going until the input is the same length as the solution and it matches.

    If at any point the input doesn't match the first n characters of the solution then they have clicked the wrong key.

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