How to make this variable

Get help using Construct 2

Post » Sat Feb 07, 2015 10:22 pm

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,

slika1.jpg


and here is a photo of my Event sheet

slika2.jpg


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
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 7
Reputation: 189

Post » Sun Feb 08, 2015 1:00 am

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.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Feb 08, 2015 1:41 am

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.
B
41
S
20
G
30
Posts: 681
Reputation: 19,683

Post » Sun Feb 08, 2015 8:30 am

codah wrote: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 :)
B
3
Posts: 7
Reputation: 189

Post » Sun Feb 08, 2015 8:46 am

rekjl wrote: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 :) I used same sprite for all the white keys and when I sow that I know how to do that and learned -- I instantly wanted to see will I be able to make something more complicated and without watching in tutorial, ..and I made it :)
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 :)
B
3
Posts: 7
Reputation: 189

Post » Sun Feb 08, 2015 11:25 am

No problem maxer006. Best of luck!
B
41
S
20
G
30
Posts: 681
Reputation: 19,683

Post » Sun Feb 08, 2015 1:23 pm

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
Piano1.capx
You do not have the required permissions to view the files attached to this post.
B
3
Posts: 7
Reputation: 189

Post » Sun Feb 08, 2015 2:11 pm

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.
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,610


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests