Hour of Code Minecraft | Events
On this next level, you can pick to
be either Steve or Alex.
Press the arrow buttons on your keyboard to
move up, down, left, and right.
Now you can move around a level wherever you
want.
To use a creature, just walk towards it, turn
to face it, and press the spacebar.
If you're using a touch screen, swipe up,
down, left, and right to move around.
Then tap the game to use the item in front
of you.
But what happens when you use it?
In Minecraft, sheep drop wool when you shear
them, cows run away when you hit them, and
creepers explode when you get near them.
These reactions happen thanks to something
called events.
Events tell your program to listen or wait
for when something happens.
And when it does, perform an action.
So far, you've used one event. Code you put
in the "when spawned" slot runs when your
creature is created or when the game starts.
Over the next few levels you'll have new slots
for events such as "when touched" that runs
when you touch the creature, or "when used"
for when you use the creature.
Or, if you want your zombie to disappear when
the sun comes up, put that in the "when day" slot