Go further with Arcade. Every sprite of a kind, functions and parameters, gravity and jumping, levels from lists, and power-ups that run out, ending in a power-ups challenge and a game of your own. Each unit points to a MakeCode skillmap that practises it.
Each lesson works two ways. Students can work through the online tutorial at their own pace (it checks their answers and saves their progress in their browser), or you can teach it to the whole class from the slides, then send students into the tutorial for the Modify and Make steps.
Every lesson guide has plain-language notes, the answers to every check, a solution for every task, and slides and a worksheet for Waypoints Prepare. These guide pages are not linked from student pages, but they are not secret either: keep printed Teacher editions for answers you do not want students to find.
Whole-course cheat sheet: Open to print (every command, grouped by unit: a handout for the final challenge)
Do something to every sprite of a kind, name a job as a function, and hand it a value.
array of sprites of kind Enemy gives a list of every enemy in the game right now, and a for element loop (in Loops) runs its blocks once for each one, so one press can freeze or destroy them all.
A function (in Functions, under Advanced) is a named job: some blocks with a name, such as spawnBug. Making it does not run it; a call block runs it, once per call. A parameter is an input the call hands in, such as speed in spawnEnemy(speed), so one function can make a slow bug and a fast bug.
Students can also look at the Python view of their programs. The big idea: every event block (on overlap, on A pressed, on game update every) is a function, handed to the game to call when the event happens.
A game cannot give every alien its own name: a list lets one block deal with all of them. Functions name a job once (make an enemy, make a coin), so it can be used from anywhere and fixed in one place.
The list is the class roll: "everyone on the roll, stand up" works however many students there are today. A function is a recipe card: "make the sauce (see card 12)", and the parameter is "for 4 people" or "for 10".
Where they break: a roll is written once a term, but array of sprites of kind is a fresh roll every time it runs, so a new alien is on it straight away. And writing a recipe card does not cook anything until someone follows it, just as making a function does not run it until it is called.
The next units use them all: a jump inside an if, a level-up in the event where the score changes, and a startLevel function that reads a list of speeds.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Gravity, a floor, and a jump that works only from the ground.
Gravity is one more number on a sprite. vx and vy (velocity) are how far the engine moves it every frame; ay (acceleration) is how much the engine changes vy. With ay 300, vy grows by 300 every second, so a sprite falls faster and faster. A jump is a speed upwards: a negative vy, because y counts down the screen. Gravity slows the jump, stops it and brings the sprite back.
An empty Arcade screen has no ground, so a falling sprite drops out of sight. Students build a floor with an if in on game update: if the player's bottom (the y of its lowest edge) is below 100, put it back at 100 and set vy to 0. A jump should only happen from that floor, so the jump goes inside if bottom ≥ 100.
Gravity and a floor are the heart of platformers and runners.
Gravity is a ball thrown up in the playground: it slows, stops at the top and comes back faster.
Where it breaks: a real ball lands on the real ground. In Arcade nothing is solid until you say so, either with your own if or with tilemap walls.
Real Arcade platformers use a tilemap: a world drawn from squares (tiles) in the tile editor. Wall tiles stop sprites by themselves (a floor without an if), and the camera can follow the player through a world bigger than the screen. This is why platformers suit Arcade so well. The course builds the floor by hand first so that a wall makes sense: it is the same if, done by the engine. Tilemaps live in a project's assets rather than in its code, so the lessons leave them for later.
Next unit adds levels to the runner. Will it work in Arcade? puts platformers near the top of the games Arcade suits, because of gravity and tilemaps. Skillmaps: Jungle Jump Platformer and Monster Truck Racer.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
A level that goes up where the score changes, and a list of what each level is like.
A level is a variable that changes by 1. The level-up is an if in the event where the score changes: if score ≥ goal, change level by 1 and move goal up, so the next level is further away. A splash shows the level, joined to the word Level with join (Text).
What changes per level goes in a list: speeds is 40, 70, 100, and speeds[level] (get value at) is the speed for this level. Places are counted from 0, so the level starts at 0 and the splash shows level + 1. A function startLevel clears the old enemies, splashes the level and sets up the new one. After the last level, the game ends with a win.
Levels keep players playing: each one a little faster or busier, with a new look, while the program stays the same and only a list changes.
Levels are a swimming programme: the same lesson each week, but the card for your level says how far and how fast.
Where it breaks: a swimmer moves up once. A game does not know it has already moved you up: an if in on game update keeps asking every frame, so if score ≥ 5 stays true and levels up again and again. Level up in the event where the score changes, and move the goal up.
Next unit, power-ups: true or false, and numbers that run out. Skillmap: Jungle Jump Platformer builds a level per map.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
True or false to remember a power-up, and a number that makes it run out.
A variable can hold true or false (Logic). A power-up is three parts: a variable that remembers it (shield is true while it is on), an event that changes it (catching a star sets it to true), and a rule that uses it (if shield, a rock costs no life). It stays true until a block sets it back to false.
A power-up that runs out is a number counting down. For ammo, the A event asks if ammo > 0 first, then fires and changes ammo by -1, so the count never goes below zero. For time, a timer every second takes 1 off shieldTime while the shield is on, and at 0 sets the shield back to false.
Games remember what is happening now (powered up or not, shots left) in variables. Checking before using is how every limited thing works, from ammo to a bank balance.
A power-up is a "free entry" wristband at a fair: while you wear it, the ride rules change for you, and it comes off at closing time.
Where it breaks: the wristband only comes off if someone checks the time. In code, nothing sets the variable back unless a block does, and a check written in on start is asked once, before the game begins. The countdown must sit in a timer.
The final challenge, Power-ups, puts true or false, counting down and every sprite of a kind into one prize box. Skillmap: Save the Galaxy adds power-ups to a shooter.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
A prize box of power-ups in milestones, then which games suit Arcade. An optional lesson builds your own game.
The challenge grows the shield game from the Power-ups unit into a prize box: a star gives a shield (true or false, counted down), a blaster with limited ammo, a smart bomb (every sprite of a kind) or a power-up each student designs. It is built in three milestones with less help each time: most of the code, then an outline, then goals only. Nothing is new.
Will it work in Arcade? then asks which games the engine is built for, ending in a pitch card and a prototype. Power-ups and Will it work in Arcade? mark the course Challenge complete. The optional Your own game turns the pitch card into a finished game, with goals only.
Every Arcade game splits into two kinds of work:
Naming the split helps students debug (a rule they wrote is where the bug is) and helps them judge which games suit Arcade: a game whose hard part the engine already does is quick to build.
Real programs are combinations: state (variables), events, decisions, lists and named jobs working together. Building in milestones keeps a game playable at every stage, so each change can be tested by playing. Game studios work the same way: prototype, playtest, change one thing.
A power-up is a "free entry" wristband at a fair: while you wear it, the ride rules change for you, and it comes off at closing time.
Where it breaks: the wristband only comes off if someone checks the time. In code, a check written in on start is asked once, before the game begins, so the shield never switches off. The countdown must sit in a timer.
Will it work in Arcade? and Your own game ask students to judge their ideas against this table. The engine facts were written from knowledge of Arcade; spot-check them in the editor.
| Game types | Why | |
|---|---|---|
| Built for it | catch and collect, dodge, top-down shooters, endless runners, single-screen sports (pong, keepy-uppy), mazes and top-down adventures, side-scrolling platformers, two to four players on one keyboard | every part is a built-in block: sprites and kinds, the controller, velocity and gravity, overlap events, score, lives, countdown, and tilemaps with walls and a scrolling camera |
| Possible, with work | quizzes and stories (the screen is small), card and board games (no mouse: move a cursor with the controller), RPGs with inventories and dialogue, turning cars or ships (sprites do not rotate: draw a picture for each direction), sprites bouncing off each other (you code the maths), saving progress beyond the high score | no block does it, so you build it from the building blocks or add an extension |
| Not a good fit | 3D or first person, realistic physics (stacking, tumbling, Angry Birds), detailed high-resolution art, hundreds of moving sprites, typing-heavy games, real-world data, online play inside our lessons | the screen is 160 × 120 in 16 colours, overlaps are events rather than pushes, there is no physics engine or 3D, and MakeCode's own online multiplayer (a join code for 2 to 4 players) needs MakeCode's sharing, which is switched off in our embedded editor |
This ends Arcade advanced skills. Next steps are Arcade's real tools: tilemaps (walls, floors and a camera that scrolls through a bigger world), animation and extensions, led by the teacher, or practised in Microsoft's skillmaps (arcade.makecode.com/skillmaps): Jungle Jump and Monster Truck Racer for platforms, Save the Galaxy for shooters, and the Game Maker Guide for students making their own. The same ideas (events, state, decisions, lists, functions) carry into games in text code later.
Cheat sheet: Open to print (A4, with a picture of what each command draws) · Markdown
Self-paced briefs students can pick up after the lesson named on each. Students tick their own milestones and claim a badge; the page lights the skills their code uses. Badges stay in the student's browser: ask them to press Show your teacher. Open the projects page
Make a shooting game with a twist of your own: waves of enemies arrive, the player fires at them, and a button or event does something to all of them at once (freeze them, slow them, clear the screen).
Milestones:
scene.setBackgroundColor(15)
info.setLife(3)
let ship = sprites.create(img`
. . 9 . .
. 9 9 9 .
9 9 1 9 9
`, SpriteKind.Player)
ship.setPosition(80, 110)
controller.moveSprite(ship, 100, 0)
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
let shot = sprites.createProjectileFromSprite(img`
5
5
`, ship, 0, -100)
})
controller.B.onEvent(ControllerButtonEvent.Pressed, function () {
for (let alien of sprites.allOfKind(SpriteKind.Enemy)) {
alien.vy = 0
}
})
game.onUpdateInterval(1000, function () {
let alien = sprites.create(img`
. 7 . 7 .
7 7 7 7 7
7 f 7 f 7
`, SpriteKind.Enemy)
alien.setPosition(randint(10, 150), 0)
alien.vy = 20
})
sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Enemy, function (sprite, otherSprite) {
sprite.destroy()
otherSprite.destroy()
info.changeScoreBy(1)
})
game.onUpdate(function () {
for (let alien of sprites.allOfKind(SpriteKind.Enemy)) {
if (alien.y > 120) {
alien.destroy()
info.changeLifeBy(-1)
}
}
})
Make a game with levels: each level is a little harder (faster, more enemies, a different map), the levels come from a list, and a function sets each one up. The kind of game is yours.
Milestones:
Will it work in Arcade? is worth doing first: it steers students away from physics games Arcade cannot do well. Ask for a one-sentence pitch before coding.
let speeds = [30, 50, 70]
let level = 0
let hero = sprites.create(img`
. 2 2 .
2 2 2 2
2 2 2 2
. 2 2 .
`, SpriteKind.Player)
controller.moveSprite(hero)
hero.setStayInScreen(true)
function startLevel() {
for (let old of sprites.allOfKind(SpriteKind.Enemy)) {
old.destroy()
}
let rock = sprites.create(img`
e e e
e e e
e e e
`, SpriteKind.Enemy)
rock.setPosition(randint(10, 150), 0)
rock.vy = speeds[level]
rock.setBounceOnWall(true)
rock.vx = speeds[level]
}
sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
game.over(false)
})
game.onUpdateInterval(10000, function () {
level = level + 1
if (level < speeds.length) {
game.splash("Level " + (level + 1))
startLevel()
} else {
game.over(true)
}
})
startLevel()