random flipping of cards

patricia.bradypatricia.brady Member, PRO Posts: 49

Hello,

I'm working with the Memory Match V2 template from Tshirbooth and would much appreciate your assistance.

Once the cards have been dealt (e.g., 16 cards (4x4) visible with cardback), I'd like each card to flip to front side of the card (e.g., diamond, heart etc..) for 0.2 secs and then back to cardback. This should happen consecutively for all 16 in a random order until all 16 cards have been visible individually and the game then reverts to 16 cardbacks ready for the next stage.

Grateful for your help.

Patricia

Comments

  • patricia.bradypatricia.brady Member, PRO Posts: 49

    Grateful for assistance or any advise on how to get assistance.

    Thank you

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Normally I'd suggest contacting the developer of the template but Tshirtbooth has been gone for a long time so that is probably not an option. You're next best bet would be to hope that someone who has used it extensively sees this post but I'm afraid I've never used it.

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    Try this in the cardback prototype:

    Timer [after] [.5] seconds
      Timer [after] [(self.what card am i)*.25] seconds
        Change Attribute [self.flip] to [true]
        Timer [after] [.2] seconds
          Change Attribute [(self.flip)] to [false]
    
  • patricia.bradypatricia.brady Member, PRO Posts: 49

    So very appreciated RThurman!!!

    Do you know if there's a way to disable the touch function when the cards are flipping?
    I'd like all the card to have flipped before the player can start flipping.

    Thank you,

    Patricia

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2018

    Try this:

    [Make an attribute of type real called game.timeStart]

    When attribute self.what card am i is 1 [this rule might have to go inside another... not sure how you decide to start the flipping mechanism]
         Change attribute game.timeStart to game.Time

    When touch is pressed AND game.Time > game.timeStart + 0.5 + 16*(0.25+0.2)
         [touch behaviors]

    I think I have the math right... just added it from what @RThurman posted above but you can adjust as needed if it starts too early/late.

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

  • patricia.bradypatricia.brady Member, PRO Posts: 49

    Hi Tatiang,

    I've tried to incorporate your suggestion, but cannot get it to work unfortunately.
    Is there another way?

    Thank you,

    Patricia

  • patricia.bradypatricia.brady Member, PRO Posts: 49

    Hi, got it to work using a timer to activate boolean [touchactivated].

  • patricia.bradypatricia.brady Member, PRO Posts: 49

    @RThurman said:
    Try this in the cardback prototype:

    Timer [after] [.5] seconds
      Timer [after] [(self.what card am i)*.25] seconds
        Change Attribute [self.flip] to [true]
        Timer [after] [.2] seconds
          Change Attribute [(self.flip)] to [false]
    

    Is it possible to do this using self.time rather than timer behaviour?

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    I have not tested it, but this should work:

    Make a self attribute (type = real) called self.startTime

    Change Attribute [self.startTime] to [self.time]
    
    When [self.time] > [(self.startTime + (self.what card am i)*.25) + .5]
         Change Attribute [self.flip] to [true]
    When [self.time] > [(self.startTime + (self.what card am i)*.25) + .5 +.2]
         Change Attribute [self.flip] to [false]
    
  • patricia.bradypatricia.brady Member, PRO Posts: 49

    @RThurman said:
    I have not tested it, but this should work:

    Make a self attribute (type = real) called self.startTime

    Change Attribute [self.startTime] to [self.time]
    
    When [self.time] > [(self.startTime + (self.what card am i)*.25) + .5]
         Change Attribute [self.flip] to [true]
    When [self.time] > [(self.startTime + (self.what card am i)*.25) + .5 +.2]
         Change Attribute [self.flip] to [false]
    

    Making the seemingly impossible, possible, with such ease!! So very grateful, thank you @RThurman !!!

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    You are welcome!

Sign In or Register to comment.