Go to the makecode.microbit.org website and create a new project.
Go to the Makecode.com Microbit website using the link below and click on the 'New Project' button underneath the 'My Projects' heading.
Install the micro:bit app on your iPad or tablet.
Open the app, tap 'Create code' and then create a new project.
Create the Egg sprite in the middle of the screen on start.
let Egg = game.createSprite(2, 2)
In the Variables toolbox, create a new variable by clicking the 'Make a Variable' button.
Once you click this button a box will appear asking what you want to call your variable. Give it a name that reminds you what you will be using it for. For example, if you wanted to keep track of your score in a game, you would create a variable called 'score'.
Now we'll create a variable for the acceleration of the egg in the x-direction. We're going to use the Microbit's accelerometer and store it's x-value in our variable.
let XAcceleration = 0 basic.forever(function () { XAcceleration = input.acceleration(Dimension.X) })
We can use the XAcceleration variable to make the Egg move either left or right.
We'll need to check if the value of XAcceleration is above a certain threshold to make the egg move initially. We'll also need to check if the value is positive or negative (a positive value will make the Egg go right and a negative value will make it go left).
let Egg = game.createSprite(2, 2) basic.forever(function () { XAcceleration = input.acceleration(Dimension.X) if (XAcceleration < -150) { Egg.change(LedSpriteProperty.X, -1) } else if (XAcceleration > 150) { Egg.change(LedSpriteProperty.X, 1) } basic.pause(700) })
Note that 150 is just an arbitrary value. You can change this value to make the Egg more or less reactive to movement.
Also, put in a pause block at the end of the code above if the egg is moving too fast!
Use what you learned in previous steps to make the Egg move up and down!