Skip to content

HW Week 6.1

abbybeno edited this page Oct 12, 2016 · 17 revisions

Homework, Week 6.1 -- Objects & Classes

In class discussion of progress will occur Wed, Oct 5th.
The Final version will be due by Mon, Oct 10th

  1. Create a sketch that creates and manages at least 5 objects created from a single class.

    • Your class should include both parameters & functions
    • The functions should cause the object to do something
    • This sketch does not necessarily need to be interactive for the user
    • Your class should be written in a seperate .js file that you link to from your index.html
    • You will need to use an array to manage the group of objects
    • You are welcome to refactor a previous sketch into this assignment. You may also write a new sketch.
    • For additional practice, you should also have at least one additional function defined in your sketch. A simple example would be to create an additional function that renders the background and any other background like elements. This function could take an argument that causes these elements to change as well. Alternatively, this function could be a math function.
  2. Here is a suggested work flow for your sketch this week

    1. Make one single object with just variables.
    2. Put one or more functions in the object.
    3. Try manually making two objects.
    4. Duplicate the object using an array and make as many as you like!
    5. In the end the goal is to have code in draw() that only makes calls to objects. Something like:
    function draw() {
      	background(0);
    
    	// A single object
    	apple.chop();
    	// Another object
    	orange.peel();
    
    	// Calling a function on all of the objects in an array
    	for (var i = 0; i < grapes.length; i++) {
    		grapes[i].pluck();
    	}
    }
  3. Additional material that you can review about objects / arrays.

    • Videos 6.1-6.5 cover more about objects, arrays, and the constructor function.
    • Getting Started with p5.js chapters 10-11 also cover the same material (In the repo).

Questions

Add your homework here

Clone this wiki locally