Stuck at some logic/math regarding card game.

Greetings to the great community of gamesalad! I have been searching the forums for information regarding my problem this past days but to no avail.

I am making a card match memory game and im stuck in the logic(and some script/math). I bought tshirtbooths #2 template and it was great but i kinda lost him when it came to some points.

Firstly, i would like to know if its possible to create a game with multiple actors as the cards and no tables.

Secondly, i am stuck at the card flip part of it. I want to understand how to make the card display its "back" and not the icon when playing. I want it to show the "back of the card" and upon clicking, flip and show the icon/value.

Tshirtbooths template is great, but i just lost him when it came to the flipping of actor and the display of the "cardback".

I appreciate any kind of help, either logic or math :)! Thank you in advance.
-Jason

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Firstly, i would like to know if its possible to create a game with multiple actors as the cards and no tables.
    Sure:

    When Touch is Pressed
    .....When [attribute] game.CardsSelected=0
    ..........Change Attribute game.FirstSelectedCard (text) to self.Name [or some other unique attribute such as self.Image if you prefer]
    ..........Change Attribute game.CardsSelected to game.CardsSelected+1
    .....When [attribute] game.CardsSelected=1
    ..........Change Attribute game.SecondSelectedCard to self.Name
    ..........Change Attribute game.CardsSelected to game.CardsSelected+1

    When [attribute] game.CardsSelected=2
    .....When [attribute] game.FirstSelectedCard=game.SecondSelectedCard
    .....[it's a match!]
    .....Otherwise
    ..........[nope!]

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • OptimisticMindOptimisticMind Member Posts: 4
    Thats great! Very helpful :)! Now that you pointed it out, it seems logical and easy!

    If im not asking much, and if i do please excuse me, how can i get the cards to display passively their "back" and upon flip! In tshirtbooths template, he used "change attribute self.image to " but when i do that, nothing happens.

    Thanks! ^^
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    When you use Change Attribute self.Image to ______, the name you type in must exactly match an image in your library (e.g. if you have an image called Card1Back.png, then you would type in Card1Back.

    I haven't used that template so I can't really comment on it, but if you want to post the rules you're trying I can see if I can help further.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822
    @OptimisticMind
    how can i get the cards to display passively their "back" and upon flip!
    Just interpolate the card horizontally, change image to the reverse side, then interpolate the card back to its original horizontal width . . .

    . . . hold on, let me do you a quick demo:

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    EDIT / !!
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    Here you go, either click on a card or swipe your mouse across them:

    http://www.mediafire.com/?z96j44l2299926k
  • OptimisticMindOptimisticMind Member Posts: 4
    Firstly, i would like to know if its possible to create a game with multiple actors as the cards and no tables.
    Sure:

    When Touch is Pressed
    .....When [attribute] game.CardsSelected=0
    ..........Change Attribute game.FirstSelectedCard (text) to self.Name [or some other unique attribute such as self.Image if you prefer]
    ..........Change Attribute game.CardsSelected to game.CardsSelected+1
    .....When [attribute] game.CardsSelected=1
    ..........Change Attribute game.SecondSelectedCard to self.Name
    ..........Change Attribute game.CardsSelected to game.CardsSelected+1

    When [attribute] game.CardsSelected=2
    .....When [attribute] game.FirstSelectedCard=game.SecondSelectedCard
    .....[it's a match!]
    .....Otherwise
    ..........[nope!]

    This should be in an actor which involves the general rules and not in each actor right?
  • OptimisticMindOptimisticMind Member Posts: 4
    edited February 2013
    Here you go, either click on a card or swipe your mouse across them:

    http://www.mediafire.com/?z96j44l2299926k
    Its great! Works fantastically well :). The done boolean is to specify if the card is turned or not right? Also, how did you change the image? I see the change self image to 1-self.image.
  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    Its great! Works fantastically well :). The done boolean is to specify if the card is turned or not right?
    Yeah, I threw it together without the 'done' switch, but it was flipping between sides really quickly, and other weirdness - so I thought it was best to check that the rule had run its course before allowing it to start again as it was re-triggering before it finished - not sure why, I didn't give it much thought, you can probably do a card flip like this dozens of different ways, this one was quick and dirty.

    Ultimately the only real reason the 'done' switch is there is because I wanted to be able to drag the mouse across the cards to flip them because it looked real pretty ! :o3
    Also, how did you change the image? I see the change self image to 1-self.image.
    Two images called '0' and '1'.

    self.image starts out as 1.

    1-self.image . . . translates as: 1-1 = 0

    self.image is now 0.

    1-0 = 1

    self.image is now 1.

    1-1 = 0

    self.image is now 0.

    1-0 = 1

    self.image is now 1.

    1-1 = 0

    self.image is now 0.

    1-0 = 1

    self.image is now 1.


    . . . . . etc, basically if you keep taking away 1 from the result of the sum '1-X' (and X starts as either 1 or 0) then it will go: 1010101010101010101010101 = card flip !! :)
  • OptimisticMindOptimisticMind Member Posts: 4
    Great :)! Yeah i saw the demo and its awesome! Ill constrain it to 2 at a time :)! Im currently fidgeting with what tatiang said about the actors.

    Made 1 actor with cherry and 1 with a clove with a display text behavior to confirm that its working properly but when i click on one of the two pics, all of the images display their text instead of just the two. Maybe its the text attribute where i store the selected cards's "image" because when i want to compare the two, i can only use "contain" (due to being a text attribute) Eg "change game.first selected card to self.image".

    Thanks socks :)! Great way to start my sunday haha!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @OptimisticMind the When Touch is Pressed rule goes in each actor (or once in a prototype for the actor if it's just a single actor). The other rule (When game.CardsSelected=2) could go in a "general" actor, yes. It also could go at the end of the When Touch is Pressed rule if you prefer.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here you go, either click on a card or swipe your mouse across them:

    http://www.mediafire.com/?z96j44l2299926k
    That is the best hand I have ever seen.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RatedPGRatedPG Member Posts: 7

    I am making a card match memory game... -Jason

    Hi Jason!

    Did you get to finish the Card Match Game you were making? I want to make one too for an event I'm planning but there's not a lot of tutorials on checking for matches, flipping cards and back, and pretty much everything needed to create such a game.

    I'd appreciate anything you can share on this.

    I could do copy/paste with templates, but learning the principle is much better.

    There is a saying that goes, "Give a man a fish and you feed him for a day, but teach him how to fish and you feed him for a lifetime."

Sign In or Register to comment.