Leave a rating/review
I have an idea on how to make Bullseye a bit more fun. What if we modified bullsye to give the player an additional 100 bonus point when they hit a perfect score? This would encourage the players to really try and place the bullseye exactly on the target.
Otherwise, there isn’t much difference between 100 points for a perfect score and 98 or 95 points if you’re close but not quite there.
While you’re at it, give the player 50 bonus points if they’re just one off from the perfect score.
That’s it - go ahead and pause the video and give it a shot, and stay tuned for the solution.
How was the challenge? Hopefully, you did well. As always, if you got stuck, feel free to follow along.
Start by heading over to the pointsForCurrentRound method.
Then create a new bonus variable and set it to 0:
var bonus = 0
After that, create an if block to determine the bonus amount based on the difference. Enter the following code:
if (difference == 0) {
bonus = 100
} else if (difference == 1) {
bonus = 50
}
Finally, add the bonus to the returned score like so:
return maxScore - difference + bonus
Run your app.
Then try to get the slider right on the exact target.
When you do, you’ll see your new bonus point which would be an extra 100 if you hit a perfect score. Or an extra 50 if you’re 1 point away from the perfect score.
Well done!