Hi everyone,
I am trying to design a memory game. Basically, I have two of each animals on a grid, and a user is supposed to find paired animals by opening boxes.
Right now, I have it set up so that when a user clicks on a field, the sprite changes a costume (to that of a cat, for example), broadcasts a message ("cat") meant to be received by the paired sprite, waits for 1 second, and then changes costume back to a green square. My idea was to set it up so that, when revealed, cat1 communicates to cat 2, and if the user clicks on a field corresponding to cat2, that mouse click will cause both cats to be revealed and remain like that on the screen.
The issue was that in the script for cat1, I cannot find a way to represent mouse click on cat2 (or any other sprite) as an event.
For cat2, I tried to write a script that goes something like this:
if message "cat'' received and if mouse click on cat2,
then change costume of cat1 and cat2 to reveal original cat costume.....
I hope I explained well enough what the issue is. Is there a way to fix this? Is there a different way to approach the whole design of this game?
I would appreciate all thoughts. Thanks so much,
L
Offline
This is just an idea, so sorry if it doesn't make sense but...
What if you created a variable for each pair of sprites, incremented it by 1 after it's been clicked, and set it back to 0 after 5 seconds? If the variable is 2, than you have a match.
For example:
when gf clicked set [cat_clicks v] to (0) forever if < (cat_clicks) = [2] > broadcast [Cat Match Found! v] end when I receive [Cat Clicked v] change [cat_clicks v] by (1) wait (5) secs set [cat_clicks v] to (0) when [cat1] clicked broadcast [Cat Clicked v] when [cat2] clicked broadcast [Cat Clicked v]I'm not 100% sure this would work, but it is something to give a try. If you have lots of sprite pairs you could try a list instead of a bunch of variables.
Offline
Hi scmb1,
Thanks so much for your response -- I did something along the lines of what you had suggested and it worked. Here is the game:
http://scratch.mit.edu/projects/luthien/3007985
The only issue I could not work out was how to randomly change the positions of each piece after the game is over and the new game is begun.
I would love to hear any suggestions.
Thanks so much,
L
Offline
luthien wrote:
Hi everyone,
I am trying to design a memory game. Basically, I have two of each animals on a grid, and a user is supposed to find paired animals by opening boxes.
Right now, I have it set up so that when a user clicks on a field, the sprite changes a costume (to that of a cat, for example), broadcasts a message ("cat") meant to be received by the paired sprite, waits for 1 second, and then changes costume back to a green square. My idea was to set it up so that, when revealed, cat1 communicates to cat 2, and if the user clicks on a field corresponding to cat2, that mouse click will cause both cats to be revealed and remain like that on the screen.
The issue was that in the script for cat1, I cannot find a way to represent mouse click on cat2 (or any other sprite) as an event.
For cat2, I tried to write a script that goes something like this:
if message "cat'' received and if mouse click on cat2,
then change costume of cat1 and cat2 to reveal original cat costume.....
I hope I explained well enough what the issue is. Is there a way to fix this? Is there a different way to approach the whole design of this game?
I would appreciate all thoughts. Thanks so much,
L
Personally i would use Call statements to allow communication between sprites. I scratch this would be using the broadcasting block so when 1 sprite is ready it can broadcast "ready" then when the other sprite receives "ready" it can then carry one. Hope this helped!
Offline