Functions / Blocks.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Section 1 Introduction National 4/5 VB Course. What you should know after this lesson What is a program Who writes programs Why is sequence important.
Scratch for Storytelling Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Harry Potter Scratch Game
Mr. Wortzman INTRO. TO COMPUTER SCIENCE. UNIT 1 – CUSTOM BLOCKS.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
INTRODUCTION TO THE SCRATCH PROGRAMMING ENVIRONMENT.
Ms. Deveny Second Semester  Introductions  Interview your table partner  Name  Why taking CPD  Computer experience  Favorite game?
We will be creating a spaceship that simulates real movements in space. The spaceship will fire a laser beam that can destroy targets. The spaceship will.
Introducing Scratch the Cat
 Review  Created our own motion block called “draw square”  Used script to create a square with side lengths of 100 steps.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Section 1 Introduction National 4/5 Scratch Course.
Chapter 9 Macros And Visual Basic For Applications.
Algorithms Writing instructions in the order they should execute.
Creating a Simple Game in Scratch Barb Ericson Georgia Tech June 2008.
TRIGGERS Triggers tell a script to start executing There are four types of triggers: When green flag is clicked When I am clicked When is pressed When.
Summer Computing Workshop. Session 3 Conditional Branching  Conditional branching is used to alter the normal flow of execution depending on the value.
Making a Sprite Dance Barb Ericson Georgia Tech June 2011.
1 Use different costumes in Scratch to make an animation effect Synchronise interaction between 2 or more sprites Lesson 3: Learning Objectives.
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Programming Modeling a Passive Solar Home.
Drawing with the Pen Barb Ericson Georgia Tech June 2011.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Introduction to Computer Programming - Project 1 Intro to Digital Technology.
Scratch for Interactivity Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
How to create a basic game in Scratch. The Scratch Stage The Scratch stage is 480 pixels wide and 360 pixels high x increasesx decreases.
Digital Art in Scratch part 2 Barb Ericson Georgia Tech Nov 2010.
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
Today's Ninja Challenge: Write Your First Computer Game!
Computer Programming Modeling a Passive Solar Home.
Computer Programming with Scratch JAOIT 8. Scratch Scratch is a programming language that makes it easy to create your own interactive stories, animations,
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Drawing in Scratch We will be using the Scratch Environment today, so please log in to the Scratch website (scratch.mit.edu)
Introducing Scratch Learning resources for the implementation of the scenario
Scratch Programming Cards
Module 2: Investigation 2
Introduction to Scratch
Create a Halloween Computer Game in Scratch
August 31 Intro to CS.
Scratch for Interactivity
Building with Numbers Module 4: Investigation 3
Understanding the Geometric Shape Code
ECS 9/7/17.
August 30 Intro to CS.
Intro to CS Monday, August 29
Radial differentiation slide
Intro to CS Monday, August 24
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Introduction to.
Getting Started with Scratch
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Lesson 3.2 Review: Identifying concepts
Unit 3: Intro to Programming Snap! Introduction
Introduction to Snap Programming
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Getting Started with Scratch
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Mod 2 Lesson 2 Repeating with loops
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Creating a Simple Game in Scratch
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
Pen Cards Pen Cards Back and Forth Draw a Line Special Effects
2 Making Blocks.
Presentation transcript:

Functions / Blocks

Why USE You have code that you are repeating in multiple places i.e. redundant code By putting in an block, you can make a change in one place and have that change affects every place you use the block Related piece of code

Types of Blocks Note the Shape: Note the Shape: Note the shape: Command Reporter Predicate Note the Shape: Note the Shape: Note the shape:

How to make a block Right-Click on the Scripting Area Select make a block … The Make a block dialog appears Select the Category Type the name of the Block and press OK

Add code to the Block Drag blocks into the scripting area within the Block Editor Click Apply Note that the block now appears in the Palette in the category that you chose – Pen in this case. Click OK Use that block like others

How to make a block with inputs Right-Click on the Scripting Area Select make a block … The Make a block dialog appears Select the Category Type the name of the Block make polygon and press OK Click the + between make and polygon The Create input name dialog appears Give the input a name sides

Make a block with inputs Add code to the script To use the input, click on the input name sides and drag it where you want to use it. Click Apply The block shows up in the palette User can input a value where sides is in the block.

Exercises Create a draw house block that uses your draw square and draw triangle blocks together to draw a "house" shape: a square with a triangular shaped roof sitting on top. (You might have to do some debugging to get the two shapes to connect properly.) Build a draw row of houses block that draws a row of attached houses, each new one to the right of the previous, until the sprite moves too close to the right edge of the screen. For that, you will need repeat until. Create a honeycomb block (with an input to let you control the size) that uses your hexagon block three times to create this design:  http://bjc.edc.org/bjc-r/cur/programming/1-introduction/3-building-blocks/1-custom- blocks.html?topic=nyc_bjc%2F1-intro- loops.topic&course=bjc4nyc.html&novideo&noassignment

Reporters and Predicates

Blocks that return a value - Reporters Note the Shape:

Predicates - Blocks that return a BOOLean Booleans are TRUE or FALSE values

How to create a visual Score

Visual Scores Goal

Visual Scores Goal

Visual Scores Goal

Visual Scores Add 2 sprites for each score

Visual Scores Add in costumes for each of the digits Get costumes from C:\BYOB\Media\Costumes\Letters or the web Drag and drop the 10 costumes into each costume.

Visual scores Add code to both number sprites to orient the number correctly when the game is started. Add code to broadcast a score change Add code to receive that broadcast in the “ones” digit of the visual score.

Visual Scores Add code to the “tens” digit to update the score.