← Teacher guide Markdown for Prepare

Collide and score: cheat sheet

Arcade Foundations · Find each block in the MakeCode toolbox (the category is at the end of each line).

on overlap

Runs when a sprite of the first kind touches a sprite of the second kind. sprite is the first, otherSprite the second. Sprites › Overlaps.

sprites.onOverlap(SpriteKind.Player, SpriteKind.Food, function (sprite, otherSprite) {
    blocks
})
The block

set score

Shows a score at the top of the screen. Info.

info.setScore(0)
The block

set life

Shows hearts for lives. At zero lives the game ends by itself. Info.

info.setLife(3)
The block

hit costs a life

A hit destroys what hit you and costs a life, so one touch counts once. At 0 lives the game ends by itself.

sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.destroy()
    info.changeLifeBy(-1)
})
The block

start countdown

A timer in seconds at the top of the screen; the game ends when it reaches 0. Info.

info.startCountdown(30)
The block

destroy

Removes a sprite from the game. Sprites.

otherSprite.destroy()
The block

pick random

A whole number chosen at random, from the first number to the second. Math.

randint(0, 160)
The block

change score

Adds to the score. Use a negative number to take away. Info.

info.changeScoreBy(1)
The block

change life

Adds or takes away lives. Info.

info.changeLifeBy(-1)
The block

on game update every

A timer: runs its blocks every so many milliseconds (1000 ms is one second). Game.

game.onUpdateInterval(1000, function () {
    blocks
})
The block