Warm Up Find the unknown lengths. 1. the diagonal of a square with side length 5 cm
Review Created our own motion block called “draw square” Used script to create a square with...
-
Upload
lynette-sullivan -
Category
Documents
-
view
213 -
download
0
Transcript of Review Created our own motion block called “draw square” Used script to create a square with...
![Page 1: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/1.jpg)
Lab 2: Build Your Own Blocks (BYOB), Variables & Loops
Jan. 13 – Jan. 15
![Page 2: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/2.jpg)
BYOB…Draw square Review Created our own motion block called
“draw square” Used script to create a square with side
lengths of 100 steps
![Page 3: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/3.jpg)
Improving Draw square
Created a motion block, that allows us to move a sprite in a 100 step square whenever this block is applied to the script
We will edit the block to accept an argument (or input), which tells it the length of the square it has to draw.
Right-click on the block and open block editor.
![Page 4: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/4.jpg)
Improving Draw Square Notice the “+” surrounding the draw
square text on the block Allows us to enter another component Create size input and copy by dragging
![Page 5: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/5.jpg)
Draw Triangle
Using knowledge of “draw square” motion block…create a “draw triangle”› How many repeats?› What angle?
Edit block to have size argument
![Page 6: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/6.jpg)
Draw Shape
Create a motion block that will draw any shape
Name block “draw shape sides size” Have two arguments
› Side› Size
Use operator block for angle
![Page 7: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/7.jpg)
Max Block
Reporter block – reports a value We will make a block called “max” that
takes two numbers as input and reports the bigger value (the maximum)
Notice the shape of this block, it has smooth edges and differs from the puzzle piece look of command blocks
![Page 8: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/8.jpg)
Max Block
How could we compute the max of 3 values?
![Page 9: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/9.jpg)
Useful tips in Snap
You can create inputs in blocks by clicking on the plus signs to add an input; however, you can also type the names of the input by incorporating a %.
The percent signs (%) indicate that the word should be an input.
Practice doing this both manually and with a %
![Page 10: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/10.jpg)
Predicates
A predicate is a block that reports either true or false.
Notice the difference in shape of a predicate block, it is neither smooth or puzzle piece shaped, but has pointed sides.
Lets create our own predicate block, “Greater than or equal to”
![Page 11: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/11.jpg)
Review of Variables
Normal/Global Variables: Can be used anywhere and by any in block, script, and sprite› Ex. “score” variable
Sprite Specific Variables: Normal variables that are applied to sprites individually, not good for block use
Script Variables: For use inside a script
![Page 12: Review Created our own motion block called “draw square” Used script to create a square with side lengths of 100 steps.](https://reader031.fdocuments.net/reader031/viewer/2022032607/56649edb5503460f94bebb25/html5/thumbnails/12.jpg)
Activity 2: Brick Wall
In this activity you will draw this brick wall
See Moodle link for full description