Download presentation
Presentation is loading. Please wait.
1
Broadcasting (Adding a new level)
Games Programming in Scratch
2
Today’s Lesson Learning Objectives:
Understand the purpose of repeat loops and procedures (broadcasts) Use a broadcast in your own Scratch program Excellence I can extend my program with additional features of my own ideas, making confident use of looping and broadcasts Developing I can make use of broadcasts for different features within my program and explain the benefits of their use Secure I can make use of loops and broadcasts within my program following examples given, as well as describing their basic purpose Foundation I can make use of loops in my program with support and describe why they are used
3
What is better? Both of the scripts below do the same thing, they draw a square shape, but which is better… This... or This... WHY?
4
Efficiency of Code (Using ‘Loops’)
Used to repeat commands automatically Can specify how many times or make it happen forever Shorter code = Smaller program = Better to look at + Easier and quicker for computer to run
5
Dance Efficiency of Code (Using ‘Procedires’) Here’s another question…
Why is… Dance Better than… Left foot forward Left foot back Right foot forward Right foot back Raise arms Clap Lower arms
6
Efficiency of Code (Using ‘Procedures’)
Can be called or used as many times as needed without having to write out the whole ‘Dance’ instructions each time And again… Shorter code = Smaller program = Better to look at + Easier and quicker for computer to run
7
Procedures or ‘Broadcasting’
Look at the following example: When does the code block on the right run? It runs all of these actions in the ‘Procedure’ each time the sprite touches the ‘Shark’
8
Concurrent Events Using a broadcast can also make two things happen at the same time Both blocks of code will run concurrently (at same time!)
9
Adding ‘Next Level’ using Broadcast
Today’s Task 1 Adding ‘Next Level’ using Broadcast Use a ‘Broadcast’ to create more levels in your game… 1) Create a variable called ‘Level’ On the ‘Main Character’ 2) Add events to ‘reset’ the level to 1 when game starts 3) Add a ‘forever’ loop to check when the Score has got to 10 (or whatever number you want) before ‘Broadcasting’ Next Level event
10
Adding ‘Next Level’ using Broadcast
Today’s Task 1 Adding ‘Next Level’ using Broadcast Use a ‘Broadcast’ to create more levels in your game… On the ‘Enemy’ 4) Add events to ‘change’ the level by 1 and reset score to 0 when it receives ‘Next Level’ broadcast To make the game get gradually harder, you can… 5) Change the ‘move 10 steps’ of the enemy, and replace it with the ‘Level’ variable number (so that as the levels go up, so does the speed of the enemy!)
11
Doing more things with ‘Next Level’ Broadcast
Today’s Task 2 Doing more things with ‘Next Level’ Broadcast There are more things you can do when the ‘Next Level’ broadcast message is sent within the game Stage – Make the background change each time you go up a level. Enemy – Make an extra ‘clone’ enemy every time you go up a level Main character – Make the main character do something (like flash/change costume) when go up a level
12
Today’s Task 3 Comment your Code
13
Finding Ideas for other ‘Broadcast’ uses
How do other games in the Scratch library make use of Broadcasting? Type broadcast into the search box and look at the code using the See Inside button. How could you build some of these ideas into your own game?
14
Broadcast – Your own idea!
Today’s Task 4 Broadcast – Your own idea! Broadcasts can be used for lots of different things. Try to now add another broadcast to your game for a different idea… You could use it to: Change the colour of a sprite temporarily (Looks) Change the costume (Look under the Costume tab) Change the background to create a new level
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.