Simon Says choosing the sequence

0 favourites
  • 9 posts
  • Hello there!

    I'm working on a Simon Says activity and I've tried to adapt the concepts in this tutorial:

    construct.net/en/tutorials/simon-says-follow-me-108

    to what I have so far:

    drive.google.com/file/d/1AIIYi6nHiNvWRHE_scRQL-9gksLoc8Ag/view

    ---

    I've mapped the different colors to different sections in the array and I've created a function for what happens when you click a color. I've got Simon choosing a random color each time the program runs (yes!) and a text field (so I can see what's happening) that also lists the color picked. It was my thought process that through that text field/global string I could keep track of the colors and also compare them.

    I just don't understand how that comparison happens. I would like Simon to pick 4 colors before it is the users turn to pick a color, but how do I keep track of that sequence? my global variable 'user' keeps combining every color I've chosen!

    Can anyone offer a hint or let me know if I'm even going in the right direction? The tutorial I'm trying to follow doesn't offer the .capx anymore and I feel like I'm really close there is just something I'm not understanding.

    Thank you for your help!

  • My approach would be to push simon picked colours to an array and when the player presses a combination you can compare the pressed colour with the top colour of the array. If it matches then pop the top of the array then continue and if not then you failed. If the array is empty or by tracking with a global variable for number of colours then go onto the next game.

    The initial colours for picking don't need to be in an array you can use choose("red","green","blue","yellow") which picks a random one of the 4 but then my approach would be to push the colour chosen at this point into the array for comparison.

  • Okay! I've made some good progress I think. Thank you so much for your help so far!

    Here is where I am at:

    drive.google.com/file/d/1X5FnjZW1TbFiqgQEmdjPo91eLVEtT8hL/view

    I've got arrays that im pushing values to and comparing between the user and simon successfully. I think I have to utilize your global variables suggestion to really get things moving, but first...

    I created my test button because I wanted to know how 'reading' from an array (later would be Simon's chosen sequence) would look and the problem that I am experiencing is that when I press the test button all of the colored buttons light at the same time. I've tried the 'wait' command with values ranging from 0.2 to 5, but it doesn't matter. I've tried putting the 'wait' command above the function call, but then nothing happens at all. What am I doing wrong? How do I say "for each x value in the array, call this function, wait a moment, call the next one"

    I saw someone with a similar problem once, but I couldn't find the forum post I do apologize.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Combining waits and loops and functions can be problematic and cause bugs so I try to stay away from that. To have more control with the timing and reducing bugs I like to use an approach such as : every X seconds, so you can control the speed - play array.at(var) where var is a global variable. Then underneath add 1 to var.

    Because this won't work in the same event as the button press you would put it in its own event activating it with another global variable that works as on/off. You set it to on with button press. To stop the var from counting up forever you also have a condition that global var is not greater than array.width (the number of values), else set counting var to 0 and on/off var to off to reset.

  • Hello!

    Okay, I'm stuck again.

    Using 'Every X seconds' to initiate Simon's initial sequence works and it records it to an array. I'm using global variables to turn things on and off. My event sheet now has comments in it to show my thought process/why something is there. For example, during the start of Simon's initial turn, I had to put a wait command in or else the last item Simon chose wouldn't be included in the array. This seems like a sticky solution especially since in the future I would be interested in changing the playback speed and having asynchronous audio files that play along with the choices.

    On top of this, (and without current regard to whose turn it is... that's my next thought process to tackle) I updated my test button to playback Simon's sequence on click and that's where I've been stuck for a few days now. I just wanted to test if I could get it to play back. I'm using the 'count' global variable as my indicator for where on the x axis of the array the sequence is being called.

    I've tried 'Every X seconds' - This will step through Simon's sequence on click (seemingly without regard to time), but I want it to happen automatically - Every X seconds. Also, count = Simon-1 doesn't change the 'SimonsTurn' variable to true which is why, I imagine, the extra pick at the end does not record to the SimonsChoice array.

    I've tried 'For Every X...' in the SimonsChoice array - this creates the problem I had before where all options were being chosen and played at the same time. It also immediately sets the 'count' variable to 4 instead of stepping through it (I included wait commands too).

    I've tried using the 'wait for previous actions to complete' condition with no noticeable successes.

    Even removing the comparison of the count and simonsays variables didn't change anything. It's like 'Every X seconds' is just being completely ignored.

    Where do I go from here?

    drive.google.com/file/d/12KKDjNMTP6wyyC_lJ98LEfFHSXEKta92/view

  • The reason you now need the wait to 'fix' it is because you added waits in the functions, that's why I mentioned I try to avoid this where possible because it creates bugs. I like to stick with one simple event if possible. The test button isn't working because it's a trigger once event (the button press) and you can't put an every X seconds as a sub event of this. You'll need to toggle a variable on button press so it runs all the time like you did with the start variable.

  • Ohhhh! My bad! I foolishly thought since those were working they would be okay, but I suppose I've just learned exactly why you said not to do that haha! Okay thank you!

  • I just wanted to let you know...

    IT'S WORKING!!!

    I've been trying to figure this out for 4 months and it was only a month ago I was brave enough to come to the forums so I just want to thank you for your help getting me to this point!

    drive.google.com/file/d/1UDxkIsaj9hoirZMFdbXkWiCopMLbwZW7/view

  • Nice :) good job

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)