Giter Site home page Giter Site logo

week1.day1.bouncingball's Introduction

week1.day1.bouncingBall

Instructions

  1. Use command line to create a new project folder called bouncingBall
    • Navigate into the folder and create your required files (index.html, sketch.js)
    • Include a reference to p5.js in your index.html file
  2. In your sketch.js, setup your canvas (600x600) and draw a circle in the center of the canvas
    • Your circle should be drawn from the CENTER by default, but if this isn’t the case, try using rectMode(CENTER)
  3. Have the circle move along the x axis, you will need to define the x & y position as a variable and incrementally increase them (try different increments for each).
  4. You will need a conditional statement for each side of your canvas. If the ball reaches that position (i.e. x < 25 at it's center), it should reverse the incremental direction of the 'speed' you applied above.
    • Trying drawing this out by hand - Think, what should happen to the ball when it hits top, left, right, and bottom walls?
    • HINT: If something is changing, think about using a variable!
    • HINT: If something occurs in a certain situation (i.e. ball touches wall), think about using a conditional and IF/ELSE IF statement!

Extra Credit

  • Have the ball start out in a random position on the canvas, instead of the center of the canvas
  • Write a function that changes the color of the ball if the user is able to click it while it is on the move.
    • Think about what “clicking the ball” really means - the mouse x and y were within the radius of the circle. Hint: dist()
  • Make the ball speed up every time it hits the edge of the canvas

Helpful Resources

week1.day1.bouncingball's People

Watchers

James Cloos avatar Victor(ious) Ramirez avatar  avatar Mahdi Shadkam-Farrokhi avatar  avatar  avatar  avatar

Forkers

justinasc5mlb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.