Functions, Arrays, Objects, oh my!

This week my main focus was to make my code from last week more concise. I want to continue building on my game idea, eventually creating a timer, levels and more challenging interactions. My code went from almost 400 lines to 97. Screen Shot 2015-10-06 at 10.06.03 PM

I first created a constructor function and made parameters for each part of the bouncer. The color refers to the original color of each ball and the target, which is seen in the next part refers to the color the ball turns into after being clicked.

Screen Shot 2015-10-06 at 10.09.19 PM

For the palette array that I defined previously, I hardcoded the color values. Since there are 10 balls, I created 10 color values to be assigned to each.

Below I pasted each screenshot of the game sketch. Each ball begins grey and as they are clicked they turned into their assigned color.

Screen Shot 2015-10-06 at 10.04.26 PM

Screen Shot 2015-10-06 at 10.04.38 PM

Screen Shot 2015-10-06 at 10.04.51 PM

Screen Shot 2015-10-06 at 10.04.59 PM