ST EK List:
1.2.3 Create a new computational artifact by combining or modifying existing artifacts. [P2]
1.2.3A Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
5.3.1E Parameterization can generalize a specific solution.
5.3.1F Parameters generalize a solution by allowing a function to be used instead of duplicated code.
5.3.1G Parameters provide different values as input to procedures when they are called in a program.
MF: 1.2.4 Collaborate in the creation of computational artifacts. [P6]

Modify Your Pinwheel

Ruthless Suggestions from Al

On this page, you will modify your existing pinwheel block so that you can use it to draw a variety of shapes.
assortment of pinwheels

Adding Multiple Inputs

Recall how you first generalized your original pinwheel script: you added an input variable called branches that controlled the turning angle of the sprite. By adding more input variables, you can generalize other aspects of your program...

  1. If it isn't already open, open your U1L3-Pinwheel project.
  2. Experiment with the input for the second move block inside your pinwheel block as shown below.
    1. Talk with Your Partner First predict. What do you think will happen?
    2. pinwheel block definition with comment asking students to experiment with the input for the second move block
    3. Then try several inputs between -100 and 0.
    4. Talk with Your Partner What happened? How does it compare to what you predicted? How does this input value impact the sprite's behavior? How does it impact the resulting image on the stage?
      Animation cycle from Asterisk to Polygon
  3. Review how to add an input at Unit 1 Lab 3 Page 3: Blocks with Input, if needed.
    Add a second input variable to control the amount of "backing up" that the sprite does before each turn through the full 360°.
    1. Edit your pinwheel block, then click the "+" sign at the end to add an input label (choose "Title text"). Type backup: as shown below, and click "OK".
    2. typing 'backup:' as Title text into Block Editor's Create input name window
    3. Then click the "+" sign at the end again to add an input variable (choose "Input name"), and call it backup.
    4. Drag off the new backup variable, place it where it belongs in the pinwheel code, and press "OK" or "Apply."
    5. Check that the new input slot in the pinwheel block behaves like the changes in your experimentation above.
  4. Use an Operator block.
  5. Change the pinwheel script so that it will accept a positive value (between 0 and 100) for backup.
Pair Programming Swap

Debugging Tip: Organizing Your Code

A great way to avoid having bugs in your program in the first place is to keep your code organized by deleting any unused blocks to avoid clutter. Here are examples of messy code and neatly organized code with comments. If you came back to your project after a few days, which code do you think would be easier to debug?
Example of messy code with loose scripts all over the place.
Example of organized code with comments

You can use the clean up option by right-clicking in the Scripts area to organize and arrange your blocks vertically. You can remove a block or script either by dragging it out of the scripting area and back to the palettes on the left or by choosing "delete" option from the drop-down menu as shown below. Note that this is different from the "delete block definition" option which will permanently delete a custom block and all its instances from your entire project.
Animation about deleting blocks by dragging them off to the palette or by choosing the delete option by right-clicking.

  1. Add another input called size to control the input to the first move block.
    pinwheel, branches: (number of branches) size: (size) backup: (backup) hat block
  2. Try out a variety of inputs to your pinwheel program...
    setup; pinwheel, branches: (6) size: (80) backup: (20) image of result pinwheel, branches: (6) size: (80) backup: (20)
    setup; pinwheel, branches: (5) size: (80) backup: (60) image of result of  pinwheel, branches: (5) size: (80) backup: (60)
  3. Talk with Your Partner Discuss what input values will give you a polygon or an asterisk.
    polygon asterisk
  4. You may want to reduce the input value for the wait blocks inside the pinwheel script so you don't have to wait so long between trials.
Now Is a Good Time to Save
  1. Find inputs to pinwheel that make the result look like a circle.
  1. Make a picture that looks more like a real pinwheel:
    pinwheel photo
    Copyright 2010 Victoria Hudgins. Used by permission.

    (Save your project first; you'll need the pinwheel block you already have later.)

    It doesn't have to look exactly like the photo. But each arm of a pinwheel is essentially two triangles. You may find the fill block block helpful.