Skip to content

Commit

Permalink
making format updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jedi-force committed Nov 8, 2024
1 parent d30e181 commit 3d4764b
Show file tree
Hide file tree
Showing 82 changed files with 447 additions and 1,106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
# Build the book
- name: Build the book
run: |
jupyter-book build snap-manual
jupyter-book build .
# Upload the book's HTML as an artifact
- name: Upload artifact
Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/static.yml

This file was deleted.

Binary file modified _build/.doctrees/content/C1-S1.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S12.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S17.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S2.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S3.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S4.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S5.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S6.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S7.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/C1-S8.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/Chapter1.doctree
Binary file not shown.
Binary file modified _build/.doctrees/content/Chapter2.doctree
Binary file not shown.
Binary file modified _build/.doctrees/environment.pickle
Binary file not shown.
7 changes: 1 addition & 6 deletions _build/html/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,7 @@
<li class="toctree-l3"><a class="reference internal" href="content/C1-S8.html">Transient variables</a></li>
</ul>
</details></li>
<li class="toctree-l2 has-children"><a class="reference internal" href="content/C1-S12.html">Debugging</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l3"><a class="reference internal" href="content/C1-S13.html">The pause button</a></li>
<li class="toctree-l3"><a class="reference internal" href="content/C1-S15.html">Breakpoints: the pause all block</a></li>
<li class="toctree-l3"><a class="reference internal" href="content/C1-S16.html">Visible stepping</a></li>
</ul>
</details></li>
<li class="toctree-l2"><a class="reference internal" href="content/C1-S12.html">Debugging</a></li>
<li class="toctree-l2"><a class="reference internal" href="content/C1-S17.html">Etcetera</a></li>
<li class="toctree-l2"><a class="reference internal" href="content/C1-S18.html">Libraries</a></li>
</ul>
Expand Down
60 changes: 20 additions & 40 deletions _build/html/_sources/content/C1-S1.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,52 +32,41 @@ the program, click the red stop sign at the right end of the tool bar.)

## Costumes and Sounds

<img src="/content/assets/images/image30.png" style="width:31px; height:21px">
<img src="/content/assets/images/image31.png" style="width:170px; height:180px">
<img src="/content/assets/images/image32.png" style="width:28px; height:16px">
To change the appearance of a sprite,
paint or import a new *costume* for it. To paint a costume, click on the
Costumes tab above the scripting area, and click the paint button . The
*Paint Editor* that appears is explained on page 128. There are three
ways to import a costume. First select the desired sprite in the sprite
corral. Then, one way is to click on the file icon in the tool bar ,
then choose the "Costumes..."menu item. You will see a list of costumes
from the public media library, and can choose one. The second way, for a
To change the appearance of a sprite, paint or import a new *costume* for it. To paint a costume, click on the Costumes tab above the scripting area, and click the paint button. <img src="/content/assets/images/image32.png" style="width:28px; height:16px"> The *Paint Editor* that appears is explained on page 128. There are three ways to import a costume. First select the desired sprite in the sprite corral. Then, one way is to click on the file icon in the tool bar, then choose the <img src="/content/assets/images/image30.png" style="width:31px; height:21px"> "Costumes..."menu item. You will see a list of costumes from the public media library, and can choose one. The second way, for a
costume stored on your own computer, is to click on the file icon and
choose the "Import..." menu item. You can then select a file in any
picture format (PNG, JPEG, etc.) supported by your browser. The third
way is quicker if the file you want is visible on the desktop: Just drag
the file onto the Snap*!* window. In any of these cases, the scripting
the file onto the Snap<em>!</em> window. In any of these cases, the scripting
area will be replaced by something like this:

<img src="/content/assets/images/image31.png" style="width:170px; height:180px">

Just above this part of the window is a set of three tabs: Scripts,
Costumes, and Sounds. You'll see that the Costumes tab is now selected.
In this view, the sprite's *wardrobe,* you can choose whether the sprite
should wear its Turtle costume or its Alonzo costume. (Alonzo, the
Snap*!* mascot, is named after Alonzo Church, a mathematician who
Snap<em>!</em> mascot, is named after Alonzo Church, a mathematician who
invented the idea of procedures as data, the most important way in which
Snap*!* is different from Scratch.) You can give a sprite as many
Snap<em>!</em> is different from Scratch.) You can give a sprite as many
costumes as you like, and then choose which it will wear either by
clicking in its wardrobe or by using the or block in a script. (Every
clicking in its wardrobe or by using the <img src="/content/assets/images/image34.png" style="width:180px; height:25px"> or <img src="/content/assets/images/image35.png" style="width:173px; height:27px"> block in a script. (Every
costume has a number as well as a name. The next costume block selects
the next costume by number; after the highest-numbered costume it
switches to costume 1. The Turtle, costume 0, is never chosen by next
costume.) The Turtle costume is the only one that changes color to match
a change in the sprite's pen color. Protip: switches to the *previous*
a change in the sprite's pen color. Protip: <img src="/content/assets/images/image33.png" style="width:173px; height:27px"> switches to the *previous*
costume, wrapping like next costume.

<img src="/content/assets/images/image33.png" style="width:173px; height:27px">
<img src="/content/assets/images/image34.png" style="width:283px; height:25px">
<img src="/content/assets/images/image38.png" style="width:182px; height:25px">
<img src="/content/assets/images/image39.png" style="width:119px; height:25px">

In addition to its costumes, a sprite can
have *sounds;* the equivalent for sounds of the sprite's wardrobe is
called its *jukebox.* Sound files can be imported in any format (WAV,
OGG, MP3, etc.) supported by your browser. *Two blocks accomplish the
OGG, MP3, etc.) supported by your browser. Two blocks accomplish the
task of playing sounds. If you would like a script to continue running
while the sound is playing, use the block . In contrast, you can use the
block to wait for the sound\'s completion before continuing the rest of
the script.*
while the sound is playing, use the block <img src="/content/assets/images/image39.png" style="width:119px; height:25px">. In contrast, you can use the <img src="/content/assets/images/image38.png" style="width:182px; height:25px">
block to wait for the sound's completion before continuing the rest of
the script.

## Inter-Sprite Communication with Broadcast

Expand All @@ -86,34 +75,25 @@ more interesting program, though, the sprites on stage will *interact*
to tell a story, play a game, etc. Often one sprite will have to tell
another sprite to run a script. Here's a simple example:

<img src="/content/assets/images/image40.png" style="width:165px; height:24px">

<img src="/content/assets/images/image41.png" style="width:55px; height:107px">

<img src="/content/assets/images/image42.png" style="width:267px; height:145px">

<img src="/content/assets/images/image43.png" style="width:119px; height:83px">

<img src="/content/assets/images/image43.png" style="width:119px; height:83px">
<img src="/content/assets/images/image44.png" style="width:146px; height:58px">


<img src="/content/assets/images/image45.png" style="width:172px; height:19px">
<img src="/content/assets/images/image46.png" style="width:173px; height:18px">
In the block, the word "bark" is just an
arbitrary name I made up. When you click on the downward arrowhead in
that input slot, one of the choices (the only choice, the first time) is
"new," which then prompts you to enter a name for the new broadcast.
When this block is run, the chosen message is sent to *every* sprite,
which is why the block is called "broadcast." (But if you click the
right arrow after the message name, the block becomes , and you can
change it to  to send the message just to one sprite.) In this program,


In the block <img src="/content/assets/images/image40.png" style="width:165px; height:24px">, the word "bark" is just an arbitrary name I made up. When you click on the downward arrowhead in that input slot, one of the choices (the only choice, the first time) is "new," which then prompts you to enter a name for the new broadcast. When this block is run, the chosen message is sent to *every* sprite, which is why the block is called "broadcast." (But if you click the
right arrow after the message name, the block becomes <img src="/content/assets/images/image45.png" style="width:172px; height:19px">, and you can change it to <img src="/content/assets/images/image46.png" style="width:173px; height:18px"> to send the message just to one sprite.) In this program,
though, only one sprite has a script to run when that broadcast is sent,
namely the dog. Because the boy's script uses broadcast and wait rather
than just broadcast, the boy doesn't go on to his next say block until
the dog's script finishes. That's why the two sprites take turns
talking, instead of both talking at once. In Chapter VII,
"Object-Oriented Programming with Sprites," you'll see a more flexible
way to send a message to a specific sprite using the tell and ask
blocks.
talking, instead of both talking at once. In Chapter VII, "Object-Oriented Programming with Sprites," you'll see a more flexible way to send a message to a specific sprite using the tell and ask blocks.

Notice, by the way, that the say block's first input slot is rectangular
rather than oval. This means the input can be any text string, not only
Expand Down
70 changes: 16 additions & 54 deletions _build/html/_sources/content/C1-S12.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
# Debugging

Snap*!* provides several tools to help you debug a program. They center
Snap<em>!</em> provides several tools to help you debug a program. They center
around the idea of *pausing* the running of a script partway through, so
that you can examine the values of variables.

## The pause button

<img src="/content/assets/images/image115.png" style="width:28px; height:16px">
<img src="/content/assets/images/image116.png" style="width:28px; height:16px">
The simplest way to pause a program is
manually, by clicking the pause button in the top right corner of the
window. While the program is paused, you can run other scripts by
clicking on them, show variables on stage with the checkbox next to the variable in the Variables palette or with the show variable block, and
do all the other things you can generally do, including modifying the
paused scripts by adding or removing blocks. The button changes shape to
and clicking it again resumes the paused scripts.
The simplest way to pause a program is manually, by clicking the pause button <img src="/content/assets/images/image116.png" style="width:28px; height:16px"> in the top right corner of the window. While the program is paused, you can run other scripts by clicking on them, show variables on stage with the checkbox next to the variable in the Variables palette or with the show variable block, and do all the other things you can generally do, including modifying the paused scripts by adding or removing blocks. The button changes shape to <img src="/content/assets/images/image115.png" style="width:28px; height:16px"> and clicking it again resumes the paused scripts.

## Breakpoints: the pause all block

<img src="/content/assets/images/image117.png" style="width:79px; height:21px">
The pause button is great if your program
seems to be in an infinite loop, but more often you'll want to set a
*breakpoint,* a particular point in a script at which you want to pause.
The block, near the bottom of the Control palette, can be inserted in a
script to pause when it is run. So, for example, if your program is
getting an error message in a particular block, you could use pause all
just before that block to look at the values of variables just before
the error happens.

The pause button is great if your program seems to be in an infinite loop, but more often you'll want to set a *breakpoint,* a particular point in a script at which you want to pause. The block <img src="/content/assets/images/image117.png" style="width:79px; height:21px">, near the bottom of the Control palette, can be inserted in a script to pause when it is run. So, for example, if your program is getting an error message in a particular block, you could use pause all just before that block to look at the values of variables just before the error happens.

The pause all block turns bright cyan while paused. Also, during the pause, you can right-click on a running script and the menu that appears will give you the option to show watchers for temporary variables of the script:

<img src="/content/assets/images/image118.png" style="width:181px; height:87px">
The pause all block turns bright cyan
while paused. Also, during the pause, you can right-click on a running
script and the menu that appears will give you the option to show
watchers for temporary variables of the script:

But what if the block with the error is run many times in a loop, and it
only errors when a particular condition is true---say, the value of some
variable is negative, which shouldn't ever happen. In the iteration
library (see page 25 for more about how to use libraries) is a
breakpoint block that lets you set a *conditional* breakpoint, and
automatically display the relevant variables before pausing. Here's a
sample use of it:

But what if the block with the error is run many times in a loop, and it only errors when a particular condition is true---say, the value of some variable is negative, which shouldn't ever happen. In the iteration library (see page 25 for more about how to use libraries) is a breakpoint block that lets you set a *conditional* breakpoint, and automatically display the relevant variables before pausing. Here's a sample use of it:

<img src="/content/assets/images/image119.png" style="width:115px; height:128px">
(In this contrived example, variable zot
Expand All @@ -52,31 +29,16 @@ all inside an if.[^2]

## Visible stepping

<img src="/content/assets/images/image121.png" style="width:28px; height:16px">
<img src="/content/assets/images/image122.png" style="width:52px; height:15px">
<img src="/content/assets/images/image123.png" style="width:28px; height:16px">
Sometimes you're not exactly sure where
the error is, or you don't understand how the program got there. To
understand better, you'd like to watch the program as it runs, at human
speed rather than at computer speed. You can do this by clicking the
*visible stepping button* ( ), before running a script or while the
script is paused. The button will light up ( ) and a speed control
slider will appear in the toolbar. When you start or continue the
script, its blocks and input slots will light up cyan one at a time:

Sometimes you're not exactly sure where the error is, or you don't understand how the program got there. To understand better, you'd like to watch the program as it runs, at human speed rather than at computer speed. You can do this by clicking the *visible stepping button* (<img src="/content/assets/images/image121.png" style="width:28px; height:16px">), before running a script or while the script is paused. The button will light up (<img src="/content/assets/images/image123.png" style="width:28px; height:16px">) and a speed control slider <img src="/content/assets/images/image122.png" style="width:52px; height:15px"> will appear in the toolbar. When you start or continue the script, its blocks and input slots will light up cyan one at a time:

<img src="/content/assets/images/image124.png" style="width:720px; height:110px">
In this simple example, the inputs to the blocks are
constant values, but if an input were a more complicated expression
involving several reporter blocks, each of those would light up as they
are called. Note that the input to a block is evaluated before the block
itself is called, so, for example, the 100 lights up before the move.

<img src="/content/assets/images/image134.png" style="width:28px; height:16px">
The speed of stepping is controlled by
the slider. If you move the slider all the way to the left, the speed is
zero, the pause button turns into a step button , and the script takes a
single step each time you push it. The name for this is *single
stepping.*

In this simple example, the inputs to the blocks are constant values, but if an input were a more complicated expression involving several reporter blocks, each of those would light up as they are called. Note that the input to a block is evaluated before the block itself is called, so, for example, the 100 lights up before the move.

<!--<img src="/content/assets/images/image134.png" style="width:28px; height:16px">-->

The speed of stepping is controlled by the slider. If you move the slider all the way to the left, the speed is zero, the pause button turns into a step button , and the script takes a single step each time you push it. The name for this is *single stepping.*

If several scripts that are visible in the scripting area are running at
the same time, all of them are stepped in parallel. However, consider
Expand Down
2 changes: 1 addition & 1 deletion _build/html/_sources/content/C1-S17.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ case-independent.
<img src="/snap-manual/assets/images/image171.png" style="width:275px; height:18px">
These *hidden* blocks can be found with
the relabel option of any dyadic arithmetic block. They're hidden partly
because writing them in Snap*!* is a good, pretty easy programming
because writing them in Snap<em>!</em> is a good, pretty easy programming
exercise. Note: the two inputs to atan2 are Δ*x* and Δ*y* in that order,
because we measure angles clockwise from north. Max and min are
*variadic;* by clicking the arrowhead, you can provide additional
Expand Down
Loading

0 comments on commit 3d4764b

Please sign in to comment.