Intro CS – Keyboard and mouse input

Slides:



Advertisements
Similar presentations
1 An intro to programming concepts with Scratch Session 3 of 10 sessions Repetition and variations.
Advertisements

A Christmas Scratch game
Code Club Session 3 Shark Eats Fish. Picture of finished product here.
INTRODUCTION TO SCRATCH. About Me Resources Scratch Website Learn Scratch Washington-Lee Computer.
Creating pong in scratch Learning objectives: To learn how to program Sensing via colour and sprite proximity O:\ICT\ks3\scratch\scratch Exercises\Creating.
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.
CATCH SCRATCH! Programming from Scratch. Remember Scratch?
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.
Exploring Computer Science 2/23/15 2/23 Develop a Scratch story project -Brainstorming 2/24 Develop a Scratch story project –Developing 2/25 Develop a.
Exploring Computer Science 2/16/15
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.
Game Maker Galactic Mail Advanced Group: Complete Galactic Mail, then start developing an independent project.
WHAT IN THE WORLD IS SCRATCH??? AN INTRODUCTION TO COMPUTER PROGRAMMING By MD Showman.
Intro CS – Screens and Variables Lesson Plan 9. Goals  Using sprites as full screens (Start screen, Game over)  Using layering to control ordering of.
Variables and Random Numbers Computer App Session 4.
Using MIT Scratch for Programming and Control Exercise 4 – Cat and Dog game Year 9 ICT Autumn Term 2007.
Programming a Shooter Game Design.
University Learning in Schools Computing Games Programming Lesson 5.
Scratch Programming Lesson 1 Moving objects with sound and changing colours.
Making a Flappy Birds Game PART 2 – MAKING THE BIRD FLAP AND FALL – AND DEVELOPING THE GAME FURTHER (ADDING ADDITIONAL CHARACTERS, GOODIES, ENEMIES AND.
ICT/COMPUTING RULES Only use software allowed by the teacher
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.
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.
Scratch Programming Cards
Intro CS – Costumes and Variables
Installing and Learning Software
Movement Game Design (Scratch).
Create a Halloween Computer Game in Scratch
Intro CS – Screens and Variables
Installing and Learning Software
Games Programming in Scratch
Scratch for Interactivity
Interacting Sprites Module 3: Investigation 1
Intro CS – Loops, making animations & films
Exploring Mathematical Relationships Module 5: Investigation 3
PYGAME.
Intro CS – Loops & Creating Shapes
Building with Numbers Module 4: Investigation 3
Madlib-Input, Strings, and Lists in Scratch
How to work with your sprite
© A+ Computer Science -
Keyboard Input.
Intro CS – Probability and Random Numbers
Year 11 DTG Intermediate Using MIT Scratch for Programming and Control Exercise 2 Controlling movement with the keyboard Year 11 DTG Intermediate.
Introduction to Events
Scratch for Interactivity
Loopy Motion Control.
Scratch Programming Intro
Version 2.
Hints on Delivering PowerPoint Presentations Well
Module 5 Lesson 3 Extreme Scratch Cards
Getting Started with Scratch
Scratch – Simple Programming
Introduction to TouchDevelop
Presentation Companion Slide Pack
ICT Gaming Lesson 3.
Flappy bird Demo: Lesson 5 Flappy bird Demo:
Building a Game in Scratch
Game Over Module 4 Lesson 2.
Explain what touch develop is to your students:
Creating a Simple Game in Scratch
Scratch Racing.
Primary School Computing
Scratch – Simple Programming
Presentation transcript:

Intro CS – Keyboard and mouse input Lesson Plan 7

Goals Understanding Keyboard and Mouse Input Single key press, and held down state Mouse position and mouse click Controlling sprites using the keyboard or mouse

Objectives Students are introduced to the topic and given examples of keyboard and mouse input Students are given real problems to code and solve using the keyboard and mouse Results are demonstrated through demos of running code and displayed results

Pre Requisites Understanding of Scratch, Sprites, Animation, IF, hit detection, looping

Materials Slides with examples (or present on whiteboard) PCs with development environments installed

Lesson Description Introduce Scratch blocks for Key N pressed, MouseX, MouseY, Mouse down Give examples/demo of handling key presses, and key held down Give examples/demo of handling mouse movement and click Give sample problems to solve in class Students practice and extend examples 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: Animation, x position, y position of sprites Give exercises for in class practice (move a sprite based on keyboard input) Direct movement on key press, key held, OR, constant movement with key input to change direction Direct movement of sprite to current mouse position Chase movement of sprite to follow (move towards) mouse position Walk the room answering questions, looking over the shoulder, asking questions, etc.

Closure/Conclusion Discussion Summary How do you apply this to your Galaga project ship? What other kinds of games can you make with keyboard and mouse input? Summary Key press and key down handling Mouse input Ask questions on what is confusing or needs more time/practice

Keyboard and Mouse Input Lesson 7 What did we learn in the last lecture? Mainly about sprite and how to change their costumes and using variables. What is a costume, what is a variable? What were some interesting, hard, tips for your classmates? Common problems we saw some students encounter. Does anyone know what keyboard and mouse inputs are?

Example Demo Today we’re going to learn more about keyboard and mouse inputs (how to get your sprite to move on command). We’re also going to revisit the concept of variable and see how we can keep score. Demo CheesePuffGirl mini-game

Variables What is a variable? Stores a value that can be reused in code. Pros: if you want to change a number, you will only have to change it in one place. Also use for score, movement speed, health level, etc. Do we need to recap? What are some useful things we can use variables for? IE: helping us keep score in games

Variables Continued… How do you create a variable? How do you deleted a variable? How do you show a variable on the screen? How do you set the value of the variable? How can you increment/decrement the value of a variable? What do these two variable blocks do? (Same as the third bullet) Has everyone gotten a chance to play around with variables? Think of questions one level higher.

Keyboard Input We’ve already seen: What does this do? What if we wanted to move a sprite to the left with our left arrow key? Right arrow? Up/Down arrow? What do we usually do with keyboard? We press a key and detect that key stroke For games we use arrow keys (left, right, up, down) We can use arrow and space bar to control our Galaga spaceship and fire hits

Keyboard Input (part 2) When you use these blocks: The sprite pauses briefly You can't press 2 keys at the same time (diagonals) Instead, you can do it another way: May need to adjust speed by adding wait, or by moving fewer steps Can also use Change X by and Change Y by to avoid using Point in Direction

Mouse Input We’ve already seen this control: What about this one? What does it do? What about this one? This is how we can have sprites follow the mouse. What does this control block do? Use with Move block to make a sprite chase your mouse pointer, or another sprite What about these blocks? Show the x-coordinate of the mouse Show the y-coordinate of the mouse Condition statement to check if the mouse was clicked. What things do you think we can do with mouse input? Some students have already experimented with these controls. Mouse selects/deselects Has movement (with x/y coordinate) Then introduce blocks: point in direction/mouse down?/go to mouse pointer

Example Demo Show how to create the CheesePuffGirl Demo Make sure students know how to pick random x,y start and direction. Make sure they know in order to click the object, it must be in front. 2 conditions in if statement 1. touching 2. mouse clicked.

Daily project By the end of class create a mini-game where a sprite chases other sprites (either by using keyboard or mouse inputs) and on clicking the chased sprites, the score is increased by 1 point. Worth 10 points total. Save your project: File format: LP7-YourLastName_YourFirstName.sb Grade Breakdown – Must Include Points Sprite movement on either keyboard or mouse input (must move correctly in all 4 directions) 2 (1/2 for each direction) Contains at least two other moving sprite (besides the one being controlled by keyboard/mouse input) 2 Chased sprites must bounce off screen edges 1 Chased sprites have random starting position Chased sprites have random movement direction On mouse-click the chased sprite must hide and reappear later Score is kept correctly

Summary Discussion Summary How do you apply this to your Galaga project ship? What other kinds of games can you make with keyboard and mouse input? Summary Key press and key down handling Mouse input Ask questions on what is confusing or needs more time/practice