August 30 Intro to CS.

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
1 An introduction to programming concepts with Scratch.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
ACO 101 Making a program. mb_your_brain_on_improv.html mb_your_brain_on_improv.html.
Summer Computing Workshop. Introduction  Boolean Expressions – In programming, a Boolean expression is an expression that is either true or false. In.
2015 CSE/EGR Summer Camps 1 Computer Science Concepts 1. What is an algorithm? 2. Binary information coding 3. Programming concepts via Scratch Designed.
Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch Paul Tennent
Using MIT Scratch for Programming and Control Exercise 1 Creating movement Year 11 DTG 2012.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
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.
Vex Robotics program three: using motors and sensors together.
Intro CS – Logic & Operators Lesson Plan 5. Goals  Students can explain basic logical operators  AND, OR, NOT  Students can create truth tables for.
Introducing Scratch Learning resources for the implementation of the scenario
Functions / Blocks.
BIT116: Scripting Lecture 05
August 25 Intro to CS.
Creating a UFO Rescue Game in Alice
Scratch Helicopter Game
Development Environment
Introduction to Programming
Create a Halloween Computer Game in Scratch
Intro CS – Screens and Variables
Broadcasting (Adding a new level)
A Simple Quiz for Alice 3.2:
August 31 Intro to CS.
Games Programming in Scratch
Scratch for Interactivity
Chapter 1: An Introduction to Visual Basic 2015
Intro to CS Sept 22/23, 2015.
ECS 9/7/17.
Intro to CS Monday, August 29
Intro to CS Monday, August 24
Creating a UFO Rescue Game in Alice
Scratch for Interactivity
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Introduction to Object-Oriented Programming
Conditional Statements
Selection CIS 40 – Introduction to Programming in Python
Introduction to Programming
Learn… Create… Program
Introduction to TouchDevelop
UNITY TEAM PROJECT TOPICS: [1]. Unity Collaborate
Getting Started with Scratch
A Simple Quiz for Alice 3.2:
Go to =>
Learn… Create… Program
Loops CIS 40 – Introduction to Programming in Python
Introduction to TouchDevelop
Lesson 3.2 Review: Identifying concepts
Getting Started with Scratch
Game Over Module 4 Lesson 2.
Introduction to Snap Programming
Learn… Create… Program
Learn… Create… Program
Introduction to Programming
Running a Java Program using Blue Jay.
creating a ecosystems model in net logo
Creating a Simple Game in Scratch
An Introduction to Designing and Executing Workflows with Taverna
Restricting Events Creating Conditional Events in Alice By Henry Qin
Presentation transcript:

August 30 Intro to CS

Today’s Objectives More Boolean Broadcast and Ask & Answer Custom Blocks Layers Work on your project

Review: More Boolean (“AND”) Lincoln Lion = Dana Ave AND 9-12 grade AND In Intro CS Which one(s) are true? Condition # School on Dana? 9-12? In Intro CS? Lion CS programmer! 1 2 3 4 5 6 7

Review: More Boolean (“AND”) Lincoln Lions = Dana Ave AND 9-12 grade AND In Intro CS Which one(s) are true? Condition # School on Dana? 9-12 In Intro CS? Lion CS programmer! False 1 True 2 3 4 5 6 7

Review: More Boolean (“AND”) Lincoln Lions = Dana Ave AND 9-12 grade AND Intro to CS Do you see a pattern in the table? Condition # School on Dana? 9-12? In Intro CS? Lion CS programmer! False 1 True 2 3 4 5 6 7 TRUE

More Block use More Boolean Parallelism Broadcast Ask/Answer If/Else Repeat Forever Broadcast More Boolean Parallelism Broadcast Ask/Answer Ask/Answer

SNAP! Broadcast What does this do? It puts the scripted value into “message” system variable

SNAP! Ask and Answer What does this do? It puts the value typed by the keyboard into “answer” system variable

Constructing Boolean expressions Condition A Condition B Condition C Expression Wednesday Sunday 9-3 cVSFarmersMarketOpen cVSFarmersMarketOpen = (Wednesday AND 9-3) OR (Sunday AND 9-3)

Constructing Boolean expressions Condition A Condition B Condition C Expression Wednesday Sunday 9-3 CVSFarmersMarketOpen floorLamp tableLamp pgePowerPresent ARoomLightOn deadBattery noGas ----- CarWontStart CVSFarmersMarketOpen = (Wednesday AND 9-3) OR (Sunday AND 9-3) ARoomLightOn = (write this on your paper) CarWontStart = (write this on your paper)

Constructing Boolean expressions - ANSWER Condition A Condition B Condition C Expression Wednesday Sunday 9-3 CVSFarmersMarketOpen floorLamp tableLamp pgePowerPresent ARoomLightOn deadBattery noGas ----- CarWontStart CVSFarmersMarketOpen = (Wednesday AND 9-3) OR (Sunday AND 9-3) ARoomLightOn = (floorLamp AND pgePowerPresent) OR ( tableLamp AND pgePowerPresent) = ( floorLamp OR tableLamp) AND pgePowerPresent CarWontStart = deadBattery OR noGas

Class Assignment – Write Truth Tables Wednesday Sunday 9-3 CVSFarmersMarketOpen Fill in with all the rows and combinations Evaluate each combination floorLamp tableLamp pgePowerPresent ARoomLightOn Fill in with all the rows and combinations Evaluate each combination deadBattery noGas CarWontStart Fill in with all the rows and combinations Evaluate each combination

Today’s Objectives Review More Boolean Custom Blocks Stage Scripting and Layers Work on your project

Make Block or Right click on empty space in Script Area this dialog box will appear. or Press “Make Block” button in Variables and this dialog box will appear.

Make Block, continued Fill in the name of your block Choose all Sprites or This Sprite only Default choice is “Command” Click OK

Make Block, continued After OK this Block Editor appears Can write a script in the Editor Can drag a script into the Editor Click OK

Make Block, continued Write your code Click OK Done! Look in Variables for your custom block

Make Block (with Reporter) You can re-edit Block Right Click on the block The yellow menu pops up Select “edit “ and make your changes

Make Block (with Reporter) Right click on empty space in Script Area this dialog box will appear. or Press “Make Block” button in Variables and this dialog box will appear.

Choose “Reporter” option Fill in the desired Name Choose “Reporter” option here Click OK

Now make some inputs Click on the “+” on the right and name your inputs This is the “report” block

Now add your code I clicked the “+” sign 4 times I named each input as shown

Done! Sum = num1 + num2 + num3 + num4 “report” the Sum back to the caller

How to use the “reporter” block You now have a custom block which adds 4 numbers and reports the Sum back to the caller/user You can use with any 4 hard coded numbers you want or The custom block can use the values in the variables.

Lab: Make a “HeroWalksRight” custom block Only 7 instructions needed Be sure and include comments Does everything it needs to do!!

ANSWER: Make a “HeroWalksRight” custom block

Today’s Objectives Review More Boolean Custom Blocks Stage Scripting and Layers Work on your project

Two “Looks” commands – goto front , go back N layers Front, -2 layers Front, -1 layer Front layer With these 2 commands, you can control where the scenery resides.

Layers, continued - SNAP! will put your Sprites somewhere. Don’t know where. You must tell SNAP! which layer each Sprite belongs to. Procedure – Step 1. Each Sprite must be told goto front in order to start from a known layer. Step 2. Each Sprite is now commanded to the proper layer with go back N layers. In this way a mountain can be behind a tree, the tree can be behind Mario and Mario and the gremlin can occupy the front layer.

Stage scripting Click on Stage icon Scripts just like for Sprites Broadcast messages

Stage scripting Click on Stage icon Scripts just like for Sprites Broadcast messages This runs Mario Sprite only which is useful for debug

Today’s Objectives Review More Boolean Custom Blocks Layers Work on your project

Initialization Logic for the Hero Sprite (“Program is repeatable and initializes state correctly.”) Code is executed BEFORE Game starts Set the desired layer Set desired position Set the desired size Set the desired costume

Rest In Peace (R.I.P.) – Game over Logic (“Program is repeatable and initializes state correctly.”) Starts when the game starts forever checking if <Mario and Gremlin touching> Game Over!

Open Lab: Work on your Project Where should I start? Start with the project spec. There are least two scenery sprites (example: a tree and a mountain) Scenery sprites are layered with Mario (example: appropriate layering blocks are in your program) Scenery sprites move based on Mario’s movement Scenery sprites move at different speeds (e.g. the mountain far away moves slower than the nearby tree – just like when you look out a car window) Scenery sprites roll over when the fall of the stage

Reminders Read Chapter 1 Quiz next week Test on Friday, Sept 4 on computer processing, abstraction Boolean operations, and SNAP!

Looking ahead … Monday Tues / Weds Thurs/Fri TODAY 8/25-26 8/27-28 BACK TO SCHOOL NIGHT 8/31 TEST #1 9/1-2 QUIZ #1 9/4 LABOR DAY – NO SCHOOL 9/8-9 PROJECT #1 DUE 9/11 PROJECT #1 Due @ 6pm

Design first – small manageable sections Mario Initialize : costume, position Right Arrow : costume, move right, costume change, move right, etc. (check for Right Edge & wrap) Left Arrow : costume, move left , costume change , move left , etc. (check for Left Edge & wrap) Up Arrow : move up, wait, move down R.I.P. : Mario and Gremlin are touching

Design first – small manageable sections Tree Initialize: position Right Arrow: point left , move left, check for left edge (wrap or bounce) Left Arrow: point right, move right, check for right edge (wrap or bounce)

Lab Exercise: Design Gremlin and Mountain on paper – 10 min All possible inputs are shown - but may not be relevant to the Sprite What happens on RIP (Rest In Peace – the hero dies) Mountain Initialize: yy Right Arrow: yy Left Arrow: yy Up Arrow: yy RIP: yy Gremlin Initialize: yy Right Arrow: yy

What does it mean? Same as going to MacDonalds… Front counter where you give your order Different orders - different input

What does it mean? Ann : Cheeseburger Water No (false) Fries? Ann : Cheeseburger Water No (false) Jim : Fish Coffee No (false) You : Big Mac Coke Yes (true)

Creating Broadcast messages Step 1. Create a message by choosing “new”. Step 2. SNAP! Opens a dialog box where you invent the name of your Message Step 3. Click “OK”

Parallelism ( also called threads) These are 5 different streams of instructions/code also called threads. Program Counter can’t be in 5 different places at the same time!! SNAP executes a few instructions in one stream and then moves to the next. 1 GHz = 1,000,000,000 instructions in 1 second Makes it appear that each stream/thread is executed simultaneously.

Advanced Blocks – using inputs We will write code together as a class From the rubric, it says the Hero… “ Must be able to walk anywhere - left, right, up or down” “Make Block” with inputs You can write 6 or 7 lines of code and use it for Gremlin, Tree and Mountain. Why not Mario?

Lab Exercise: Make Block, continued Name your block - “FancyWalk” Choose all Sprites, or , This Sprite only Click OK

Lab Exercise: Make Block, continued Block Editor appears with the name of the block Click on the “+” sign Type the name of your input LeftOrRight Click OK

Lab Exercise: Make Block, continued You now have a Block with an input Click on the “+” sign again

Lab Exercise: Make Block, continued Type the name of your 2nd input: UpOrDown Click OK

Lab Exercise: Make Block, continued Your Custom Block now has 2 inputs Now add the script

Lab Exercise: Make Block, continued After you have constructed your script … Drag the input names as shown in the figure Now let’s run SNAP, initialize and see it work!!

Test Review SNAP! Broadcast Ask/Answer Variables System Global Local Layers Costumes Terminology Sprite, Script, Stage, Scripting Area, Blocks, Tabs Custom Blocks

Test Review Computer Architecture Parallelism Boolean Logic Main Memory Program Memory ALU Variables Program Counter Parallelism Definition Boolean Logic AND, OR, NOT Truth Tables