Download presentation
Presentation is loading. Please wait.
1
August 25 Intro to CS
2
Let’s review last class…
Blocks 1 Sprite 3 Comments 6 Stage 4 1 2 3 4 5 6 Script 5 Script area 2
3
Let’s review last class…
Identify by name the parts of SNAP! Give examples of blocks in each category Explain the function of control blocks Build, comment and run a simple SNAP! script Script, Blocks, Stage, Sprite Controls the actions of the Sprite Hello World!
4
What you’ve learned SNAP IDE: How to login
How to select the desired palette of instructions What is the “Script Area” What is the “Stage” area How to make a “comment” and attach to an instruction block
5
What you’ve learned Motion blocks: Control blocks Looks and Pen instructions
6
Today’s Objectives How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a Sprite
7
Today: Exploring More Blocks
8
Advanced Blocks
9
Advanced Blocks
10
Go to File Import Tools (to get additional functions.
11
Help! (or, How to get instruction help)
Cursor on instruction Right Click Choose “help…” On a MAC: CTRL + Click == right click
12
Result of right click help
13
Today’s Objectives How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a Sprite
14
Boolean Operations What is a BOOLEAN OPERATOR?
Conditions that when evaluated result in the answer of “true” or “false.” George Boole, Mathematician Examples: The sun is shining right now in San Jose (TRUE). I am under 16 years old. (FALSE) The classroom light switch is on. (TRUE)
15
Boolean Operations Examples:
You can create IF / Then situations using Boolean Conditions Examples: IF The sun is shining right now in San Jose, I am under 16 years old, The classroom light switch is on, THEN Turn off the street lights. Make sure I am not driving. The lights should be on.
16
Boolean Operations Examples:
You can COMBINE operations, and the result still will be either True or False. Examples: IF It is between 8am and 2pm, AND It is a Friday, THEN Ring the Lincoln bells.
17
Boolean Operations Examples:
You can COMBINE operations, and the result still will be either True or False. Examples: IF The light switch by the classroom door is on, OR The light switch by the library door is on, THEN The lights should be on.
18
AND (both have to be true)
Battery Switch A Switch B Is Switch A closed? Is Switch B closed? The Lightbulb ON? No False Yes TRUE!
19
OR (either one has to be true)
Battery Switch A Switch B Switch A closed Switch B closed? Lightbulb ON No False Yes True
20
NOT (the inverse) In these cases, Yes ==True == 1 No == False == 0
Battery Switch A Switch B Switch A closed Switch A is NOT closed No True (Yes) Yes False (No) In these cases, Yes ==True == 1 No == False == 0
21
SNAP! Operators How do Boolean Operators in SNAP! work? The same way.
Conditions that when evaluated result in the answer of “true” or “false.”
22
SNAP! Operators If BOTH Condition “A” and Condition “B” are true,
then TRUE If EITHER Condition “A” or Condition “B” is true, then TRUE If NOT Condition “A” then TRUE When you NEST boolean operators, solve inside out
23
Lab: Build this compound Boolean expression
If BOTH Condition “A” and Condition “B” are true, then TRUE If EITHER Condition “A” or Condition “B” is true, then TRUE If NOT Condition “A” then TRUE When you NEST boolean operators, solve inside out
24
Lab: Solve this compound Boolean expression
A and (B or (Not A) ) No Yes A B A and (B or (Not A) ) 1
25
Lab: ANSWER A B (Not A) (B or (NotA) A and (B or (Not A) ) No Yes
No (False) Yes (True) A B (Not A) (B or (NotA) A and (B or (Not A) ) 1
26
Where are Boolean operators used?
These are instructions from the “Control” palette The triangular shape is a clue that a Boolean operator needs to be inserted. These instructions “Control” the code flow based on when a condition becomes true or off Let’s look at some examples
27
Boolean Example1 LAB: PROGRAM AND RUN THIS EXAMPLE.
What does this code do? Notice the triangular Boolean operator “fits” into the empty triangular slot in the “repeat” LAB: PROGRAM AND RUN THIS EXAMPLE.
28
Boolean Example2 LAB: PROGRAM AND RUN THIS EXAMPLE.
What does this code do? Notice the “Control” block which Starts the code. Notice the triangular Boolean operator “fits” into the empty triangular slot in the “repeat” LAB: PROGRAM AND RUN THIS EXAMPLE.
29
Today’s Objectives How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a sprite
30
Introducing Project #1 Play “The Platform” Project – Watch for these things What does Mario do? At the Edges? What does the Tree do? At the Edges? What does the Mountain do? At the Edges? What does the Gremlin do? At the edges?
31
The Platform Game Video
32
Project #1: The Platform Project
Play “The Platform” Project – What did you see? What does Mario do? At the Edges? What does the Tree do? At the Edges? What does the Mountain do? At the Edges? What does the Gremlin do? At the edges?
33
Specification and grading ( Hero(“Mario) )
Requirement Mario turns to the right on right arrow key Mario turns to the left on left arrow key Mario performs an in-place animated walk if you hold down either arrow key Mario jumps based on some input
34
Mario Specification and grading ( Scenery)
Requirement 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
35
Mario Specification and grading ( Enemy )
Requirement There is at least one on-ground enemy Enemy sprite always moves towards Mario Enemy sprite re-appears/rolls over correctly Enemy sprite is animated when it moves If Mario does not jump, he runs into the enemy and the game ends nicely and properly Mario can jump over the enemy
36
Mario Specification and grading ( Good programming )
Requirement Good programming #1: Program has clear start and stop Good programming #2: Program is repeatable and initializes state correctly Good programming #3: Use of at least 10 comments in your code
37
Project Grading Guidelines
When helping someone else, keep your hands off their keyboard and mouse. They must do all the typing. Talking through a coding project problem is ok: copying is plagiarism, and forbidden. You will lose 50% of your score, and your parents will be notified.
38
One version of Code This code does everything
Mario, Gremlin, Tree, etc. Looks Intimidating Not commented
39
Today’s Objectives How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a Sprite
40
How to approach this large amount of code
Break large problem into small ones You must think first ! Look for patterns in real world situation Find a pattern - write one block - use it everywhere Design your structure After all of that…then you may begin coding
41
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
42
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)
43
Designed code (Hero) Code self-documented Code smaller chunks
Easy to debug Each Block has 6 or 7 lines of code.
44
Today’s Objectives How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a Sprite
45
Adding a new Sprite Click new Sprite button at bottom of stage -
Click on “Costumes” Drag image from desktop into costume area Click on “Scripts” Write the code for this Sprite
46
Lab: Add, remove and reposition sprites
Open SNAP! With your blank project, name it “August2425Labs”
47
Lab: Add, remove and reposition sprites
Find an image that you would like for your Sprite Add it to your workspace as a Sprite “costume” Replace existing costume with your new one Repeat this process – but only this time draw a STICKMAN Sprite with one leg longer than the other using the graphical editor.
48
What worked? What was difficult?
Lab Recap: Discussion What worked? What was difficult?
49
Rotating a Sprite
50
Lab: Rotation Create this simple script, then run it.
Pick your stick figure figure Sprite with one leg purposely longer than the other TIMING: 4 mins (total 8Mins) ACTUAL: 4 min (10 total), Today, let’s do a deeper dive into the Pen block set. Who can tell me what these do: - Pen Up - Pen Down - Clear - Set Pen Color? - Set Pen Shade - Stamp Who can tell me what the following block does?
51
Lab: Rotation Did any of you get this? Why?
Click each of the three buttons and try it again. What was different? What happens with “rotate 180 degrees?” TIMING: 4 mins (total 8Mins) ACTUAL: 4 min (10 total), Today, let’s do a deeper dive into the Pen block set. Who can tell me what these do: - Pen Up - Pen Down - Clear - Set Pen Color? - Set Pen Shade - Stamp Who can tell me what the following block does?
52
Did any of you get this? Why?
Lab 3: Recap Did any of you get this? Why? TIMING: 4 mins (total 8Mins) ACTUAL: 4 min (10 total), Today, let’s do a deeper dive into the Pen block set. Who can tell me what these do: - Pen Up - Pen Down - Clear - Set Pen Color? - Set Pen Shade - Stamp Who can tell me what the following block does? can rotate only face left/right can’t rotate
53
What worked? What was difficult?
Lab Exercise Recap: Discussion What worked? What was difficult?
54
Let’s move the rotation point
Right click the Sprite Popup menu – choose edit Use this tool uses the rotation point as the reference. All motion commands do!! Important when Mario & Gremlin touch.
55
Review: Today How to get help Boolean Operations
Introducing Project #1 How to “design” before you “code” Adding and rotating a Sprite
56
What you’ve learned SNAP IDE:
How to login userid = firstNamelastName pwd = 89oijf8 How to select the desired palette of instructions What is the “Script Area” What is the “Stage” area How to make a “comment” and attach to an instruction lego How to start Blue button provides more blocks/instructions How to get “help” right click on a lego block – choose help How to rotate a Sprite How to create a new Sprite click turtle sprite, drag image into costume area How Boolean expressions work and where they are used
57
Reminders Read Chapter 1. Quiz in two weeks Test on Monday, Aug 31
on computers, abstraction, & SNAP!
58
Looking ahead … Monday Tues / Weds Thurs/Fri TODAY 8/24 8/25-26
8/27-28 BACK TO SCHOOL NIGHT 8/31 TEST #1 9/1-2 QUIZ #1 9/3-4 LABOR DAY – NO SCHOOL 9/8-9 PROJECT #1 DUE 9/10-11 Start Unit 2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.