Getting Started

Remember to Do Pair Programming Swaps
From now on, we won't remind you to do Pair Programming Swaps on every page, but they remain a valuable programming habit to develop.
  1. This code Follow That Mouse Script appeared in Unit 1 Lab 2 Following with Sprites and this code repeat-until-(touching-Sprite)-(point-towards-Sprite) appeared in Unit 1 Lab 2 Sprite interaction . You've also used x position, y position and direction in Unit 1 Lab 2 Sprite Position Direction. Also, don't forget the right-click duplicate feature to save time making similar scripts.
    Construct each of these scripts and figure out how it works.

    You will use what you learn about these scripts to solve the puzzles in problem 2.


    Forever, go to mouse x mouse y and if X position is less than 0 set pen color red else green If Direction less than 90 set Pen Size to 5 Else set Pen Size to 1 Forever If Direction greater than 180 and direction less than 270 S et Color Red Else Green Move 1 Turn 1 forever ((if-direction=30or60-set-pen-size-10-set-color-blue-else-size-1-color-red)-move-1-turn-1)
  2. Four puzzles: For each picture, create a script (or modify one you already have) that keeps the sprite moving in a circle drawing that picture.
  3. Puzzle 1: circle with northwest circumference red and the rest green, sprite circling clockwise Puzzle 2: Circle with southeast circumference thin and the rest thick, sprite circling clockwise Puzzle 3: Circle with southwest corner thick and the rest thin, sprite circling clockwise Puzzle 4: Circle with the southeast corner thin and the rest thick, sprite circling clockwise

  4. Create a script that lets you write on the stage in two colors, using your mouse:
    using the mouse to write "mouse" on the stage

Conditional statements: The blocks if and if-else allow your programs to perform different actions or computations depending on a condition that you specify.

 

Predicates: As you learned in Unit 1, blocks such as less than or not that report only trueor false are called predicates. In snap, predicates are hexagonal in shape, not oval like other reporters. The values trueand false themselves are called Booleans.

Gamal: Hey, Betsy! Alphie! Delia and I did the puzzles in problem 2 using if-else the way I think we were supposed to, but we also found a way to do them with repeat until and even a way without using any conditionals at all.
Betty: How did you do it without conditionals?
Delia: Like this.
Gamal begins to rebuild a script for the first puzzle: partial solution using only repeat 90
Delia: This makes the red part. You do pretty much the same thing for the green part.
Alphie and Betty: Cool!
Gamal: But we couldn't find any way to do problem 3 without if-else. Do you think there is a way?
 
  1. Finish Gamal and Delia's script so that it draws the correct picture and keeps the sprite moving forever around that circle redrawing the picture.
  2. Compare a method using if-else with your method that uses no conditionals. What are the advantages/disadvantages of each method?
  3. Solve at least one of the puzzles from problem 2 using repeat-until.
  4. Answer Gamal's last question. Do you think there is a way to do problem 3 without if-else? Share Your Work
    Explain how or why not.
  5. Uncheck the "draggable" box above the scripting area before you try this. draggable check box
  6. Improve the script from problem 3 so that the sprite always follows the mouse, but draws only when the mouse button is down, so that you can draw disconnected shapes: bicolor printed hello