1 / 14

Introduction to Scratch

Introduction to Scratch. Computer Programming Modeling a Passive Solar Home. What is Scratch?. Scratch is a visual computer language Uses graphical blocks to create a program as opposed to typewritten commands. Output is primarily visual

adina
Download Presentation

Introduction to Scratch

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Scratch Computer Programming Modeling a Passive Solar Home

  2. What is Scratch? • Scratch is a visual computer language • Uses graphical blocks to create a program as opposed to typewritten commands. • Output is primarily visual • Made to be simple to use, but it contains all the elements of a programming language

  3. Overview • The output is displayed on a stage, which can have several different backgrounds • Sprites arecharacters or objects that are moved about the stage and which also can change appearance • The inputs and results of calculations are also displayed on the stage • Scripts, or programs, are used to change the background and to move or change the appearance of sprites

  4. Sprites • Characters or pictures in the animation that you can manipulate • Move, Glide, Shrink, Grow, Alter, appearance • The first Sprite that shows up is the Cat • In the lower right hand part of the screen are where the Sprites are loaded, created, or altered • Sprites do not have to be characters. They can also be objects that you want to change or move, such as a lamp that can be on or off or a ball moving across the screen

  5. Stage • The white area in the upper right that has a background and on which the sprites move. • The stage can have multiple backgrounds which can be changed by the script • Selecting Stage, just to the left of the Sprites, brings up three tabs for the stage in the center of the window: Scripts, Backgrounds and Sounds • Under the Background tab, you can load in pictures that will serve as the background behind your Sprites. • You can paint a background, import a background that Scratch provides (in the Backgrounds folder), or import in your own background picture

  6. Scripts • Scripts are the computer programs that govern the movement and appearance of each Sprite or Background • They are created by dragging commands from the left column into the center column • Commands are arranged in categories shown in the upper right of the window

  7. Calculations and Values • Variables hold numeric values • Create them under the “variables” commands • Can set or change a variable using “set” and “change” commands • Operators perform calculations • Addition, subtraction, multiplication • Operands include existing variables and numbers • Operators give results that are used in “set”, “change”, “move to”, and other commands

  8. Controlling the Program • Start – starts the script via flag, message, or clicking • Stop – stops the script or all of the scripts • Loops let you repeat parts of a script • Other control blocks allow a script to change its behavior if certain conditions are met

  9. A Simple Calculator • Follow the steps below to create a program to add two numbers together. • Steps • Open scratch and click on the “stage” in the lower right. • Select backgrounds in the middle panel, then “edit” • Use the line tool to draw a “+” and a line, as one might do for addition with a pencil and paper. • Move the Cat sprite out of the way (we won’t use the sprite in this example)

  10. Create Variables • Select “Variables” in the upper left • Select “Make a Variable” and create three variables. Suggested names are “number 1”, “number 2”, and “sum”. These appear on the stage. • Move them so theymake sense, withthe sum below theline and the numbersabove

  11. Write the script • Click on the “Script” tab in the center panel • Click on “Control” button on the upper left and drag the “When stage clicked” into the center panel • Click on the “variables” button and drag the “set” block to the center panel, just under theexisting piece. A white line will appear that will tell you when the piece is fitting correctly. • Use the small arrow in the “set” block to change the variable from “number 1” to “sum”

  12. Write the script (continued) • Click on “Operators” in the upper left • Drag the top operator (with the plus) so that it falls into place on the “set” block where the 1 used to be • Go back to the “variable” area and drag the “number 1” and “number 2” variables into the “+” operator. The placeholders will be highlighted when the fit is correct. • Go back to the “control” area and drag the “stop script” block to theend of the script

  13. Run the Script • On the stage, double-click on the “number 1” and “number 2” variables. Both will have a small slider beneath them. • Double-click twice on the “sum” variable. It will turn into a larger number. • Use the sliders to changevalues of“number1” and “number 2” • Single-click anywhere onthe stage and the value of “sum” will change to be the sum of the other two variables.

  14. Activity • Use scratch to calculate the change in temperature in a house due to heat loss

More Related