Memory Card Game Problem

In my memory card game, there is always one pair without correct match. How to fix it?
For the hearts, it will deduct one live when pairs are not match, this is what i want but the animation will deduct two lives when it comes to the last two hearts (code is correct, deduct 1 life but animation wrong) how to fix it?

Can you share your project and post a link to it please

Is this an assignment or a personal project ?

1st thing I've noticed is this variable glitch - do you know how this happened?

image

(Ignore this for the moment - we can chat about this afterwards as it's not causing the problem with the game)

you can edit the code in it if u want to

it is shown like that after i delete one of the unwanted variable

this is an assignment that needed to hand in this thursday

In that case - add in a speak block
image

and you'll see that the CardIDs are not quite right

You are experiencing what is called a "race condition"

Can you come up with a method of overcoming the problem?

To be frank I have no idea how to solve this

That only happens when a variable (or block) has no name, like not even a space. The only way to get a variable with that name is by renaming it, and deleting all the text.

I can't give you the fixed code, but I can give you advice. A clone takes the value of a sprite local variable before it's cloned. For example, if you set a sprite local variable to 5, then create a clone, that clone will have the variable be set to 5. If you then change the variable in the sprite (not the clone), the variable in the clone will not change.

I hope you can figure out how to use this to solve your issue (hint, it removes race conditions)

I'll let you take over leading them to the answer :slight_smile:

I tried, but I failed. Maybe I'll try it later

Clump your posts up.
You can edit your posts and add new speech.

You literally just did what you were telling them not to do

Oh sorry.Did not read completely.

My problem. I tried to change the variable and ended up one more extra problem pair. But nvm thanks for the suggestions.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.