Successfully Added To Cart

EXERCISE SOLUTIONS:

Challenge

Download the code above (the 'I Give Up' file) for the solution to this question.

Question 1

By making the "bucket" variable smaller, the game becomes more responsive to your movement, and therefore more difficult. On the other hand, making it bigger makes it easier to hold the cursor over the goal. Notice that if you make it too big, you won't be able to reach the outer LEDs with your cursor.

Question 2

One way to do this is to make a new variable, lets call it goalTime. To start out, set it equal to 500. Then, change if(millis() - goalStartTime >= 1500) to if(millis() - goalStartTime >= goalTime). In this if statement, also add the line goalTime += 500. This will increase the time needed to score a goal by 500 milliseconds each time a goal is scored.

Question 3

To cycle through the colors, we need three variables: red, green,, and blue. Set green to 255 and red and blue to 0. In order to cycle through these colors, we need a couple of if statements in the loop():
if(red == 0) {
 blue++;
 green--;
}
if(green == 0) {
 red++;
 blue--;
}
if(blue == 0) {
 green++;
 red--;
}
To set the cursor to these colors, change the line setNthPixel(cursorIndex, strip.Color(0, 10, 0)); to etNthPixel(cursorIndex, strip.Color(red, green, blue)); A slightly more advanced version of this code with adjustable brightness is available in the 'I Give Up' file.

Google Tracking
Pinterest Tracking