It usually takes butter to make good toast. In our case, practice will be the butter for our toast.
Before we practice, though, we want to spend a little time working on our wiki pages. Work with the teacher to make some improvements to your wiki page. After that, come back to this practice!
Using classes seems hard, so let's do another simple one step by step. Here's what we want to do:
We'll do one together first, then you can do it again with your own simple drawing.
First, we start with some buttered toast.
Now we'll make a class and put this in the draw method so that we can draw it.
Notice that we have to call the constructor once using the “new” keyword with the class name to make an object to draw.
We'll change the position arguments to base them around 0. Then we'll add position properties. We'll use translate and resetMatrix to set the position and restet the matrix so that it's ready for the next thing we draw.
We'll add in a random rotation, like we did before.
Now let's use buildArray to make many of them, then use forEach to draw the objects from the array.
Let's go ahead and make the color of the toast more variable. We'll also make the butter and its position change each time.
Go ahead. Start with the easiest version of this ButteredToast class, then replace the draw method with your own code. Don't forget to rename the class to something appropriate. You'll need to change the name in the place where you call the constructor, too (hint: look for the new keyword).
Remember, these are the instructions from last time. Can you make a drawing that does the following?
When you're done, be sure to put it on the wiki!