Challenge 2: Add Challenge to Shooting Monkeys
After completing lessons 1 to 12, you are ready for your second challenge! Modify the code for the Shooting Monkeys game so, if 5 monkeys get by without being clicked on, the game stops and an alert message appears that says "You lose!".
Also, you may notice that as you play the Shooting Monkeys game, occassionally the image of the monkey is selected (becomes highlighted). Add the CSS code to prevent the player from selecting the monkey image.
Check out the Example.
Then create your own version. Here are a few hints:
- Set up a variable to track the number of monkeys that made it to the top.
- Increase the variable by one every time a monkey makes it to the top.
- Right after the variable is increased, add a conditional statement that ends the game if the variable is equal to 5.
- Increase the speed of the monkey to make the game more challenging.
To get good at programming you should go beyond the minimum challenge requirements. Here are some examples from students who went beyond the call of duty.
Spring 2016
- Yixel Padilla: Increasing speed after each hit, instructions, & background art.
- Ari Yegiazaryan: Displaying number of hit and escaped monkeys.
- Ryan Peterson: Increasing speed & automatic restart after losing.
- Jon Wong: Increasing speed, refresh button in game window, scoring/life system, green monkeys to give life, red monkeys to take away life.
Once you have completed the challege, reward yourself with some Sliver.io.