SImon Game - my head is spinning

SImon Game - my head is spinning
0

#1

Need some guidance with Simon Game- if anybody has the patience to review my code that would be great…

  1. I set up HTML, CSS and Audio for button presses…- after the start button is pressed…

  2. I used setInterval() - but this always fires and - maybe setTimeout would be a beter option???

3… Sort out a way to alternate between computer and player…

  1. I have an array which keeps track of the random colors picked…

#2

Yep! You were doing the right thing by storing the interval and using clearInterval, though, and it’s a good idea to keep storing those intervals in case you need to cancel playback.

Well, you’ve already got an array that keeps track of the computer’s moves, why not create an array of the player’s moves? You can switch when the arrays are the same size.


#3

Thanks for your reply…

I have having issues creating the logic for creating the action to press the button in the order the array is created… con you provide some references or feedback…
thanks


#4

Think about what you want to do to each color when it’s being played and put that in a separate function. Then, call that function for each item in the array. Use that same function for the button handlers. Here’s some pseudo-pseudo code.

$('.blue.color-button').click(function(event) {
    playColor('blue');
});

// ...

function playColors(arrayOfMoves) {
    // for each move in the array of moves...
    // playColor(move)
}

#5

thanks for sharing some of your thoughts. I have been stuck on my present code the past 2 days… I think I need to watch some videos on static javascript games…