fetch pxt-microbit v2.2.30 (#102)
* undo buttonEvent * fetch microbit v2.2.30 Co-authored-by: Amerlander <gitkraken@juriwolf.de>
This commit is contained in:
		@@ -3,7 +3,6 @@
 | 
			
		||||
## Introduction @unplugged
 | 
			
		||||
 | 
			
		||||
Make a love meter, how sweet! The @boardname@ is feeling the love, then sometimes not so much!
 | 
			
		||||
Tell everyone who you are. Show you name on the LEDs.
 | 
			
		||||
 | 
			
		||||

 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,13 +8,19 @@ Snap the dot is a game of skill where the player has to press **A** exactly when
 | 
			
		||||
 | 
			
		||||
This tutorial shows how to use the game engine.
 | 
			
		||||
 | 
			
		||||
## Create a sprite @fullscreen
 | 
			
		||||
## Make a sprite variable @fullscreen
 | 
			
		||||
 | 
			
		||||
Drag a ``||game:create sprite||`` block onto the workspace. A sprite is a single pixel that can move on the screen. It has an ``x`` and ``y`` position along with a direction of motion.
 | 
			
		||||
Create a new variable called `sprite`. Drag a ``||variables:set sprite to||`` into the ``||basic:on start||`` on the workspace. 
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite: game.LedSprite = null
 | 
			
		||||
sprite = game.createSprite(2, 2)
 | 
			
		||||
let sprite = 0
 | 
			
		||||
```
 | 
			
		||||
## Create a sprite @fullscreen
 | 
			
		||||
 | 
			
		||||
Pull out a ``||game:create sprite||`` block and put it in ``||variables:set sprite to||`` replacing the `0`. A sprite is a single pixel that can move on the screen. It has an ``x`` and ``y`` position along with a direction of motion.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Move the dot @fullscreen
 | 
			
		||||
@@ -22,8 +28,7 @@ sprite = game.createSprite(2, 2)
 | 
			
		||||
The sprite starts in the center facing right. Put a ``||game:move||`` block into the ``||basic:forever||`` to make it move. Notice how it moves to the right but does not bounce back.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite: game.LedSprite = null
 | 
			
		||||
sprite = game.createSprite(2, 2)
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
basic.forever(function () {
 | 
			
		||||
    sprite.move(1)
 | 
			
		||||
})
 | 
			
		||||
@@ -34,8 +39,7 @@ basic.forever(function () {
 | 
			
		||||
Grab a ``||game:if on edge, bounce||`` block to make the sprite bounce on the side of the screen. Also, add a ``||basic:pause||`` block to slow down the sprite.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite: game.LedSprite = null
 | 
			
		||||
sprite = game.createSprite(2, 2)
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
basic.forever(function () {
 | 
			
		||||
    sprite.move(1)
 | 
			
		||||
    sprite.ifOnEdgeBounce()
 | 
			
		||||
@@ -54,13 +58,12 @@ When **A** is pressed, we test if the sprite is in the center or not.
 | 
			
		||||
Use a ``||input:on button pressed||`` block to handle the **A** button. Put in a ``||logic:if||`` block and test if ``||game:x||`` is equal to `2`.
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite: game.LedSprite = null
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
    if (sprite.get(LedSpriteProperty.X) == 2) {
 | 
			
		||||
    } else {
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
sprite = game.createSprite(2, 2)
 | 
			
		||||
basic.forever(function () {
 | 
			
		||||
    sprite.move(1)
 | 
			
		||||
    basic.pause(100)
 | 
			
		||||
@@ -73,7 +76,7 @@ basic.forever(function () {
 | 
			
		||||
Finally, pull out an ``||game:add score||`` and a ``||game:game over||`` block to handle both success (sprite in the center) and failure (sprite not in the center).
 | 
			
		||||
 | 
			
		||||
```blocks
 | 
			
		||||
let sprite: game.LedSprite = null
 | 
			
		||||
let sprite = game.createSprite(2, 2)
 | 
			
		||||
input.onButtonPressed(Button.A, function () {
 | 
			
		||||
    if (sprite.get(LedSpriteProperty.X) == 2) {
 | 
			
		||||
        game.addScore(1)
 | 
			
		||||
@@ -81,7 +84,6 @@ input.onButtonPressed(Button.A, function () {
 | 
			
		||||
        game.gameOver()
 | 
			
		||||
    }
 | 
			
		||||
})
 | 
			
		||||
sprite = game.createSprite(2, 2)
 | 
			
		||||
basic.forever(function () {
 | 
			
		||||
    sprite.move(1)
 | 
			
		||||
    basic.pause(100)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user