Skip to content

Commit 9829dfc

Browse files
committed
Integrate proofreading for Chapter 15
1 parent c4afb3c commit 9829dfc

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

06_object.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,8 @@ root)))(((Math.sqrt function)))Adding a getter property to the
11021102
constructor can be done with the `Object.defineProperty` function. To
11031103
compute the distance from (0, 0) to (x, y), you can use the
11041104
Pythagorean theorem, which says that the square of the distance we are
1105-
looking for is equal to the square of the x coordinate plus the square
1106-
of the y coordinate. Thus, (!html √(x^2^ + y^2^pass:[)]!)(!tex pass:[$\sqrt{x^2 + y^2}$]!)
1105+
looking for is equal to the square of the x-coordinate plus the square
1106+
of the y-coordinate. Thus, (!html √(x^2^ + y^2^pass:[)]!)(!tex pass:[$\sqrt{x^2 + y^2}$]!)
11071107
is the number you want, and `Math.sqrt` is the way you compute a square
11081108
root in JavaScript.
11091109

15_game.txt

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ overlaid on top of that, using absolutely positioned elements.
8181

8282
(((performance)))In games and other programs that have to animate
8383
((graphics)) and respond to user ((input)) without noticeable delay,
84-
((efficiency)) is important. Though the ((DOM)) was not originally
84+
((efficiency)) is important. Although the ((DOM)) was not originally
8585
designed for high-performance graphics, it is actually better at this
8686
than you would expect. You saw some ((animation))s in
8787
link:13_dom.html#animation[Chapter 13]. On a modern machine, a simple
88-
game like this performs well even if we don't think about
88+
game like this performs well, even if we don't think about
8989
((optimization)) much.
9090

9191
(((canvas)))In the link:16_canvas.html#canvas[next chapter], we will
@@ -120,17 +120,17 @@ var simpleLevelPlan = [
120120
----
121121

122122
Both the fixed ((grid)) and the moving elements are included in the
123-
plan. The _x_ characters stand for ((wall))s, the space characters are for empty
123+
plan. The `x` characters stand for ((wall))s, the space characters for empty
124124
space, and the exclamation marks represent fixed, nonmoving lava tiles.
125125

126-
(((level)))The @ defines the place where the ((player)) starts. Every _o_ is a
127-
((coin)), and the equal sign (=) stands for a block of ((lava))
126+
(((level)))The `@` defines the place where the ((player)) starts. Every `o` is a
127+
((coin)), and the equal sign (`=`) stands for a block of ((lava))
128128
that moves back and forth horizontally. Note that the ((grid)) for
129129
these positions will be set to contain empty space, and another data
130130
structure is used to track the position of such moving elements.
131131

132132
(((bouncing)))We'll support two other kinds of moving ((lava)): the
133-
pipe character (|) for vertically moving blobs, and _v_ for
133+
pipe character (`|`) for vertically moving blobs, and `v` for
134134
_dripping_ lava—vertically moving lava that doesn't bounce back and
135135
forth but only moves down, jumping back to its start position when it
136136
hits the floor.
@@ -194,8 +194,8 @@ type of the square—`"wall"` or `"lava"`.
194194

195195
The ((actor))s array holds objects that track the current position and
196196
((state)) of the dynamic elements in the ((level)). Each of these is
197-
expected to have a `pos` property giving its position (the
198-
((coordinates)) of its top-left corner), a `size` property giving its
197+
expected to have a `pos` property that gives its position (the
198+
((coordinates)) of its top-left corner), a `size` property that gives its
199199
size, and a `type` property that holds a string identifying the
200200
element (`"lava"`, `"coin"`, or `"player"`).
201201

@@ -219,10 +219,9 @@ Level.prototype.isFinished = function() {
219219

220220
== Actors ==
221221

222-
[[vector]]
223-
(((Vector type)))(((coordinates)))To store the position and size of an
224-
actor, we will return to our trusty `Vector` type, which groups an x
225-
coordinate and a y-coordinate into an object.
222+
[[vector]] (((Vector type)))(((coordinates)))To store the position and
223+
size of an actor, we will return to our trusty `Vector` type, which
224+
groups an x-coordinate and a y-coordinate into an object.
226225

227226
// include_code
228227

@@ -281,7 +280,7 @@ Player.prototype.type = "player";
281280
----
282281

283282
Because a player is one-and-a-half squares high, its initial position
284-
is set to be half a square above the position where the @ character
283+
is set to be half a square above the position where the `@` character
285284
appeared. This way, its bottom aligns with the bottom of the square
286285
it appeared in.
287286

@@ -364,7 +363,7 @@ time and motion inside them.
364363
== Encapsulation as a burden ==
365364

366365
(((programming style)))(((program size)))(((complexity)))Most of the
367-
code in this chapter does not worry about ((encapsulation)). This has
366+
code in this chapter does not worry about ((encapsulation)) for
368367
two reasons. First, encapsulation takes extra effort. It makes
369368
programs bigger and requires additional concepts and interfaces to be
370369
introduced. Since there is only so much code you can throw at a reader
@@ -599,7 +598,7 @@ left and one to the top right, to create a white halo effect.
599598
(CSS))))(((max-height (CSS))))(((viewport)))We can't assume that
600599
levels always fit in the viewport. That is why the
601600
`scrollPlayerIntoView` call is needed—it ensures that if the level is
602-
sticking out outside the viewport, we scroll that viewport to make
601+
protruding outside the viewport, we scroll that viewport to make
603602
sure the player is near its center. The following ((CSS)) gives the
604603
game's wrapping ((DOM)) element a maximum size and ensures that
605604
anything that sticks out of the element's box is not visible. We also give the outer element a relative
@@ -772,7 +771,7 @@ Level.prototype.obstacleAt = function(pos, size) {
772771
(((Math.floor function)))(((Math.ceil function)))This method computes the set
773772
of grid squares that the body ((overlap))s with by using `Math.floor`
774773
and `Math.ceil` on the body's ((coordinates)). Remember that ((grid)) squares
775-
are 1-by-1 units in size. By ((rounding)) the sides of a box up and
774+
are 1×1 units in size. By ((rounding)) the sides of a box up and
776775
down, we get the range of ((background)) squares that the box touches.
777776

778777
image::img/game-grid.svg[alt="Finding collisions on a grid",width="3cm"]
@@ -927,8 +926,8 @@ Player.prototype.moveX = function(step, level, keys) {
927926
};
928927
----
929928

930-
(((animation)))(((keyboard)))The motion is computed based on the state
931-
of the left and right arrow keys. When a motion would cause the player to
929+
(((animation)))(((keyboard)))The horizontal motion is computed based on the state
930+
of the left and right arrow keys. When a motion causes the player to
932931
hit something, the level's `playerTouched` method, which handles
933932
things like dying in ((lava)) and collecting ((coin))s, is called.
934933
Otherwise, the object updates its position.
@@ -966,7 +965,7 @@ is accelerated vertically to account for ((gravity)). The gravity,
966965
game have been set by ((trial and error)). I tested various values
967966
until I found a combination I liked.
968967

969-
(((collision detection)))(((keyboard)))(((jumping)))Next we check for
968+
(((collision detection)))(((keyboard)))(((jumping)))Next, we check for
970969
obstacles again. If we hit an obstacle, there are two possible
971970
outcomes. When the up arrow is pressed _and_ we are moving down
972971
(meaning the thing we hit is below us), the speed is set to a
@@ -1055,7 +1054,7 @@ an object with key codes as property names and key names as values,
10551054
will return an object that tracks the current position of those keys.
10561055
It registers event handlers for `"keydown"` and `"keyup"` events and,
10571056
when the key code in the event is present in the set of codes that it
1058-
is tracking, update the object.
1057+
is tracking, updates the object.
10591058

10601059
// include_code
10611060

@@ -1302,7 +1301,7 @@ handler and interrupting or resuming the animation whenever the
13021301
Esc key is hit.
13031302

13041303
(((runAnimation function)))The `runAnimation` interface may not look
1305-
like it is suitable for this, at first glance, but it is, if you
1304+
like it is suitable for this at first glance, but it is, if you
13061305
rearrange the way `runLevel` calls it.
13071306

13081307
(((variable,global)))(((trackKeys function)))When you have that
@@ -1311,7 +1310,7 @@ registering keyboard event handlers is somewhat problematic. The
13111310
`arrows` object is currently a global variable, and its event handlers
13121311
are kept around even when no game is running. You could say they _((leak))_ out of
13131312
our system. Extend `trackKeys` to provide a way to
1314-
unregister its handlers and then change `runLevel` to register its
1313+
unregister its handlers, and then change `runLevel` to register its
13151314
handlers when it starts and unregister them again when it is
13161315
finished.
13171316

16_canvas.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ high. The following code loads the image and then sets up an interval
637637
(((remainder operator)))(((% operator)))The `cycle` variable tracks
638638
our position in the ((animation)). Each ((frame)), it is incremented
639639
and then clipped back to the 0 to 7 range by using the remainder
640-
operator. This variable is then used to compute the x coordinate that
640+
operator. This variable is then used to compute the x-coordinate that
641641
the sprite for the current pose has in the picture.
642642

643643
== Transformation ==
@@ -1044,7 +1044,7 @@ tenth, rightmost sprite.
10441044
(((flipHorizontally function)))(((CanvasDisplay type)))Because the
10451045
((sprite))s are slightly wider than the player object—24 instead of 16
10461046
pixels, to allow some space for feet and arms—the method has to adjust
1047-
the x coordinate and width by a given amount (`playerXOverlap`).
1047+
the x-coordinate and width by a given amount (`playerXOverlap`).
10481048

10491049
// include_code
10501050

@@ -1396,7 +1396,7 @@ from the pie.
13961396
(((Math.cos function)))If you are not sure how to find out which side
13971397
of the circle a given angle is on, look to the explanation of
13981398
`Math.cos` in the previous exercise. The cosine of an angle tells us
1399-
which x coordinate it corresponds to, which in turn tells us exactly
1399+
which x-coordinate it corresponds to, which in turn tells us exactly
14001400
which side of the circle we are on.
14011401

14021402
!!hint!!

0 commit comments

Comments
 (0)