Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update & Swap free-throw #6351

Merged
merged 2 commits into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions docs/test/tutorials/free-throw-jr.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## {1. Introduction @showdialog}

Line up your shot and see if you can slam dunk this Basketball free throw game!
Let's code a free-throw game!

![Free throw shot from player](/static/tutorials/free-throw/freethrow.gif)

Expand Down Expand Up @@ -36,9 +36,9 @@ freethrow.setCourt()
## {3. Look at the game window}


- :binoculars: Look at your project in the game window!
- :binoculars: Look at the game window!

You should see the court background that you just added.
You should see a basketball court.

![Look for the game window in the lower right](/static/tutorials/free-throw/game.png)

Expand Down Expand Up @@ -68,24 +68,24 @@ freethrow.addPlayer(throw_imgs.dunk)
```blocks
freethrow.setCourt()
//@highlight
freethrow.throw_imgs.dunk
freethrow.addPlayer(throw_imgs.dunk)
```



## {7. Look at the game window again}
## {5. Look at the game window again}


- :binoculars: Look at your project in the game window!
- :binoculars: Look at the game window again!

You should see the athlete start running forward.
You should see the athlete moving across the court.






## {9. Create the Basketball Hoop}
## {6. Create the Basketball Hoop}

**Add the hoop!**

Expand All @@ -97,15 +97,15 @@ freethrow.addHoop()
#### ~ tutorialhint
```blocks
freethrow.setCourt()
freethrow.throw_imgs.dunk
freethrow.addPlayer(throw_imgs.dunk)
//@highlight
freethrow.addHoop()

```



## {10. Use (A) Button to Toss}
## {7. Use (A) Button to Toss}

**Make (A) toss the ball**

Expand All @@ -128,13 +128,14 @@ freethrow.onA(function () {



## {12. Test it Out}
## {8. Test it Out}


- :binoculars: Look at your game!

- Your player should be moving back and forth on the court
- When you press the (A) button (or space bar) the player should shoot a basketball toward the top of the screen
Your player should move across the court.

When you press the (A) button <br/>(or space bar)<br/> the player should throw the ball.


~hint It isn't working 🤷‍♂️
Expand All @@ -158,7 +159,7 @@ hint~



## {13. Points when we get a basket}
## {9. Points when we get a basket}


**Add points for each basket**
Expand Down Expand Up @@ -218,7 +219,7 @@ freethrow.gameCountdown(30)



## You did a great job!!! @showdialog
<!--## You did a great job!!! @showdialog


### What did you think of this tutorial?
Expand All @@ -227,7 +228,7 @@ freethrow.gameCountdown(30)

Would you like to tell us more?

(Yes) (No)
(Yes) (No) -->



Expand All @@ -237,9 +238,9 @@ Would you like to tell us more?

---

You've coded an amazing game!
You've made a free-throw game!

**Can you get 20 points before the counter gets down to zero?**
**Can you get 20 points before time runs out?**

When you've finished playing, click **Done** so you can share your tutorial with family and friends!

Expand Down Expand Up @@ -559,4 +560,4 @@ freethrow.setScoreOverride(0)
"#000000"
]
}
```
```
52 changes: 37 additions & 15 deletions docs/test/tutorials/free-throw.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Line up your shot and see if you can slam dunk this Basketball free throw game!

**Ready to start coding?**

Let's add the basketball court background.
Let's add a basketball court as the background.

---

Expand All @@ -40,10 +40,18 @@ block, we are pointing you toward <br/>
scene.setBackgroundImage(img`.`)
```

which is located in the ``||scene:Scene||`` category in the Toolbox.

hint~

- :paint brush: Click the empty grey box in the background block to draw a basketball court <Br/>
(or switch to the **Gallery** to pick the one that we created.)

<!--
<br/><br/>
💡 _The court image should be preloaded in the block, but you are welcome to edit the image if you like._
-->



#### ~ tutorialhint
Expand Down Expand Up @@ -80,7 +88,7 @@ You should see the court background that you just added.
- :paper plane: From ``||sprites:Sprites||``, drag<br/>
``||variables(sprites):set [athlete] to sprite [ ] of kind [Player]||``<br/>
to **the end** of the
``||loops:on start||`` container.
``||loops(noclick):on start||`` container.


~hint What's a sprite? 💡
Expand All @@ -95,9 +103,17 @@ Our athlete will be a sprite, too.

hint~


- :paint brush: Click the empty grey box in the sprite block to draw your player <Br/>
(or switch to the **Gallery** to pick one that we created.)



<!--

<br/><br/>
💡 _The athlete image should be preloaded in the block, but you are welcome to edit the image if you like._

-->

#### ~ tutorialhint
```blocks
Expand Down Expand Up @@ -242,7 +258,7 @@ Using what you learned when adding the athlete, add a hoop to the scene then pos
- :paper plane: From ``||sprites:Sprites||``, drag<br/>
``||variables(sprites):set [hoop] to sprite [ ] of kind [Goal]||``<br/>
to **the end** of the
``||loops(noclick):on start||`` container.
``||loops(noclick):on start||`` container, then select the hoop from the Gallery.

- :paper plane: From the ``||sprites: Sprites||`` category in the toolbox, grab <br/>
``||sprites: set [hoop] position to x [80] y [35]||`` <br/>
Expand Down Expand Up @@ -323,13 +339,19 @@ hint~


- :paper plane: Snap <br/>
``||variables(sprites):set [projectile] to projectile [🏀] from [athlete] with vx [0] vy [-100]||`` <br/>
``||variables(sprites):set [projectile] to projectile [ ] from [athlete] with vx [0] vy [-100]||`` <br/>
inside **the empty** <br/>
``||controller(noclick):on [A] button pressed ||``<br/>
container.

💡 _The projectile is a basketball, but you can click the ball and change it to whatever you like._

- :paint brush: Click the empty grey box in the projectile block to draw a basketball <br/>
(or switch to the **Gallery** to pick the one that we created.)


<!--
💡 _The projectile is a basketball, but you can click the ball and change it to whatever you like._
-->



Expand All @@ -354,8 +376,9 @@ controller.A.onEvent(ControllerButtonEvent.Pressed, function () {

- :binoculars: Look at your game!

- Your player should be moving back and forth on the court
- When you press the (A) button (or space bar) the player should shoot a basketball toward the top of the screen
Your player should be moving back and forth on the court.

When you press the (A) button (or space bar) the player should shoot a basketball toward the top of the screen.


💡 _We will add points in the next step._
Expand Down Expand Up @@ -443,7 +466,7 @@ and snap it into **the end** of the <br/>
containter in the workspace.


~hint Why "destroy sprite"? 💡
~hint Why destroy "sprite"? 💡

---

Expand Down Expand Up @@ -478,7 +501,7 @@ sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Goal, function (sprite, othe

- :binoculars: Look at your project in the game window!

You should get a point every time your basketball overlaps the hoop!
You should get exactly one point every time your basketball overlaps the hoop!



Expand Down Expand Up @@ -528,10 +551,7 @@ info.startCountdown(30)
```





## You did a great job!!! @showdialog
<!--## You did a great job!!! @showdialog


### What did you think of this tutorial?
Expand All @@ -542,6 +562,8 @@ Would you like to tell us more?

(Yes) (No)

-->



## {18. Finale}
Expand Down Expand Up @@ -597,7 +619,7 @@ sprites.onOverlap(SpriteKind.Projectile, SpriteKind.Goal, function (sprite, othe
projectile = sprites.createProjectileFromSprite(throw_imgs.ball, athlete, 0, -100)
music.play(music.createSong(hex`00780004080200`), music.PlaybackMode.InBackground)

scene.setBackgroundImage(throw_imgs.court)
scene.setBackgroundImage(img`.`)
```


Expand Down
Loading
Loading