Simon Day 38 (Part 2)

If you haven’t checked out part 1 [click here]

Last we left off is checking is connecting the lights and sequence works. Let’s see the result.



[The gif was too large so I can’t upload it]

okay, that went south… I’m not sure if you caught the problem but yes it lights up however there is no delay between the first light, and the second one so they all light up together instead of each having their turn. And that is where javascript’ an Asynchronous feature kicked me in the butt. I had to find a way to force it to wait and that is where timing functions saved the day so now

Brilliant! It’s working. Now that I have the cmp functions working, I have to start on the user interaction and turn. I started with having the lights interact with clicks so that was easy enough and the result was good



Now, I want to start working on the game loop which starts off with the cmp, and then control goes to the user [to listen to any clicks] and well that didn’t turn so well at all.

I hit an infinite loop. This didn’t make sense to me because I know for a fact that I have halting cases so what is going on here. And here is where I learned about overloading the thread, and that javascript and recursion aren’t friends. so I maneuvered my way around it and managed to fix it, but it’s still messing up

The problem that I’m facing is that it starts off well but then starts jumping and adding things to the user array without even a user interaction. So after some multiple debug, I managed to fix this issue

okay now I faced the problem whenever I try to add some new lights to the user array the old one is gone and it adds duplicates of the currently selected one [am I making sense or have I lost you] so I started adding a couple of log statements to know what’s going on and

why? why is it registering 2 clicks when I clearly just clicked one. That’s where I learned about parent function triggers so I had to fix that issue and

WOOOOHOOOO! Finally got user interaction working properly! I now start working on making sure that what the user selected matches the cmp sequence, as well as have a losing state. That was pretty simple compared to what I had to deal with earlier and



Awesome. Now I’ll start tweaking the UI a little adding an endgame state

Okay. A little bit more tweaking and adding around for the user to know how long the managed to reach in the game

Okay, I think it’s pretty cool now. It took a while and a lot of coffee consumption but it’s done. I’ll jut add a sound effect and it’s complete.

a couple of the resources that helped me out are:

so I managed to reach round 13 how long can you survive

You can check out the game on my site here. and I would love your suggestions or comments. If you reached this far cheers! You are an awesome human!

I guess that is it, until next time happy coding 🙂

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *