Intro CS – Screens and Variables

Slides:



Advertisements
Similar presentations
SCRATCH Lesson Two – Interactive Concepts Using Sensing, Operators, and Variables.
Advertisements

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.
Ch 1.4 – Equations & Inequalities
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
CATCH SCRATCH! Programming from Scratch. Remember Scratch?
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.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
QUIZ! You can bring notes you took during class Any concept/topic we’ve covered may be up for grabs.
Intro CS – Screens and Variables Lesson Plan 9. Goals  Using sprites as full screens (Start screen, Game over)  Using layering to control ordering of.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Today's Ninja Challenge: Write Your First Computer Game!
Intro CS – Costumes and Variables Lesson Plan 6. Goals  Understanding Costumes, Ordering, Naming  Switching Costumes with Switch and Next  Using Variables.
Intro CS – Broadcasting Messages Lesson Plan 8. Goals  Using broadcasting to track events across sprites and act on them.
Intro CS – Logic & Operators Lesson Plan 5. Goals  Students can explain basic logical operators  AND, OR, NOT  Students can create truth tables for.
Intro CS – Probability and Random Numbers Lesson Plan 6a.
Intro CS – Loops, making animations & films Lesson Plan 3.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
DAY 4. MAKING SOMETHING ‘JUMP’ Simple! Move it a certain amount ‘up’ Glide back to your original spot.
Index Background Costumes Making object walk smoothly Controlling an object with the keyboard Control an object with the mouse Changing costume when hit.
Intro CS – Keyboard and mouse input Lesson Plan 7.
LEARNING SCRATCH: PRESENTATION 4 PRESENTATION 1: GETTING STARTED 1 Broadcast Messages Today, we'll learn how to get our sprites to act together, and build.
Scratch Programming Cards
How Do You Make a Program Wait?
Intro CS – Costumes and Variables
Development Environment
Broadcasting (Adding a new level)
August 31 Intro to CS.
Intro CS – Loops, making animations & films
Intro CS – Loops & Creating Shapes
Intro CS – Probability and Random Numbers
Intro CS – Keyboard and mouse input
Intro to CS Monday, August 29
Unit 2 Getting Started With
Intro to CS Monday, August 24
Explain what touch develop is to your students:
Lesson 10: Building an App: Color Sleuth
Learning to program with Logo
Introduction to Object-Oriented Programming
Completing the tasks for A452 with….
Explain what touch develop is to your students:
Dance Cards Dance Cards
Explain what touch develop is to your students:
Dance Cards Dance Cards
Dance Cards Dance Cards
An Introduction to VEX IQ Programming with Modkit
Dance Cards Dance Cards
Dance Cards Dance Cards
Scratch Programming Brian Cain.
Go to =>
Introduction to TouchDevelop
Explain what touch develop is to your students:
Go to =>
Dance Cards Dance Cards
Dance Cards Dance Cards
Explain what touch develop is to your students:
Explain what touch develop is to your students:
Explain what touch develop is to your students:
Using CourseCompass Features
Game Over Module 4 Lesson 2.
Explain what touch develop is to your students:
Dance Cards Dance Cards
Dance Cards Dance Cards
Dance Cards Dance Cards
Explain what touch develop is to your students:
Creating a Simple Game in Scratch
Dance Cards Dance Cards
Dance Cards Dance Cards
Presentation transcript:

Intro CS – Screens and Variables Lesson Plan 9

Goals Using sprites as full screens (Start screen, Game over) Using layering to control ordering of screens Using full screen sprites to create moving backgrounds Using global and sprite level variables – when and why for each

Objectives Students are introduced to the topic and given examples of full screen sprites for start/end screens, and for animated backgrounds; also examples of global and sprite level variables Students are given real problems to code and solve for practice Results are demonstrated through demos of running code and displayed results

Pre Requisites Basic Understanding of Scratch, Sprites, Animation, Costumes, and Variables

Materials Slides with examples (or present on whiteboard) PCs with development environments installed (this includes moving backgrounds that are pre-installed)

Lesson Description Introduce full screen sprites, positioning, animating them Review variables – used to track information that may change due to user input, hit detection, time, etc. Discusses when to use variables, how to use them, and what are their benefits and drawbacks (variables at sprite and global level) Examples/demos – get scrolling background working in class Students practice and extend problem to their own wishes Students present their solutions, typically F2F with the instructor(s) at their desk Students analyze their and others’ solutions for bugs Won’t do Breakout game, instead give them time to work on their Galaga Projects.

Lesson Procedure Review previous lessons: Repeat loops, Animation, Costumes, Hit Detection In class examples: Full screen sprite with layered button (click button to start) Full screen sprites to animate background horizontally/vertically Examples of global and local variables Give exercises for in class practice Walk the room answering questions, looking over the shoulder, asking questions, etc. Won’t do Breakout game, instead give them time to work on their Galaga Projects.

Closure/Conclusion Discussion Summary How do you add Start and Game over screens to your Galaga game? What kind of scrolling background will you use? How would you use global and local variables in your Galaga game? Summary Using variables to track app state and animation of backgrounds Sprite vs. global variables Ask questions on what is confusing or needs more time/practice

Animated Backgrounds and Scoped Variables Lesson Plan 9 Today we’re going to talk about start, end, scrolling screens, and variables that help manage state that will help you guys in your Galaga project. But first off, discuss the quiz (too hard, too easy? Everyone had enough time? Was everyone prepared?) Secondly discuss what we learned last lesson – hit detection and broadcasting. Did anyone have trouble? What did a lot of you notice? Some people had trouble with the Done (variable) equals True statement, what do you guys think we had that for – to check for the state of the program (if the AngryShark had hit something).

3 Concepts Today Needed for your Galaga projects Moving Backgrounds Screens and Broadcasting Variable Scoping

Backgrounds What have we done so far with backgrounds? Backgrounds are static (can’t move) in BYOB We can change them whenever we want using the two following blocks : What else might we want to do? What if we wanted a scrolling background in our Galaga game? What if we wanted to create a Start or Game over screen? Make sure everyone understands how to import and change a background, should be review. How could we create a scrolling background in our game? Paper demo: one piece of paper with a design how can we make it seem like it’s scrolling forever. Hints: what does a treadmill do? So how can we translate this to Scratch?

Moving Backgrounds?

Background in Galaga

Paper Prototype Partner up Get out some paper Try to recreate either Fred’s or Galaga’s background as a quick mockup / prototype How would you solve this in Snap?

Full Screen Sprites Background images can also be used as regular Sprites - these are known as full screen sprites. By using backgrounds as Sprites we can control: Position Animation/movement (tip: glide block will allow for smooth background movement) Layering (tip: be careful of layering, make sure what you want to show is layered on top at the correct time; layering can be used to control ordering of screens) Demo scrolling background Full screen sprites will allow you to create moving backgrounds, think about Mario and Galaga space bgs.

The Pseudo code & Math Start BG1 fully on screen (at 0,0) Start BG2 fully on screen (above at 0,360) Move both down at same time When BG1 goes off the bottom of the screen (0,-360), move it back to the middle When BG2 goes to the center of the screen (0,0), move it back to the top

UPDATE In the gear menu in Snap, turn on the Prefer smooth animations checkbox Also, if you get a gap, create 2 variables and try this: On each sprite Stage

Screens and Broadcasting

Start Screen State

Play Button Similar to everything else in Scratch, the Play Button will also be a Sprite, however it’s more of an object than a character. Demo Play Button Next thing we want to discuss is how to start your game by pressing a Play Button. How do we think this might be accomplished?

Variable Scoping

Global vs. Sprite Variables What is a Global variable? Variable for all sprites Example: In our past projects we have used a single variable for speed or step size. What is a Sprite variable (also known as local variable)? Variable for a single sprite Example: If you want to make the dive directions for your enemy ships in Galaga different or anything else that is specific to a single sprite. What else could we use global and sprite variables for?

Global vs. Sprite Variables – Used in Broadcasting Scratch cannot limit where a Broadcast can go Work around for this is to use a global variable and private/local/sprite variable for each sprite: We discussed Global and Sprite Variables in the last Broadcasting lecture and it was also the Bonus question for your quizzes, does anyone remember what the difference between a Global and Sprite Variable are? How did it help Broadcasting?

Daily project By the end of class: Add a scrolling background to your project Extra: add a Start screen and button to your project Show me "for this sprite only" variables and how they work

Summary Discussion Summary How do you add Start and Game over screens to your Galaga game? What kind of scrolling background will you use? How would you use global and local variables in your Galaga game? Summary Using variables to track app state and animation of backgrounds Sprite vs. global variables