custom blocks

Open your Drawing Lab project, then create a new sprite and give it the soccer-ball costume.  Do all the work for today in this sprite.

 

Activity 7: a helpful script

When we are drawing, sometimes it's nice to quickly reset our screen. Below are a couple common ways to do this. 

Capture.PNG  or  Capture2.PNG

Make one of these versions, or feel free to adapt it to fit your needs. You can use the drop down menu in the "when __ key pressed" block to choose a different key than the space bar if you like. 

 

Activity 8: abstraction + your first custom block

In coding, abstraction is the process of hiding the details of how something works. We can do this by building a custom block in Scratch. Watch the video below to learn how to make a "draw a square" block.

 

Activity 9: generalization + abstraction

Generalization is finding a common pattern from many different examples or situations. In the "pen & shapes" activities, you may have noticed a pattern in the angles needed for each shape. Take a look at the table below.

Capture-1.PNG

Here is a visual representation of what inputs go in each block.

Capture-3.PNG

You don't need to make this block..

 

Notice that:

a. the repeat block gets an input of the number of sides in the shape

b. in the table, the number of sides X the turn angle = 360, always!

c. (and by the way) the size of the shape is controlled by the move block input

 

So now we can calculate the turn angle for any shape using the formula:

360 / sides = angle


Now that we have generalized our pattern, we can make a custom block that will draw ANY regular polygon. Watch the video below (up to about 7:00) to learn how.

Here is more information about custom blocks in Scratch if you are interested: https://wiki.scratch.mit.edu/wiki/Custom_Blocks Links to an external site. 

 

Activity 10: row of houses  

First make a script to draw a single house like one of the houses shown below. Use at least 2 custom blocks. You can use custom blocks from this lesson or make your own.

Capture-4.PNG

Next, use a repeat block with your script above to draw a ROW of houses like the row shown above (you will probably need to add some blocks to your house script to make the row draw properly). CHALLENGE: create a custom "row of __ houses" block!

When I grade this activity, I'll be asking you to draw a row of X houses, where I choose a random number between 3 and 7 for X. 

 

Activity 11: get creative  

Now use your custom "polygon" block and/or scripts of your own design to create some interesting shapes. Here are a couple examples to get you started (this is the same video as above, starting at 7:04). Be creative and make something nobody else made! Add in blocks to control the pen color, width, etc. to make something unique.