Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming Modeling a Passive Solar Home.

Similar presentations


Presentation on theme: "Computer Programming Modeling a Passive Solar Home."— Presentation transcript:

1 Computer Programming Modeling a Passive Solar Home

2  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  The output is displayed on a stage, which can have several different backgrounds  Sprites are characters 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  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  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 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 Motion Looks Sound Pen Control Sensing Operators Variables

7  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  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  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  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 they make sense, with the sum below the line and the numbers above

11  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 the existing 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  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 the end of the script

13  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 change values of “number 1” and “number 2”  Single-click anywhere on the stage and the value of “sum” will change to be the sum of the other two variables.

14  Use scratch to calculate the change in temperature in a house due to heat loss


Download ppt "Computer Programming Modeling a Passive Solar Home."

Similar presentations


Ads by Google