Golf


Can you get your ball to the green, avoiding obstacles, using fewest strokes possible?

Use vector principles to translate the touch-and-pull game mechanic into the ball's speed and direction. Create this game using any theme you'd like, from standard green to under-sea or space-golf!

Here is an example of a completed game and a space-golf version.


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. Select a background for your course that matces your theme.

  3. Create your ball and destination (hole and green, the planet Earth). These can be images or just a circe. Place them on the screen in opposite corners

  4. Create a new Line for your flight vector - the direction where your rocket will go. Give it a bright color. Hide it by default.

  5. When the mouse is clicked, show the vector line and make it go from the mouse pointer to the ball. Have it adjust as you move the mouse.

  6. When the mouse is released, have the vector line disappear and set the speed of the ball be the direction of the vector. Hint: the two components of ball speed (xSpeed and ySpeed) are a multiple of the xLength and yLength of the vector line.

  7. Add a forever loop, and move the ball by the X and Y speed components. Make the ball slow down as it travels across the course, so it should eventually come to a stop.

  8. Have the ball "bounce off" as it hits edges of the screen.

  9. Add 3-4 barriers on the screen. Use the "bounce off" function you wrote to have the rocket bounce off the barriers.

  10. Create obstacles and set them up in the middle of the course to block the ball.

  11. Create a variable that counts how many strokes the player takes. Show it on the screen.

  12. Play a sound when you hit the ball.

  13. Check when the ball is in the hole, play a sound, stop the game and show the player score.

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