From fb7fd82d16da3ca0fdb6e627095b528197f2c00e Mon Sep 17 00:00:00 2001 From: Galen Nickel Date: Mon, 25 Jun 2018 12:29:58 -0700 Subject: [PATCH] Merge edits for new projects into v1 (#896) --- docs/projects/mood-radio.md | 26 ++++++++++----------- docs/projects/tele-potato.md | 44 ++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/docs/projects/mood-radio.md b/docs/projects/mood-radio.md index e606fe5c..4cddf1c8 100644 --- a/docs/projects/mood-radio.md +++ b/docs/projects/mood-radio.md @@ -4,16 +4,15 @@ ![@boardname@ sending moods around](/static/mb/projects/mood-radio.png) -This project uses the [radio](/reference/radio) to share your mood with other @boardname@. -When you press ``A``, you friends will see a **smilley**. When you press ``B``, they will see a **frownie**. +This project uses the [radio](/reference/radio) to share your mood with other @boardname@s. +When you press ``A``, your friends will see a **smiley** face. When you press ``B``, they will see a **frowny** face. ## Sending a smiley The @boardname@ can't understand mood but it is pretty good with numbers. In fact, it can send numbers -between @boardname@ using the radio antenna, just like phones. +between @boardname@s using the radio antenna, just like a phone can send text messages. -Let's add blocks that send a number when button ``A`` is pressed. In our "code", -we assume that **0** means "smiley". +Let's add blocks that send a number when button ``A`` is pressed. We assume that `0` is the "mood code" to send for **smiley**. ```blocks input.onButtonPressed(Button.A, () => { @@ -24,9 +23,9 @@ input.onButtonPressed(Button.A, () => { ## Receiving a smiley -We add a ``radio on received`` block that will run code whenever a new message code in. -The ``receivedNumber`` variable contain the numeric value that was sent. Since we've decided that -**0** was **smiley**, we add a conditional **if** statement to show this icon. +We add a ``||radio:on radio received||`` block that will run code whenever a new "mood" message comes in. +The ``receivedNumber`` variable contains the numeric value that was sent. Since we've decided that +`0` is **smiley**, we add a conditional ``||logic:if then||`` statement to show this icon. ```blocks radio.onDataPacketReceived( ({ receivedNumber }) => { @@ -36,10 +35,9 @@ radio.onDataPacketReceived( ({ receivedNumber }) => { }) ``` -## Sending a frowney +## Sending a frowny -Adding another code in our messaging app is very similar. We decide that **1** means **forwnie**. -Then we can add a ``B`` button event that sends that code. +Adding another mood to our messaging app done in a similar way. We decide that the "mood code" of `1` means **frowny**. We can add a ``B`` button event that sends that code. ```blocks input.onButtonPressed(Button.B, () => { @@ -48,7 +46,7 @@ input.onButtonPressed(Button.B, () => { }) ``` -If the ``on radio received`` block, we add an conditional **if** statement to handle the new code. +If the ``||radio:on radio received||`` block, we add another conditional ``||logic:if then||`` statement to handle the **frowny** "mood code". ```blocks radio.onDataPacketReceived( ({ receivedNumber }) => { @@ -61,11 +59,11 @@ radio.onDataPacketReceived( ({ receivedNumber }) => { }) ``` -That's it. Download your code in multiple @boardname@ and try it out! +That's it. Download your code to multiple @boardname@s and try it out! ## Challenges -Try adding a new code and use the **shake** event to send it. +Try adding a new code and use the ``||input:on shake||`` event to send it. ## Full sources diff --git a/docs/projects/tele-potato.md b/docs/projects/tele-potato.md index e692323d..943a2097 100644 --- a/docs/projects/tele-potato.md +++ b/docs/projects/tele-potato.md @@ -4,44 +4,44 @@ ## ~ avatar -Don't keep the potato too long or you might loose the game! +Don't keep the potato too long or you might lose the game! ## ~ ![A teleporting potato](/static/mb/projects/tele-potato.png) -Do you know the "Hot Potato" game? You usually toss around a potato with a timer -and the person that holds it when it finishes looses... It's super fun. +Do you know the "Hot Potato" game? You toss around a potato while a timer counts down +and the person holding it when the timer is up loses... It's super fun. -In this project, we'll build a similar kind of game but using **a virtual potato** and the @boardname@ radio. +In this project, we'll build a similar kind of game but instead we'll use a **virtual potato** and the @boardname@ radio. ## Teleporting potato? -Instead of sending a real potato clock around, we are going to **send a number** between @boardname@. We can do that using the **radio** blocks. They use the antenna on the @boardname@ to send data via radio frequency signals, just like the phones or gadgets around you. +Instead of passing a real potato around while a real clock counts down, we are going to **send a number** between @boardname@s. We can do that using the ``||radio:Radio||`` blocks. They use the antenna on the @boardname@ to send data over radio frequency signals, just like the phones or gadgets around you. ![Using radio to send a potato](/static/mb/projects/tele-potato/radio-potato.jpg) +Now, what does it mean to have a number represent a potato? Well, we need to **model** the clock as **a number** being tossed around with the potato. We do this so that we can play the game using the radio. So what is so special about this potato clock? It ticks down the time and when it reaches 0, it rings. -Now, what does it mean to represent a potato with a number? Well, we need to **model** the clock being tossed around as **a number** so that we can play the game using the radio. So what is so special about this potato clock? It ticks down the time and when it reaches 0, it ring. +To keep track of things, let's have a variable called **potato**: -Let's consider a variable called **potato**. * If the value of **potato** is positive, the player has the potato and the **potato** variable represents the **remaining time** * if value of **potato** reaches 0, the game is over -* if the value of **potato** is negative, this means that the player does not have the potato in its hand. +* if the value of **potato** is negative, this means that the player doesn't have the potato in their hand ![A diagram of the potato representation](/static/mb/projects/tele-potato/model.jpg) -Now that we know what the potato is, we need to decide about the user interaction: how will the user play the game. +Now that we know what the potato is, we need to come up with the user interactions. This is how will the user play the game: -* press ``A+B`` starts the game and send the first potato -* when a potato is received, the screen display some image -* when the player shakes the @boardname@, he sends the potato to other players +* press the ``A+B`` button to start the game and send the first potato +* when a potato is received, the screen displays some image +* when the player shakes the @boardname@, they send the potato to other players ## Let's get coding! ### Initialization -Let's start by creating the potato variable and initializing it to -1 in **on start**. Remember, a negative potato value means you **don't** have the potato. We use [radio set group](/reference/radio/set-group) to make sure players receive the messages. +Let's start by creating the potato variable and initializing it to `-1` in ``||basic:on start||``. Remember, a negative potato value means you **don't** have the potato. We use [``||radio:radio set group||``](/reference/radio/set-group) to make sure players receive the messages. ```blocks let potato = -1 @@ -50,8 +50,8 @@ radio.setGroup(1) ### Starting the game -To start the game, we handle the ``A+B`` button and assign a positive number to the **potato** variable. -To make the game less predictable, we use the random block to generate a value between 10 and 40. +To start the game, we respond to the ``A+B`` button press and assign a positive number to the **potato** variable. +To make the game less predictable, we use the ``||math:pick random||`` block to generate a value between `10` and `20`. ```blocks let potato = 0 @@ -62,8 +62,8 @@ input.onButtonPressed(Button.AB, () => { ### Sending the potato -Sending the potato is done by shacking the @boardname@. If the **potato** variable is positive, -we have the potato and we can send. After sending it, we set the **potato** variable to -1 since we don't have it anymore. +Sending the potato is done by shaking the @boardname@. If the **potato** variable is positive, +we have the potato and we can send it. After sending it, we set the **potato** variable to `-1` since we don't have it anymore. ```blocks let potato = 0 @@ -77,7 +77,7 @@ input.onGesture(Gesture.Shake, () => { ### Receiving the potato -Receiving the potato is done via the [on radio received](/reference/radio/on-data-packet-received) block. +Receiving the potato is done in the [``||radio:on radio received||``](/reference/radio/on-data-packet-received) block. The **receivedNumber** represents the potato and is stored in the **potato** variable. ```blocks @@ -89,11 +89,11 @@ radio.onDataPacketReceived( ({ receivedNumber }) => { ### Ticking the clock -The clock ticking down is done with a ``forever`` loop. +Making the clock tick down is done with a ``||loops:forever||`` loop. -* If the **potato** is equal to 0 (``potato == 0``), KABOOM! you lost! +* If the **potato** is equal to `0` (``potato == 0``), KABOOM! you lose! * If the **potato** variable is negative (``potato < 0``), we don't have the potato so we clear the screen. -* If the **potato** variable is positive (``potato > 0``), we display a potato image and decrease the variable by 1. +* If the **potato** variable is positive (``potato > 0``), we display a potato image and decrease the variable by `1`. ```blocks let potato = 0 @@ -113,7 +113,7 @@ basic.forever(() => { ### It's game time! -Get two or more @boardname@ and download the code into them. One player starts the game by pressing ``A+B`` to receive the first potato. Good luck! +Get two or more @boardname@s and download the code to them. One player starts the game by pressing ``A+B`` to receive the first potato. Good luck! ## Full source