Apple Catcher


Its harvest season and the apples are dropping! Can your farmer catch them all?
Start with one apple, then use an array to have multiple apples falling at the same time.

Here is an example of a completed game

Open Woof_JS here: http://www.woofjs.com/create


Directions
  1. If you are coding outside of WoofJS.com (like in Sublime), insert the Woof_JS source tag into the <head>section of your project page:

    <script src="https://rawgit.com/stevekrouse/WoofJS/master/dist/woof.js"></script>

    Your code now speaks Woof!

  2. Find an appropriate backdrop (farm if you are catching apples, a circus tent if juggling pins) and add the url to the setBackdropURL call.

  3. On the web, find two transparent images: an apple (or whatever you are ctching) and a farmer or another catcher. Save the URL's for the images.

  4. Add two image sprites. Use code from the Sprites & Backgrounds section of the Woof documentation. Now change the url: attribute in the sprite objects to be that of the images you found.

  5. Add a forever function to your code. (Hint: look in the Control section of the Woof documentation) This will take care of updating changes in the game in real time.

  6. Inside the forever function, get your Catcher to move right or left if arrow keys are pressed. Look in the Sensing section if there is an instruction that checks if a key is pressed. Copy it and put it inside an if statement: Something like:

    if (keysDown.includes('LEFT')) { //move the catcher left 10 pixels }

  7. Declare a text label for the score using a Text sprite.

  8. Create a variable (call it appleSpeed) and inside the forever loop, have the apple drop by that number.

  9. Check for apple hitting the bottom of the screen. If that happens, subtract 1 point and return the apple to the top of the screen.


  10. Add a check for the catcher catching the apple. If this happens, add points, and also return the apple to the top of the screen.

  11. Show the score in the score label

    How do like the game now? Are you ready to have many apples falling at the same time?

  12. Add an array called all_apples.

  13. Outside the forever loop, add an Every loop that creates a new apple every 2 seconds, and pushes it into the all_apples array

  14. Inside the forever loop, add a forEach function that cycles through all the apples.

    all_apples.forEach ( apple => { //move the code to move the apple, check if the apple was //caught or hit the bottom of the screen HERE })

  15. Increase the speed of the apples as the score gets higher

  16. Play a sound every time an apple is caught

  17. Keep working on the project and customizing until you are satisfied.
    Ask your teacher/TA to upload it to your public folder.







(c) 2018 by Code Craft Academy