Download presentation
Presentation is loading. Please wait.
Published byEdwin Francis Modified over 8 years ago
1
Intro CS – Broadcasting Messages Lesson Plan 8
2
Goals Using broadcasting to track events across sprites and act on them
3
Objectives Students are introduced to the topic and given examples of broadcasting messages, and with other sprites acting on receipt of those messages Students are given real problems to code and solve with message/event broadcasting Results are demonstrated through demos of running code and displayed results
4
Pre Requisites Basic Understanding of Scratch, Sprites, animation, hit detection, keyboard/mouse input
5
Materials Slides with examples (or present on whiteboard) PCs with development environments installed
6
Lesson Description Students gain understanding and practice in broadcasting messages, and using blocks to act on those messages (When I receive “message”) 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
7
Lesson Procedure Review previous lessons: Hit detection, Input Introduce Broadcasting On hit detection On Mouse click To control app state Give exercises for in class practice (input speed and angle of shot, fire button to broadcast message to start angry bird launch, hit detection to broadcast message to explode target). No or Constant Gravity used. Walk the room answering questions, looking over the shoulder, asking questions, etc.
8
Closure/Conclusion Discussion How do you apply this to your Galaga project? Summary How Broadcast can be used to make sprites react to external events Ask questions on what is confusing or needs more time/practice
9
Hit Detection and Broadcasting Lesson Plan 8
10
What is Broadcasting? Broadcasting is a message that is sent throughout the whole Scratch program, which activates receiving scripts. What can it be used for? On hit detection – do some action after hit detected On Mouse click – do some action after mouse down detected To control app state – do some action when your program goes from one state to another
11
Broadcasting Related Blocks Broadcast () Makes the specified broadcast and has no further effect Broadcast () and Wait Makes the specified broadcast and freezes its script until all of the receiving scripts have finished When I Receive () Stays inactive until it receives the specified broadcast. Once it has been received, the script goes into action and ends once it has finished but can be stored more than once.
12
Additional Information Scratch cannot limit where a broadcast can go Work around for this is to use a global variable and private variable for each sprite:
13
Example Demo Today we’ll be learning how to create an Angry Bird- like mini-game that uses the concept of Broadcasting and hit detection. AngryShark.sb Demo how to create the program
14
Daily project If you want the challenge, work through the gravity part yourself (don’t use the sample provided) Finish the AngryShark mini-game. Worth 10 points total. Save your project: Grade Breakdown – Must IncludePoints Score is kept correctly1 When the AngryShark touches the edge, the correct actions take place (see comments in code). 2 When the AngryShark touches the rock, the correct actions take place(see comments in code). 2 When the AngryShark touches the Fish, the correct actions take place (see comments in code). 4 Reset command is correctly implemented.1 Extras if you finish early: Make the target move, making shot timing important Use the mouse position to determine the shot angle and speed, and the mouse button to fire (like Angry Birds)
15
Summary Discussion How do you apply this to your Galaga project? Summary How Broadcast can be used to make sprites react to external events Ask questions on what is confusing or needs more time/practice
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.