Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Create a Simple Game in Scratch
Summer Computing Workshop. Introduction to Variables Variables are used in every aspect of programming. They are used to store data the programmer needs.
Create a Simple Game in Scratch
Harry Potter Scratch Game
Mr. Wortzman INTRO. TO COMPUTER SCIENCE. UNIT 1 – CUSTOM BLOCKS.
1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Learn… Create… Program. Manipulation of Multiple Media Connects with youth culture Scratch is a new graphical programming language designed to support.
1 An introduction to programming concepts with Scratch.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech Oct 2010.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
INTRODUCTION TO THE SCRATCH PROGRAMMING ENVIRONMENT.
Summer Computing Workshop. Session 4 Loops  At the heart of their functionality, loops enable blocks of code to be executed more than once  Loops represent.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
Ms. Deveny Second Semester  Introductions  Interview your table partner  Name  Why taking CPD  Computer experience  Favorite game?
Introduction to Scratch!
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Spiral Rider PAGE 1. Set Up Scene 1.Add Stage-underwater scene 2.Add crab sprite 3.Add two fish sprites PAGE 2.
Programming & Scratch. Programming Learning to program is ultimately about learning to think logically and to approach problems methodically. The building.
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.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Scratch Programming Lesson 4 Question asking and answering.
Game Maker – Getting Started What is Game Maker?.
Digital Art in Scratch part 1 Barb Ericson Georgia Tech May 2011.
Fish Chomp. The screen where you can see what happens when you play your game is called the STAGE. The SCRIPT BANK is where the types of instructions.
Algorithms Writing instructions in the order they should execute.
CONTROL FLOW The order in which blocks are executed is called the “control flow” of the script So far all our scripts have just executed blocks in the.
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.
Scratch Another computer programming language Developed by MIT in 2003
Create a Halloween Computer Game in Scratch Stephanie Smullen and Dawn Ellis Barb Ericson October 2008.
Computer Programming Modeling a Passive Solar Home.
24 Background Building 25 Computing Terminology, and Speed/Velocity Module 4 Notes: Sensing, Or Operator, Conditional Logic 28 Module 4 Algorithms,
Introduction to Computer Programming - Project 2 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.
1 CSC 221: Computer Programming I Fall 2009 Introduction to programming in Scratch  animation sprites  motion, control & sensing  costume changes 
Creating a Simple Game in Scratch Barb Ericson Georgia Tech May 2009.
Introducing Scratch Learning resources for the implementation of the scenario
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Functions / Blocks.
Create a Halloween Computer Game in Scratch
Programming & Scratch.
Scratch for Interactivity
Exploring Mathematical Relationships Module 5: Investigation 3
Understanding the Geometric Shape Code
ECS 9/7/17.
Intro to CS Monday, August 29
Intro to CS Monday, August 24
Scratch for Interactivity
Learning to program with Logo
Introduction to.
Learn… Create… Program
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Go to =>
Learn… Create… Program
Introduction to TouchDevelop
Go to =>
Game Over Module 4 Lesson 2.
Learn… Create… Program
Learn… Create… Program
Creating a Simple Game in Scratch
CSC 221: Introduction to Programming Fall 2018
Presentation transcript:

Mrs. Chapman

Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project

 The Stage is where the action happens  You will add objects called sprites to the stage and they will act based on their scripts  Notice the coordinates in the lower-right

A class is a template in programming used to create an object. A class in SNAP is a Sprite. You choose the sprite class and create an object from it. These are the main elements of your BYOB programs  Each object created has one or more commands (methods) that determine how the object acts under different circumstances.  Objects can have different costumes that change their appearance or attribute.  BYOB provides a bunch of built-in sprites and costumes, or you can design your own.

 A method is a group of code that performs a certain action.  Methods control an objects actions.  You can also write methods to change the stage area.  All methods in SNAP must have a trigger or event handler and some operations  When the event handler happens, the object will perform the commands in order. - Sequential order one after the other.  What does this method do? trigger operations

 The different types of blocks are listed in the upper left of the BYOB window  “Motion” blocks cause objects to move  “Looks” blocks change an object’s appearance  Etc.  Each block corresponds to one “action”  Notice the shapes!  When a script runs, the actions occur in the order in which the blocks appear in the script.

 Exercise: Write an algorithm to do the following:  Move the sprite 25 steps,  Have the sprite say your name for 3 seconds  Turn the sprite around and move it back where it came from  Have the sprite say “I love BYOB!” for 5 seconds

 Blocks in the Pen category allow your sprites to draw things on the stage  The block puts a sprite’s pen down on the stage. The block picks the pen up.  When a sprite’s pen is down, moving will cause it to draw.  You can also change the pen’s color, size, or shade.

 Exercise 1: Write an algorithm to make your sprite draw a square with 50 step sides.  Exercise 2: Once you’ve done that, write an algorithm to draw two squares next to each other  The squares should not be connected by a line

 Triggers tell an object to start executing  There are four types of triggers:  When green flag is clicked  When I am clicked  When is pressed  When I receive a message ▪ more on messages later

 Exercise: Rewrite your square drawing algorithm to draw a square whenever the space bar is pressed. Clear the screen before each new square.

 You can build multiple scripts in the script area for any sprite (or the stage)  All these scripts run at the same time (assuming their triggers occur)  Each script is called a “thread”

 Exercise: Write scripts to allow the user to move a sprite around the stage with the arrow keys.

 If you right-click on the script area, you get an option to “add comment”  Comments are used to describe what’s going on in the code. In BYOB, they look like this:  They do not execute.

 BYOB comments can be attached to blocks to indicate to what they are referring:

 You should use comments to:  Describe the basic, high-level behavior of any script  Explain anything potentially unclear or tricky  Explain why you chose to do something a certain way if there were multiple options  Etc.  Get in the habit of using comments now. You’ll be graded on them (especially in Java)!

 The order in which blocks are executed is called the “control flow” of the script  So far all our scripts have just executed blocks in the order given  Consider our script to draw a square  Notice all the repeated code  Wouldn’t it be nice if there were a way to simplify this?

 Loops cause the object to repeat a certain set of commands multiple times without having to repeat the blocks  Loop blocks in SNAP have the symbol at their bottom right  This indicates that when the end of the loop is hit, the next block executed is back at the beginning  There are several types of loops in SNAP:

 Exercise 1: Rewrite the script to draw a square using loops. Try not to repeat any code.  Exercise 2: Now rewrite the script to draw two squares next to each other using loops. Again, try not to repeat code.  This is tricky!

 Thought exercise: How can we make objects move at different “speeds”?  Variables allow us to store data and modify or retrieve it later  Check out the Variables category  Look around for built-in variables  What shape are variable blocks?

 When we click “Make a variable” we get a dialog box  The name can be anything you want  “For all sprites” means all sprites/objects will be able to see and edit the variable. This is a global variable. ◦ Why might this be useful? Why might it be dangerous?  “For this sprite only” means only the current sprite can see and edit it. This is a local variable.

 You can ask the user for input using  The response is stored in  Note that is just a built-in variable  Often, you’ll be storing the input in a variable for later use

 Exercise 1: Write an algorithm to do the following:  Ask the user for a number between 1 and 10  Draw that many squares  Exercise 2: Write an algorithm to do the following:  Ask the user for a number between 1 and 10  Ask the user for a number between 1 and 255  Draw the first number of squares with the pen color set to the second number

 So far, we’ve only used simple numbers  It would probably be nice if we could do some math  Check out the Operators category  The first four blocks are your basic arithmetic operators  At the bottom are some more useful operations  As always, notice the shapes– where can we use these blocks?

 Exercise: Write an algorithm to do the following:  Ask the user for a number between 1 and 5  Draw twice that many squares

 See the hexagon-shaped hole in ? What goes there?  Look around for blocks with that shape. What does it look like they do?  Hexagon-shaped blocks represent Boolean expressions ◦ Named after 19 th century English mathematician George Boole  Boolean expressions evaluate to either true or false

 Boolean expressions are used in conditions  Conditions control whether or not certain blocks are executed  The blocks inside of an “if” are executed if and only if the condition is true  The blocks inside of an “else” are executed if and only if the condition is false  Look at the “Sensing” category for lots of interesting things you can test

 You can also use conditions in loops  is like forever, but the body only executes when the condition is true ▪ Will stop then start again if things change  loops until the condition is true, then moves on  Play with these, as they can be quite useful

 Boolean expressions can be combined in certain ways  An and expression is true when both parts are true  An or expression is true is when at least one part is true  A not expression is true when the component expression is false

 Truth Tables: ANDTF TTF FFF ORTF TTT FTF NOT TF FT

 Exercise 1: Write an algorithm to do the following:  Generate a random number between 1 and 10  Draw a red square if the number is less than 6  Draw a blue square if the number is 6 or greater  Exercise 2: Write an algorithm to do the following:  Generate two random numbers between 1 and 10  If both are less than 6, draw a red square  If both are 6 or greater, draw a blue square  Otherwise, draw a purple square

 Sprites can cause each other to act in certain ways by using and  This sends out a message which can be picked up by other objects  These messages are called events  Events have unique names, and any sprite can broadcast or listen for any event

 Exercise: Implement “Marco Polo”  Create one object at the center of the stage  Create another object at a random location and hide it  The arrow keys control the motion of the first object  When space is pressed, the first object should say “Marco” after which the second sprite should briefly show itself and say “Polo”  If the first sprite says “Marco” when it is touching the second, the second sprite should appear and say “Found me!”