GameSalad

Smartest way to do this?

BigDaveBigDave Posts: 2,093Member, PRO
edited March 2 in Working with GS (Mac)

for a memory mini game I want to create random sequences which the player has to re-created with his 4 buttons

Button 1,2,3,4

And a randomly created sequence could look like this

2,1,2,4,3

So i wonder whats the smartest way to create that.
Checking if the play does use the buttons in the correct order.

Comments

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,745Member, Sous Chef, PRO, Bowlboy Sidekick

    Not sure I understand correctly, but I'll try and answer anyway. What you could do is hold the answer in a table, and write the button integer values to a separate table as the player pressed the button. Afterwards, you can use the Table Merge function and then compare the results. If they're the same, then they entered the correct sequence. If not, then they didn't.

  • Braydon_SFXBraydon_SFX Dallas, TexasPosts: 8,745Member, Sous Chef, PRO, Bowlboy Sidekick

    You could obviously do this all in one table, but for clarity I said you could separate it. :)

  • BigDaveBigDave Posts: 2,093Member, PRO

    But i would need seperate variables for each right?

    Seqeunce number 1 = 2
    Seqeunce number 2 = 1
    Seqeunce number 1 = 2
    ...

    is it possible to have the squence directly as one string

    like

    2+1+2+4+3
    21243

    so random function would role x times and connect each result as one string.

    I guess im basically searching for something like "text" +"text"

    (i also just came up while writing this that I could do 21243 by /1 /10/100/1000/10000)

    do I still have a question know?
    i dont know

  • BigDaveBigDave Posts: 2,093Member, PRO

    Thanks guys I should find a soluation now

  • tatiangtatiang Posts: 10,534Member, Sous Chef, Senior Sous-Chef, BASIC

    Just concatenate the inputs onto a blank text string (attribute) and check that string against the correct answer. So for each button press, the string changes:

    [blank]
    2
    21
    212
    2124
    21243

    You can check after each input or just at the end (e.g. when textLength(game.input)=textLength(game.answer)).

  • tatiangtatiang Posts: 10,534Member, Sous Chef, Senior Sous-Chef, BASIC

    If your question is how to concatenate (join) the text strings, you would do it like this assuming your button actor has a self.value attribute set to 1, 2, 3, or 4:

    When touch is pressed
         Change Attribute game.input to game.input..self.value

Sign In or Register to comment.