Presentation on theme: "Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch Paul Tennent http://paultennent.wordpress.com/G50PRO.html."— Presentation transcript:
1 Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch Paul TennentRoom C41
2 What is Scratch?Scratch is a free programmable toolkit that enables users to create games, animated stories, and interactive artEnables users to share programs over the InternetScratch is developed by the Lifelong Kindergarten Group at the MIT Media Lab, with funding from the National Science Foundation, Microsoft, Intel Foundation, Nokia, and the MIT Media Lab research consortia.
4 Getting Started With Scratch Open new projectChoose, create or edit your SpriteChoose your backgroundWrite your program
5 Programming In Scratch Click on the sprite you want to program, and select the “Scripts” tab.The Scripts area is where you “build” your program by using the programming blocks.In the upper, left-hand corner of your Scratch window, you will see 8 buttons .Each of these buttons have programming blocks in those particular areas.
6 Programming In Scratch To program a sprite, drag blocks from the Blocks Palette to the Scripts Area. To run a block, click on it.Create scripts (programs) by snapping blocks together into stacks. Click anywhere on the stack to run the whole script, from top to bottom
7 Scratch StageThe Scratch stage is 480 pixels wide and 360 pixels high.180240-240-180
8 Scratch Blocks Motion Control and Sensing Animate sprites controls how many times an event happens, how long an event happens, or when an event happens.conditional statements (“if statements” or “if-else statements”)Write code so that if the user presses the Space key on the keyboard, the sprite will move 20 steps and change direction.
10 Starting From ScratchScratch has all of the common elements used in all programming languages.Conditional statementsLoopsVariablesEvents
11 Branching (Conditional Statements) Make TeaSTARTIs kettlefull?Fill kettleyesnoBoil Kettle
12 Conditional Statements If [Boolean]ThenDo thisElseDo the other
13 Comparisons == Equals < Less than > More than <= Less than or equal to>= Greater than or equal to!= Not equal to
14 Loops Simplify the coding of repetitive tasks Giving the people in a company a 10% riseEmployee 1 salary = 1.1*Employee 1 salaryEmployee 2 salary = 1.1*Employee 2 salary…Employee 99 salary = 1.1*Employee 99 salary
15 Loops Simplify the coding of repetitive tasks Giving the people in a company a 10% riseFor i = 1 to 99Employee i salary = 1.1*Employee i salary
16 Loops There are a lot of different standard types of loop Scratch only has some of them
17 Flow control Flow control In computer science flow control refers to the order in which the statements or instructions are executed or evaluated.Branches (Conditional Statements)Loops
18 Variables a variable is a facility for storing data One of the most powerful features of a programming language is the ability to manipulate variables.A variable is a named location that stores a value.Values are things that can be printed, stored or operated on. (numbers, letters, Strings, etc.)
19 Variables each variable will have Name Value Location in memory X = 100Y = 20
20 Assignment statement Declare str str = “Hello” the idea is straightforward:When you declare a variable, you create a named storage location.When you make an assignment to a variable, you give it a value.
22 Events You can’t run all of the elements of a program at once Things happen when the relevant event triggers themThe main event in Scratch is the green flagThere are other custom events that you can add
23 Summary Scratch Programming Blocks Conditional Statements allow us to make decisions about what to do nextLoops allow us to perform repetitive tasksVariables record the values and state of elements of a programEvents trigger different elements of the program to be run at the correct time