I built a Darth Vader inspired Simon Game!

Hi all,

This is my first time building an really interactive game. I use setInterval to do something, then call a function called nextThing() which is my attempt to keep synchronicity while determining the next thing to be done.

Unfortunately I am finding it very hard to keep track of the state of my application (e.g. when is it playing a pattern? When is it listening to user input?).

I would love some feedback on my JavaScript code structure. I am aware that it is a mess and there are function calls and state setting all over the place. I just don’t know how to approach the problem of keeping track of the applications state!

The main issue is that I only want certain actions to be performed AFTER setInterval has finished playing a sequence. The only way to do that is by calling functions INSIDE setInterval(function(){/*here/}, time).

Any advice in that regard would be very helpful, here is the pen:

Many thanks for your time and feedback!

(and that’s it, I’m done with the Frontend Course, thank you FreeCodeCamp!!!)

I love the Star Wars theme, but you have some bugs in your game.

  1. When the page loads and I hit Start, I get a random set up flashes and sounds on the buttons. This is not the way Simon works. I tried clicking on the sequence it gives me, but nothing happens other than the buttons light up after each press.

  2. If I click the start button after the game has started, it appears to turn the game off. Then if I click the start button again, nothing happens at all.

Basically, there is no game play at all or maybe you should put some instructions on how to play if it is intentionally different than the way Simon should work.

Hi Randell! Thanks for taking a look :slight_smile: . I should add some instructions. That is the startup sequence (playing a starwars theme) but it is not clear that it should not be copied. I have added the text ‘wait’ to the screen to tell the user to wait for the all clear. Thanks again!