Crab Hunt


Here is a fun starter game to get familiar with sprite game mechanics and Woof_JS. Move your crab (or whatever sprite you choose) around the board to pick up as much food as possible before the timer runs out.

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 (ocean if you are doing fish, space if spaceships, etc) and add the url to the setBackdropURL call

  3. On the web, find two transparent images: a hunter (crab) and a food (fish). Save the URL's for the images.

  4. Add two sprite images. Use code from the Sprites & Backgrounds section of the Woof documentation. Now change the url: attribute in the sprite object to be that of the crab,fish, alien etc 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 Crab to move in 4 directions 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('UP')) { //move the crab up 5 pixels }

  7. Declare a Text sprite lable to show points.

  8. Add a check for the Crab catching the fish. If this happens, add points, and move the fish to a random spot on the screen.

  9. Check for Crab hitting the edges of the screen and react appropriately.

  10. Create a timer variable and set it to however many seconds you want the game to last.

  11. Add an every function, cycling every second. (Look in the Control section.) Inside the every function, decrease the timer by 1, and when the timer runs down, stop the game.

  12. Play a sound every time the crab gets a point.

  13. 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