Unit 6 Student trying to create bop-it type game

Student is trying to create a bop-it type game with his Adafruit Circuit Board. When he originally created it, it was adding points no matter what the action was (shake, buttonL, buttonR, etc). He tried to add code to differentiate however now it is not adding any points.

Is there a way to do this? Any help would be greatly appreciated.

Hi @sarah.dudley,

This was a fun one to work through! There’s a few things I changed in order to get it working:

  • The student is checking textBop.length, which will give them the length of the string. What I changed it to was checking getProperty(“label2”, “text”) and checking if it was equivalent to the corresponding part of the textBop array (so textBop[0], textBop[1], textBop[2], or textBop[3]). Now we’re checking the value rather than the length.
  • The event handler “onBoardEvent” should come before the if statement checking for the value of textBop. I’m not sure of the technical explanation of why, except that the board event handlers should be listening all the time but only take action some of the time (determined by the if statement).
  • This wasn’t actually impacting the game, but I changed the typo from “swicth” to “switch” – goes to the readability of the code! (Maybe I was an English teacher in a past life. Who knows?)
  • One last thing for the student to be aware of – sometimes the background is so dark I can’t read the display. They may want to look at their RGB’s.
  • The accelerometer wasn’t working on my board so I switched it to “change” instead of “shake”. I’m working on a board that’s a few years old so it may just be an issue with that particular board.
  • Here is a link to my remix with the above edits.

Overall, the student did a great job with this game. I had fun playing it. :slight_smile: If you have any further questions, please reach out & one of us will get back to you.

–Michael K.

Thank you SO much for this post. My student and I were trying to do the Bop-it game and we were SO close and we couldn’t figure out the last piece to make it work. This post helped me figure out what we needed to do!

1 Like