GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

"Simon Says" Style game programming problems

Here is what I have working:
1. My game has 10 buttons. Each button is controlled by touch, or can also be controlled via a game attribute.
2. The game generates and stores a random number from 1-10 each step of the sequence.
3. The game steps through the sequence, and turns on the matching button so the player can see an example.
4. Once the sequence has been played, the game displays a message for a few seconds saying "Now You try!"

All of this works great up to this point. I have made several variants of this, I originally tried to do it with a table and it wasn't reliable, so I re-made it using attributes instead of table cells. The attributes make it more annoying to tweak things like how many steps to a sequence for each level, but it's easier to look at the code and seems to work more reliably.

  1. After the "Now You Try!" Message has timed out, The user then must touch the buttons in the same order that they were played to complete the level. There is a maximum number of tries for each level, If they make a mistake, they have to start over until they run out of tries, at which point they are either bumped back 1 level or lose the game if they are at the lowest level.

I am having a lot of trouble with implementing step 5. I can get the game to compare the first button you press with the stored attribute for that step of the sequence. The program seems to get stuck here. I have tried putting "display text" in various parts of the code to figure out what's going on, and it seems like the code just stops executing. I have tried all kinds of different things, using rules and the "loop" behavior, and looping through a table or having discrete attributes. I have made so many changes I honestly don't remember everything I have done.

Can anyone point me to a template of something similar or is it possible to explain a simple example of how this should work?

Comments

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    I built a system like this for a game called Light the Way by @poorcollegedev a long time ago.

    I used tables with each row representing a step in the process. So if the correct sequence is 4683, the table would hold:

    4
    6
    8
    3

    To compare sequences (correct vs. player inputted), I think I used tableMergeValues and a string attribute with something like game.playerSequence..game.playerChoice. So if the player chose 4 and then 6, it would concatenate them as "46". It compares the merged table value ("4683") to the player sequence ("46") after each click/choice. You can do that with textSubStr to just compare the current sequences (e.g. "46" of "4683" to "46" inputted by the player).

    Hope that's helpful.

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

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef
    edited September 2016

    Here's a demo (attached). It's slightly easier to use 0 to 9 instead of 1 to 10 so I went with that.

    YouTube skips frames so you end up missing the full randomized sequence but it works (albeit quickly) in the project file.

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

  • SocksSocks London, UK.Posts: 12,822Member

    @tatiang said:
    Here's a demo (attached). It's slightly easier to use 0 to 9 instead of 1 to 10 so I went with that.

    I've vastly improved your demo, it's now much more responsive.

  • JH4musicJH4music Posts: 23Member, PRO

    Wow, thanks so much. I'm going to study these, looks like exactly what I needed.

  • tatiangtatiang Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    Any time @Socks uses the word "vastly" you know you're being rickrolled. Still, I must admit I loved it.

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

  • JH4musicJH4music Posts: 23Member, PRO

    Lol. I opened that one first...

Sign In or Register to comment.