Edits for 'snap the dot' (#1246)
This commit is contained in:
parent
649355ef3c
commit
e7741f3eef
@ -2,14 +2,13 @@
|
|||||||
|
|
||||||
## Introduction @unplugged
|
## Introduction @unplugged
|
||||||
|
|
||||||
Snap the dot is a kill game where the player has to press **A** exactly when the dot
|
Snap the dot is a game of skill where the player has to press **A** exactly when the dot reaches the center of the screen.
|
||||||
is in the center of the screen.
|
|
||||||
|
|
||||||
This is a tutorial to learn how to use the game engine.
|
This tutorial shows how to use the game engine.
|
||||||
|
|
||||||
## Create a sprite @fullscreen
|
## Create a sprite @fullscreen
|
||||||
|
|
||||||
Drag a ``||game:create sprite||`` block in the workspace. A sprite is a single pixel that can move on the screen. It has a ``x``, ``y`` position and a direction.
|
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.
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let sprite: game.LedSprite = null
|
let sprite: game.LedSprite = null
|
||||||
@ -18,9 +17,7 @@ sprite = game.createSprite(2, 2)
|
|||||||
|
|
||||||
## Move the dot @fullscreen
|
## Move the dot @fullscreen
|
||||||
|
|
||||||
The sprite starts in the center facing right. Drag a
|
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.
|
||||||
``||game:move||`` block in the forever to make it move.
|
|
||||||
Notice how it moves to the right but does not bounce back.
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let sprite: game.LedSprite = null
|
let sprite: game.LedSprite = null
|
||||||
@ -32,8 +29,7 @@ basic.forever(function () {
|
|||||||
|
|
||||||
## Bounce @fullscreen
|
## Bounce @fullscreen
|
||||||
|
|
||||||
Drag a ``||game:ifOnEdgeBounce||`` block to make the sprite
|
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.
|
||||||
bounce on the side of the screen. Add also a ``||basic:pause||`` block to slow down the sprite.
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let sprite: game.LedSprite = null
|
let sprite: game.LedSprite = null
|
||||||
@ -47,15 +43,13 @@ basic.forever(function () {
|
|||||||
|
|
||||||
## Test and download
|
## Test and download
|
||||||
|
|
||||||
Use the simulator to find the best speed. If you have a @boardname@, press ``Download``
|
Use the simulator to find the best speed. If you have a @boardname@, press ``|Download|`` to try it out on the device.
|
||||||
to try it out on the device.
|
|
||||||
|
|
||||||
## Button handling @fullscreen
|
## Button handling @fullscreen
|
||||||
|
|
||||||
When **A** is pressed, we test if the sprite is in the center or not.
|
When **A** is pressed, we test if the sprite is in the center or not.
|
||||||
|
|
||||||
Drag a ``||input:on button pressed||`` block to handle the **A** button.
|
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`.
|
||||||
Drag a ``||logic:if||`` block and test if ``||game:x||`` is equal to 2.
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let sprite: game.LedSprite = null
|
let sprite: game.LedSprite = null
|
||||||
@ -71,10 +65,10 @@ basic.forever(function () {
|
|||||||
sprite.ifOnEdgeBounce()
|
sprite.ifOnEdgeBounce()
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
## Score and game over
|
## Score and game over
|
||||||
|
|
||||||
Drag a ``||game:add score||`` and a ``||game:game over||`` block to handle success
|
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).
|
||||||
(sprite in the center) and failure (sprite not in the center)
|
|
||||||
|
|
||||||
```blocks
|
```blocks
|
||||||
let sprite: game.LedSprite = null
|
let sprite: game.LedSprite = null
|
||||||
@ -95,4 +89,4 @@ basic.forever(function () {
|
|||||||
|
|
||||||
## Test and download
|
## Test and download
|
||||||
|
|
||||||
Your game is ready! Use the simulator to find the best speed. If you have a @boardname@, press ``Download`` to try it out on the device.
|
Your game is ready! If you have a @boardname@, press ``|Download|`` to try it out on the device.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user