Memory Card Game
darren.gregorio@gmail.com
Member Posts: 19
I am trying to make a memory card game, however I am very confused on how to do this. I searched online but there is no tutorial on how to make it, instead there were templates but I had to pay for them.
Can anyone make a simple tutorial or just explain to me on how to make this memory card game, at least just 2 type of cards. I want to know how to make two actors to destroy themselves if they match.
Comments
A super simple way to do it is as follows (you can probably combine these rules to make the logic tighter, but I think this should do the job and explains why it does the job).
In your cards have a self attribute called self.card. Use a text attribute. In each of the cards on your scene you'll need to type the type of the card into this attribute, making sure to use the EXACT same text on cards that match.
Create a global text attribute called global.card.
Create a second global attribute, an integer one called global.count
Then create a combination of rules that tell the game if it's been pressed, how many cards have been pressed and do they match the card that was already selected.
Give that a bash and see if it works for you
Thinking about it, you'll probably need to use some timers to make sure that the rules trigger correctly.
And it might just be simpler to have two global attributes. game.first_card and game.second_card.
When two cards have been pressed, if game.first_card = game.second_card destroy cards and reset count, else reset count
How do I do this? This is what I am actually confused about
"Then create a combination of rules that tell the game if it's been pressed, how many cards have been pressed and do they match the card that was already selected."
There's no need to make a new thread for each additional piece of information... just post in the original thread (this one) or edit your post using the gear button at the top-right of each post. Here's your question from your other thread:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
No need for a new attribute... just compare self.Image assuming your actors are using unique image names (e.g. orange.jpg, apple.jpg, lemon.jpg). But you'll need to store the two values somewhere:
When Touch is Pressed
When game.turnNumber=1
Change attribute game.firstCard to self.Image
Change attribute game.turnNumber to 2
Otherwise
Change attribute game.secondCard to self.Image
When attribute game.firstCard=game.secondCard
[match]
Otherwise
[no match]
Change attribute game.turnNumber to 1
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I might have a solution, but I made a new problem
This is what I have on one card:
When touch is pressed
Change Attribute game.turnNumber to game.turnNumber + 1
Change Attribute game.SelectedCard to game.SelectedCard + 1
When Attribute game.turnNumber = 2
When game.SelectedCard = 2
Destroy this actor
On the other side, I have another actor which acts like a resetter
so
When Attribute game.Select = 2
ChangeAttribute game.turnNumber = 0
ChangeAttribute game.SelectedCard = 0
This works pretty well until I previewed it
I placed the card beside each other like this
(A) (A)
These are the problems:
@imjustmike gave an elegant solution, which would cause no problems like this, why not try that?
Two game attributes for cards:
game.card_01
game.card_02
Also, a counter for how many cards are turned round.
game.turned_cards
Now, inside the card actor, make a self attribute:
self.card_ID
That is the type of card it is, what picture. There will be two of each ID, of course.
When you tap a card, do the following:
if: game.turned_cards < 1, change attribute: game.card_01 to: self.card_ID, AND change attribute: game.turned_cards to: game.turned_cards +1, OTHERWISE if: game.turned_cards < 2, change attribute: game.card_02 to: self.card_ID, AND change attribute: game.turned_cards to: game.turned_cards +1
Then a timer in a rule:
if: game.turned_cards = 2, after: 2 seconds, change attribute: game.card_01 to: 0, change attribute: game.card_02 to: 0, change attribute: game.turned_cards to: 0
Name your card images systematically: card_00.png for the back then card_01.png, card_02.png ... card_0X.png -- or card_000.png, card_001 etc., if you have more than 99 uniques card pictures.
Then, do a change image rule:
if: game.card_01 = self.card_ID or: game.card_02 = self.card_ID, change: self.image to: "card_"..padInt(self.card_ID,2)..".png", OTHERWISE: change: self.image to: "card_00.png"
Here, in the padInt, you put a 2 or a 3, depending on how many digits your image names have, as described earlier.