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  Paint a new Sprite ◦ This brings up a Paint Editor screen where a sprite can be created using a standard paint interface with a variety of tools and a color pallet  Choose a new Sprite from file ◦ Select and of the pre-drawn Sprites that come with the program in the costumes folder ◦ Bring in other pictures on your computer  Get surprise Sprite ◦ Selects a random Sprite from the costumes folder

6  Click on a sprite. In the center of the Scratch window are three tabs for Scripts, Costumes, and Sounds  Scripts are where programs are written. Each sprite and the stage can have their own programs  Costumes are different appearances for the Sprite. Under the tab you can create and edit the costumes for each sprite  Under Sounds you can record and manage sounds the sprite might make

7  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

8  Scratch uses a Cartesian Coordinate System to locate Sprites  Each coordinate is a pair of numbers (or ordinates)  The first ordinate in the pair gives the horizontal location  The second ordinate give the vertical location Y X 1 2 3 4 5 -5 -4 -3 -2 -1 5432154321 -2 -3 -4 -5 (-5, -2) (-3, 4)

9  The middle of the stage is 0,0  The horizontal ordinate ranges from -240 to +240  The vertical ordinate ranges from -180 to +180  Click on the Cat Sprite and move it around the stage; its coordinates are shown.

10  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

11  Move – will move the sprite in its current direction  Turn – will turn the direction of the sprite  Point – will change the direction of the sprite towards a point or another Sprite  Go to – will put the Sprite at a certain location  Glide – will move the Sprite at a certain rate to a location  Change by – will change the location by a certain amount in the x or y direction  Set to – will set a specific x or y location  Bounce – will make the Sprite bounce if it hits the edge of the screen  x, y, direction boxes – Will place the x, y, or direction values for the Sprite on the screen

12  Costume – will change the costume of the Sprite  Say – will put a box on the screen for a Sprite to say the Text entered  Think – will put a bubble on the screen for a Sprite to think the Text entered  Effects – will change the color or other effects for the Sprite  Glide – will move the Sprite at a certain rate to a location  Size – will change the size of the Sprite  Show/Hide – will either show or hide the Sprite from view  Go to – will set the Sprite to be in front of the other Sprites, or to move behind them

13  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

14  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

15  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)

16  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

17  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”

18  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

19  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.

20  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