Intro CS – Screens and Variables Lesson Plan 9. Goals  Using sprites as full screens (Start screen, Game over)  Using layering to control ordering of.

Slides:



Advertisements
Similar presentations
In this tutorial, we are going to create: A race car that the user can control with the arrow keys for direction and speed. A simulated road with a striped.
Advertisements

Scratch for Storytelling Dr. Ben Schafer Department of Computer Science University of Northern Iowa.
Flappy bird guide for Scratch
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.
Bug Session Two. Session description In this session the use of algorithms is reinforced to help pupils plan out what they will need to program on their.
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.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
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.
Code Club Session 2 Dance Party. What will we learn ?  How to change the background  How to create animations  How to make objects talk to each other.
Using MIT Scratch for Programming and Control Exercise 3 Ball Game Year 9 ICT Autumn Term 2007.
Bug Session Four. Session description Objectives Session activities summary Resources Prior knowledge of sequencing instructions using Bug Bug website.
Learning the skills for programming Advanced Visual Programming.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
Moving Sprites in Scratch Exploring Computer Science – Lesson 4-4.
Scratch Programming Lesson 4 Question asking and answering.
Variables. Todays Lesson  In todays lesson you are going to:  Learn to use variables  Learn to ask for user input  Learn to save the users response.
Image #1 Getting Started
Computer Programming Modeling a Passive Solar Home.
Marble Racer. 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.
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.
How to create a sprite Delete a sprite (e.g. the cat) by right clicking on it and choosing delete. Go to the bottom right hand corner and choose a new.
Moving Sprites in Scratch Exploring Computer Science – Lesson 4-4.
Today's Ninja Challenge: Write Your First Computer Game!
Making a Flappy Birds Game PART 2 – MAKING THE BIRD FLAP AND FALL – AND DEVELOPING THE GAME FURTHER (ADDING ADDITIONAL CHARACTERS, GOODIES, ENEMIES AND.
Computer Programming Modeling a Passive Solar Home.
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.
Introducing Scratch Learning resources for the implementation of the scenario
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
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.
Intro CS – Costumes and Variables
Customise & Explain your game
Intro CS – Screens and Variables
Broadcasting (Adding a new level)
August 31 Intro to CS.
Intro CS – Loops, making animations & films
Intro CS – Loops & Creating Shapes
How to work with your sprite
Intro CS – Probability and Random Numbers
Intro CS – Keyboard and mouse input
Intro to CS Monday, August 29
Intro to CS Monday, August 24
Explain what touch develop is to your students:
Introduction to Object-Oriented Programming
Dance Cards Dance Cards
Module 5 Lesson 3 Extreme Scratch Cards
Explain what touch develop is to your students:
Dance Cards Dance Cards
Dance Cards Dance Cards
Dance Cards Dance Cards
Dance Cards Dance Cards
Areas of the SCRATCH 2 Screen
Explain what touch develop is to your students:
Dance Cards Dance Cards
Dance Cards Dance Cards
Explain what touch develop is to your students:
Explain what touch develop is to your students:
Game Over Module 4 Lesson 2.
Explain what touch develop is to your students:
Introduction to Snap Programming
Explain what touch develop is to your students:
Scratch 7B IT 1.
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

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.

Closure/Conclusion  Discussion  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

3 Concepts Today 0 Needed for your Galaga projects 0 Moving Backgrounds 0 Screens and Broadcasting 0 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?

Moving Backgrounds?

Background in Galaga

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

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

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

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

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

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.

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:

Daily project  By the end of class: Add a scrolling background to your project  Extra: add a Start screen and button to your project

Summary  Discussion  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