Random choices

mscherermscherer Member, PRO Posts: 30

Hi all,
I'm wondering if someone could lead me in the right direction. Remember the 1970 or 1980 game called Simon? It was a round object with four different color lights on top. Each time you pushed start the game would randomly illuminate up a sequenceof coloured lights which the player would then have to press in the correct order to move forward to the next level.
Does anybody know how I could do this with GameSalad (I.e. The computer sets a random sequence and then compares this to what the player presses??

Thanks for any help you could give me.

Comments

  • colandercolander Member Posts: 1,610

    Hi @mscherer and welcome to GameSalad. It would be difficult to guide you since you have just joined and are completely new to GS. I suggest you spend some time learning the basics first before jumping straight in. It will save you a ton of time later on because you won't have to backtrack as much redoing and fixing poor work and logic.

    Go to Help/Cookbook and work your way through it. Also you should research universal builds it is critically important to choose the right path which suits your game before you start making your game.

  • mscherermscherer Member, PRO Posts: 30

    Thanks Colander
    I have spent a lot of time now reading manuals and watching videos on gamesalad. I have also made a few games to check how certain things are done.
    I would still like to know if using tables is the best way to achieve my above question.
    In short, how do I get the computer to choose a random path and then ask the player to follow that path. This will form part of a game I am writing. The player must choose the right stepping stones that the computer has previously chosen.
    Any help would be greatly appreciated.

  • quantumsheepquantumsheep Member Posts: 8,188
    edited July 2014

    Tables would work fine I think.

    Assign a number to each colour.

    So Red = 1
    Blue = 2
    Green = 3
    Yellow = 4

    Every time I press the red button, a variable called 'colour' will be 1. If I press Green, the variable colour would be 3 and so on.

    Then choose how many 'steps' the pattern will be (let's say '8' and call the attribute 'steps').

    In the table:
    Each column will be a step in the pattern.
    The rows will correspond to the colours (as above).

    Before starting a round, in a control actor, for each column (i.e. each step) pick a random number from 1-4.

    So the rules/logic would be something like:

    If step is less than 'however many steps you want - e.g. 8)

    Use a timer start that states every .1 second
    change variable step to step+1 - this cycles up the step every .1 seconds)
    change the numeric value cellvalue(YourTable,random(1,4),step) to 1 - this places a '1' in a random row (1-4) for each step.

    If it chose row 3 for step 1, the value would be 1. Row 1, 2 and 4 would equal 0.

    When player presses 'start'
    change attribute step to 1.

    On each button you'd check to see if the variable 'colour' = 1 in the table.

    For example, let's say step 1, row 3 = 1

    If I press the green button then in that actor you'd have:

    If touch is pressed
    Change 'Colour' to 3

    Then another rule that says
    If touch is pressed
    and
    colour = 3
    and
    numerical value cellvalue(YourTable,colour,step) = 1

    (this checks if its correct - in this case it is)

    Then change step to step +1 (this moves to the next step).

    If step 1, row 3 = 0 (i.e. it wasn't chosen randomly) and you press the green button (which would give the wrong number) then you'd fail.

    I think I've written that out right. I'm a bit tired, so it may be wrong/not make much sense. But if nothing else it might put you on the right course.

    Someone far smarter than me should be able to explain table loops which might make things easier.

    Hope that helps,

    QS

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • mscherermscherer Member, PRO Posts: 30

    Thanks very much QS....I will give this a go

Sign In or Register to comment.