moving out outdated js docs
This commit is contained in:
63
olddocs/js/lessons/glowing-sword/activity.md
Normal file
63
olddocs/js/lessons/glowing-sword/activity.md
Normal file
@ -0,0 +1,63 @@
|
||||
# glowing sword activity
|
||||
|
||||
Make glowing sword.
|
||||
|
||||
### ~avatar avatar
|
||||
|
||||
### @video td/videos/glowing-sword-0
|
||||
|
||||
In this activity, we will learn how to fade in and out the screen to create a glowing animation. Let's get started!
|
||||
|
||||
### ~
|
||||
|
||||
Let's start by adding the code to display an image. Use `basic->plot image` to draw your favorite image.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`) // ***
|
||||
```
|
||||
|
||||
We can control the brightness of the LED screen with code. That's just what we need to create a **glowing** animation: first we **fade out**, then **fade in**. Add a new line of code to **fade out** the screen.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700) // ***
|
||||
```
|
||||
|
||||
Run your script to make sure it works as expected then add another line of code to **fade in** the screen.
|
||||
|
||||
```
|
||||
led.fadeIn(700)
|
||||
```
|
||||
|
||||
Finally, add a `basic->forever` loop and move the fade out and fade in code into the forever to repeat the glow pattern.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700) // ***
|
||||
led.fadeIn(700) // ***
|
||||
```
|
||||
|
||||
### ~avatar boothing
|
||||
|
||||
Excellent, you're ready to continue with the [challenges](/lessons/glowing-sword/challenges)!
|
||||
|
||||
### ~
|
||||
|
62
olddocs/js/lessons/glowing-sword/challenges.md
Normal file
62
olddocs/js/lessons/glowing-sword/challenges.md
Normal file
@ -0,0 +1,62 @@
|
||||
# glowing sword challenges
|
||||
|
||||
Coding challenges for the glowing sword tutorial. #docs
|
||||
|
||||
## Before we get started
|
||||
|
||||
Complete the [glowing sword](/lessons/glowing-sword/activity) activity and your code will look like this:
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
### Challenge 1
|
||||
|
||||
Now, let's add `basic->pause(1000)` after the fade in so that there will be a 1000 millisecond (1 second) delay after the fade out.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000) // ***
|
||||
```
|
||||
|
||||
* `run main` the code to see if it works as expected.
|
||||
|
||||
### Challenge 2
|
||||
|
||||
### @video td/videos/glowing-sword-2
|
||||
|
||||
After the pause, let's add `led->fade in(2000)` so that we can create a glowing effect.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
basic.pause(1000)
|
||||
led.fadeIn(2000) // ***
|
||||
```
|
||||
|
||||
* `run main` the code to see if it works as expected.
|
||||
|
||||
### Challenge 3
|
||||
|
||||
Now add another `basic->pause(1000)` and `led->fade out(900)` so that the sword can fade out again.
|
||||
|
48
olddocs/js/lessons/glowing-sword/quiz-answers.md
Normal file
48
olddocs/js/lessons/glowing-sword/quiz-answers.md
Normal file
@ -0,0 +1,48 @@
|
||||
# glowing sword quiz answers
|
||||
|
||||
The answers for the glowing sword quiz.
|
||||
|
||||
This is the answer key for the [glowing sword quiz](/lessons/glowing-sword/quiz).
|
||||
|
||||
## 1. What is "fade out" ?
|
||||
|
||||
Fade out is a method that gradually decreases the LED screen brightness until the LED lights are turned off.
|
||||
|
||||
## 2. Consider the following code
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
Rewrite the second line of code to decrease the speed of the fade out for the longest amount of time (Hint: 1000 milliseconds is longest amount of time for a fade out).
|
||||
|
||||
<br/>
|
||||
|
||||
led->fade out(1000)
|
||||
|
||||
## 4. Consider the following code
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(1000)
|
||||
```
|
||||
|
||||
What will cause the image to fade back in twice as fast as it faded out?
|
||||
|
||||
<br/>
|
||||
|
||||
led->fade in(500)
|
||||
|
46
olddocs/js/lessons/glowing-sword/quiz.md
Normal file
46
olddocs/js/lessons/glowing-sword/quiz.md
Normal file
@ -0,0 +1,46 @@
|
||||
# glowing sword quiz
|
||||
|
||||
make a glowing sword.
|
||||
|
||||
## Name
|
||||
|
||||
## Directions
|
||||
|
||||
Use this activity document to guide your work in the [glowing sword tutorial](/lessons/glowing-sword/tutorial)
|
||||
|
||||
Answer the questions while completing the tutorial. Pay attention to the dialogues!
|
||||
|
||||
## 1. Describe what "led -> fade out" does?
|
||||
|
||||
<br />
|
||||
|
||||
## 2. Rewrite the second line of code to decrease the speed of the fade out for the longest amount of time Hint: 1000 milliseconds is longest amount of time for a fade out.
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(700)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
||||
## 3. What will cause the image to fade back in twice as fast as it faded out?
|
||||
|
||||
```
|
||||
basic.plotImage(`
|
||||
. . . . #
|
||||
# . . # .
|
||||
. # # . .
|
||||
. # # . .
|
||||
# . . # .
|
||||
`)
|
||||
led.fadeOut(1000)
|
||||
```
|
||||
|
||||
<br/>
|
||||
|
Reference in New Issue
Block a user