Get a list of every sprite of a kind, and use a for element loop to do something to each one.
A smart bomb clears the screen, a freeze spell stops every enemy, a magnet pulls in every coin: one press, every sprite of a kind.
In a shooter, aliens are made by a timer and have no names of their own. How can one button do something to all of them? array of sprites of kind (in Sprites) gives a list: every sprite of that kind in the game right now. A for element loop (in Loops) runs its blocks once for each item in the list, with value standing for that item.
Make your prediction first. Help opens once you've locked it in.

scene.setBackgroundColor(15)
let ship = sprites.create(img`
. . 1 . .
. 1 1 1 .
1 1 1 1 1
`, SpriteKind.Player)
ship.setPosition(80, 110)
controller.moveSprite(ship, 100, 0)
game.onUpdateInterval(1000, function () {
let alien = sprites.create(img`
. 7 . 7 .
7 7 7 7 7
7 f 7 f 7
. 7 . 7 .
`, SpriteKind.Enemy)
alien.setPosition(randint(10, 150), 0)
alien.vy = 20
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
for (let value of sprites.allOfKind(SpriteKind.Enemy)) {
value.vy = 0
}
})
B is enter (or X) on the keyboard.
Wait for a few aliens, then press B.

scene.setBackgroundColor(15)
let ship = sprites.create(img`
. . 1 . .
. 1 1 1 .
1 1 1 1 1
`, SpriteKind.Player)
ship.setPosition(80, 110)
controller.moveSprite(ship, 100, 0)
game.onUpdateInterval(1000, function () {
let alien = sprites.create(img`
. 7 . 7 .
7 7 7 7 7
7 f 7 f 7
. 7 . 7 .
`, SpriteKind.Enemy)
alien.setPosition(randint(10, 150), 0)
alien.vy = 20
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
for (let value of sprites.allOfKind(SpriteKind.Enemy)) {
value.vy = 0
}
})

scene.setBackgroundColor(15)
let ship = sprites.create(img`
. . 1 . .
. 1 1 1 .
1 1 1 1 1
`, SpriteKind.Player)
ship.setPosition(80, 110)
controller.moveSprite(ship, 100, 0)
game.onUpdateInterval(1000, function () {
let alien = sprites.create(img`
. 7 . 7 .
7 7 7 7 7
7 f 7 f 7
. 7 . 7 .
`, SpriteKind.Enemy)
alien.setPosition(randint(10, 150), 0)
alien.vy = 20
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
for (let value of sprites.allOfKind(SpriteKind.Enemy)) {
value.vy = 0
}
})
Mia's B event:

controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
for (let value of sprites.allOfKind(SpriteKind.Enemy)) {
value.destroy()
}
info.changeScoreBy(1)
})
def on_b_pressed():
for value in sprites.all_of_kind(SpriteKind.enemy):
value.vy = 0
controller.B.on_event(ControllerButtonEvent.PRESSED, on_b_pressed)
There are 4 aliens on the screen when you press B. How many times does set value vy to 0 run?
The loop in Python. Match each part with what it does.
Make B send every alien back to the top as it freezes them.
Inside the loop, add set value y to 0 (Sprites).
Make A speed every alien up.
Drag in on A button pressed. Put another for element loop over array of sprites of kind Enemy inside it.
Inside the loop: set value vy to 40.
Make B also send every alien back to the top.
This ticks by itself when your blocks do what is asked.
Make A speed every alien up: vy 40.
This ticks by itself when your blocks do what is asked.

scene.setBackgroundColor(15)
let ship = sprites.create(img`
. . 1 . .
. 1 1 1 .
1 1 1 1 1
`, SpriteKind.Player)
ship.setPosition(80, 110)
controller.moveSprite(ship, 100, 0)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
let shot = sprites.createProjectileFromSprite(img`
4 4 4
`, ship, 0, -100)
})
The aliens come twice as fast now. Make a smart bomb on the B button:
Count the aliens before you press B, and check the score goes up by that many.
Start with on B pressed (in Controller). Inside it, a for element loop from Loops.
Drag array of sprites of kind (Sprites) into the loop's list slot, and choose Enemy.
Inside the loop: destroy value, and change score by 1.
A smart bomb: pressing B destroys every alien on the screen and scores one point for each.
This ticks by itself when your blocks do what is asked.
A launches a rocket; B makes every rocket in the sky burst off in a random direction. Make the rockets launch faster, and make B also change the background colour, so the sky flashes when they burst.
Students get a list of every sprite of a kind with array of sprites of kind, and use a for element loop to do something to each one. About 40 minutes.
Open the teacher guide: answers, solutions, slides and a worksheet.
A list (an array in MakeCode) is many values in order under one name. array of sprites of kind Enemy (Sprites) is a list of every enemy in the game right now. A for element loop (Loops; MakeCode calls it "for element value of list") runs its blocks once for each item, with value standing for that item each time. That is how one button press can reach sprites that have no names. Blocks inside the loop run once per sprite; blocks after it run once.
Which blocks go inside the loop. Ask: should this happen once, or once for each alien?
Stretch: Make a magnet on A+B: every Food sprite flies towards the player (set value vx and vy, or use follow).
Support: Give students the on B pressed block with an empty for element loop already in it, and ask them only to choose the list and fill the loop.
Next lesson: functions, which name a job such as 'make an enemy' so it can be used in many places. Skillmap: Save the Galaxy (arcade.makecode.com/skillmaps) is a Galaga-style shooter that practises projectiles and enemies.