Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit 3: Intro to Programming Snap! Introduction

Similar presentations


Presentation on theme: "Unit 3: Intro to Programming Snap! Introduction"— Presentation transcript:

1 Unit 3: Intro to Programming Snap! Introduction

2

3 Snap! Interface Inside the Scripting area you pull blocks from the palette to make scripts, as exemplified below Snap! is a visual language; instead of writing a program using the keyboard, the Snap! programmer uses the same drag-and-drop interface familiar to computer users. The five blocks that make up this script have three different colors, corresponding to three of the eight palettes in which blocks can be found. Hat Blocks Command blocks

4 Technical Vocab A script is a sequence of instructions that tells a computer what to do. A program is a set of scripts. In some programming languages, like Snap, you program by dragging blocks (individual instructions) and snapping them together. In other languages, you type the instructions. The idea is the same. You can use blocks that Snap provides OR you can invent and create your own blocks.

5 Go to https://bjc.edc.org/bjc-r/course/bjc4nyc.html

6 Complete Unit 1 Lab 1

7 Unit 1 Lab 1 Page 1: Make your account!
Finish Lab 1: Work on Lab 1: Alonzo Game. When you get to the end “Sharing your app” please share it with me! Subject Line: U1L!: Click Alonzo Game

8 MAKE SURE YOU SAVE YOUR WORK

9 The meaning of a block’s shape
Hat Blocks (Hat Shape) indicate when the script should be carried out (think event handlers) Hat block names typically start with the word “when” A script isn’t required to have a hat block, but if not, then the script will be run only if the user clicks on the script itself. A script can’t have more than one hat block, and the hat block can be used only at the top of the script; Command Blocks  (Puzzle Shape) Each command block corresponds to an action that Snap! already knows how to carry out in terms of motion.

10 Reporter / Expressions Blocks (Round Shape) Called a “reporter” because when it’s run, instead of carrying out an action, report a value.

11 Notice the round block is in the Operators palette, just like +, but in this script it’s a lighter color with black lettering because Snap! alternates light and dark versions of the palette colors when a block is nested inside another block from the same palette

12 A closer look at those Oval/Round reporter blocks
It’s called a “reporter” because when it’s run, instead of carrying out an action, it reports a value that can be used as an input to another block. If you drag a reporter into the scripting area by itself and click on it, the value it reports will appear in a speech balloon next to the block: When you drag a reporter block over another block’s input slot, a white “halo” appears around that input slot, analogous to the white line that appears when snapping command blocks together

13 Predicate Blocks (Hexagonal Shape) have a Boolean Output (they report True or False).
The special shape is a reminder that predicates don’t make sense in an input slot that are expecting a number or text. This wouldn’t make sense: But this does: Conditional Blocks (C-Shape) runs inputted script if predicate returns true.

14 What is the meaning of a block’s color?

15 Control (Gold Blocks) Hat Shape Blocks Puzzle Shape Command Blocks
EX: the script should be run when the green flag near the right end of the Snap! tool bar is clicked. My personal FAV to use in clearing the screen Hat Shape Blocks Puzzle Shape Command Blocks Conditional Blocks (C-Shape or E-Shape) The generic “when anything” block , is subtly different from the others. When the stop sign is clicked, this block no longer tests whether the condition in its hexagonal input slot is true, so the script beneath it will not run, until some other script in the project runs (because, for example, you click the green flag). HAT BLOCK’s distinctive shape is meant to remind you that is must be on the top PUZZLE SHAPE BLOCKS are also considered command blocks because they tell a script what to do

16 White Square input slots take either a number or a string.
EX: the block tells the sprite (the arrowhead shape on the stage at the right end of the window) to move ten steps in the direction in which the arrowhead is pointing. The number 10 in the move block is called an input to the block. By clicking on the white oval, you can type any number in place of the 10. Motion (Blue) Blocks Puzzle Shape Command Blocks Reporter / Expressions Blocks (Round Shape) White Square input slots take either a number or a string.

17 The Pen (Green), Sound (Pink), and Looks (Purple) Blocks
Puzzle Shape Command Blocks Reporter / Expressions Blocks (Round Shape)

18 Sensing (Light Blue) and Operators (Light green) Blocks
Puzzle Shape Command Blocks Reporter / Expressions Blocks (Round Shape) Predicate Blocks (Hexagonal Shape) We have our Boolean Operators We can get user input & use it!

19 Variables (Orange) Blocks
This palate has Command Blocks  (Puzzle Shape), Reporter / Expressions Blocks (Round Shape), Predicate Blocks (Hexagonal Shape) TWO MORE IMPORTANT FEATURES OF THIS PALATE: Make a Variable Make a Block (You can make your own function here!) The first version of Snap! was called BYOB, for “Build Your Own Blocks.” This was the first and is still the most important capability we added to Scratch. The name was changed because a few teachers have no sense of humor. You pick your battles.

20 What should I know about “Sprites”?
1) There can be more than one sprite. Just below the stage is the “new sprite” button . Click the button to add a new sprite to the stage. The new sprite will appear in a random position on the stage, facing in a random direction, with a random color. 2) A sprite doesn’t have to look like an arrowhead, but can have any picture as a costume. You can give a sprite as many costumes as you like, and then choose which it will wear either by clicking in its wardrobe or by using the block in a script. (Every costume has a number as well as a name. ) 3) Each sprite has its own scripts To see the scripts for a particular sprite in the scripting area, click on the picture of that sprite in the sprite corral in the bottom right corner of the window

21 You Try! Multiple Sprites
Try putting one of the following scripts in each sprite’s scripting area: When you click the green flag, you should see one sprite rotate while the other moves back and forth. This experiment illustrates the way different scripts can run in parallel.

22 4) Sounds in Snap!

23 5) Sprites can talk to each other using the “Broadcast” feature!
Here’s a simple example: In the block, the word “bark” is just an arbitrary name. When you click on the downward arrowhead in that input slot, one of the choices (the only choice, the first time) is “new,” which then prompts you to enter a name for the new broadcast. When this block is run, the chosen message is sent to every sprite, which is why the block is called “broadcast.” Because the boy’s script uses broadcast and wait rather than just broadcast, the boy doesn’t go on to his next say block until the dog’s script finishes. That’s why the two sprites take turns talking, instead of both talking at once. Notice the dots in the SAY BLOCKS In the text input slots, a space character is shown as a brown dot, so that you can count the number of spaces between words, and in particular you can tell the difference between an empty slot and one containing spaces. The brown dots are not shown on the stage when the block is run.

24 Examples of Broadcast working….

25 6) You can animate parts of your Sprite…
Snap! allows one sprite to be designated as the anchor of the combined shape, with other sprites as its parts. To set up sprite nesting, drag the sprite corral icon of a part sprite onto the stage display (not the sprite corral icon!) of the desired anchor sprite. Sprite nesting is shown in the sprite corral icons of both anchors and parts: Sometimes it’s desirable to make a sort of “super-sprite” composed of pieces that can move together but can also be separately articulated. The classic example is a person’s body made up of a torso, limbs, and a head.

26 U1L2 Classwork

27 Recall U1L1 Page 7 gave the following directions:

28 HW: Intro to Snap! Make a Story Project Big Idea: Creativity
50 pts Phase 1: Decide on a background and at least 2 sprites in costumes. Be creative AND APPROPRIATE! Phase 2: Brainstorm a situation that they might be in. Story should include movement (motion), words (the Say and Broadcast/or Tell blocks should be used) Should take about 45 seconds - 1 minute to run. You will me the URL before midnight on Sunday night. Late will loose points.

29


Download ppt "Unit 3: Intro to Programming Snap! Introduction"

Similar presentations


Ads by Google