Page 3: Customizing and Debugging

Unit 1, Lab 2, Page 3

On this page, you will edit the word lists used by the sprites and debug any problems.

  1. Open your U1L2-Gossip project. Edit these three reporter blocks to change the phrases that the program uses. (See the instructions in the box below.) Be creative and funny but thoughtful.
    who block does what block who2 block

How to Edit a Block

  1. Find the block in the scripting area or the colored palettes on the left.
  2. Control-click (or right-click) on the block and choose “edit…”
  3. Make changes to the block’s internal code. (Instructions are already inside these blocks.)
  4. Click OK when you’re satisfied. (Or click “Cancel” if you don’t want to make changes.)

Brian, you need to redo this video with the plus signs on and with the space before the 2 in who 2 (start from the starter file, please). –MF, 6/15/20

Click for a video of these steps of how to edit a block.

How to edit a block

Why do these blocks use report ()? Why not just use say ()?

The report and say blocks mean very different things. Report tells something to the computer, and that value can be used as input to another block, such as the join block inside gossip. Say just shows a value to the user in a speech bubble.

: Lists, Strings, and Concatenation

What does “ordered” mean?

It doesn’t mean that the items have to appear in alphabetical or numeric order. It just means that (list a b) is a different list from (list b a).

  • A list is an ordered sequence of items. You’ve seen this example:
    list{Senora, Ms. C, my cat, Hannah, Jake}
  • The items of this list are strings. A string is a sequence of characters (letters, digits, punctuation, etc.). A substring is just a piece of some existing string. For example, “Hanna,” “anna”, and “nnah” are each substrings of the string “Hannah.” (The empty string as well as the original string are both also substrings.)
  • To concatenate strings means to make a bigger string by connecting two or more smaller strings. In Snap!, the join () () block lets you concatenate strings.

The process of testing, finding problems, and fixing them is called debugging.

  1. Make sure your program works. Test each block as well as the program as a whole. If something doesn’t work, don’t go on without fixing it.

Save your work

  1. Which two of the following sentences could be reported by gossip?
    gossip: (report (join (who) ( ) (does what) ( ) (who)))

    For reference:
    who reporter block definition: report (item (random) of (list (Señora) (Ms. C) (my cat) (Hannah) (Jake))) does what reporter block definition: report (item (random) of (list (listened to) (loves) (ran away from) (helped) (is in a band with)))

    Señora and Ms. C helped.

    Señora ran away from my cat.

    Hannah listened to Hannah.

    Jake helped.

  2. Change the costumes to anything you like.

Adding a Costume

  1. In the sprite corral, select the sprite you want to give costumes to.
  2. Choose “Costumes…” from the File (File button) menu.
  3. Choose a costume.
  4. Click “Import.”
  5. Click “Cancel” to close the dialog box.

You can use a photograph or picture from the Internet by dragging the image onto the Snap! window.

  1. Fix any issues with your costumes.

Adjusting a Costume

  • You can change the size of your sprite using set size to ( ) %.
  • You can change the position of your sprite using go to x: () y: ().
  • You can change the direction your sprite is facing:
    point in direction (270) with menu open showing right left, up, down, random

Blue “If There Is Time” boxes have optional activities that are not required for this course. If you finish everything else on the page early, try these instead of jumping ahead to the next page. If you have a smartphone, you’ll definitely want to click this one.

  1. Change the background on the Stage.

    Adding a Stage Background

    Changing a stage background is almost like changing a costume.

    1. In the sprite corral, select the stage.
    2. Choose “Backgrounds…” from the File (File button) menu.
    3. Choose a background.
    4. Click “Import.”
    5. Click “Cancel” to close the dialog box.