Skip to content

Commit 3518b1b

Browse files
committed
Remove a leftover use of var in Chapter 16
1 parent 66770c2 commit 3518b1b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

16_game.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,13 @@ and a size) touches a grid element of the given type.
847847

848848
```{includeCode: true}
849849
Level.prototype.touches = function(pos, size, type) {
850-
var xStart = Math.floor(pos.x);
851-
var xEnd = Math.ceil(pos.x + size.x);
852-
var yStart = Math.floor(pos.y);
853-
var yEnd = Math.ceil(pos.y + size.y);
850+
let xStart = Math.floor(pos.x);
851+
let xEnd = Math.ceil(pos.x + size.x);
852+
let yStart = Math.floor(pos.y);
853+
let yEnd = Math.ceil(pos.y + size.y);
854854
855-
for (var y = yStart; y < yEnd; y++) {
856-
for (var x = xStart; x < xEnd; x++) {
855+
for (let y = yStart; y < yEnd; y++) {
856+
for (let x = xStart; x < xEnd; x++) {
857857
let isOutside = x < 0 || x >= this.width ||
858858
y < 0 || y >= this.height;
859859
let here = isOutside ? "wall" : this.rows[y][x];

html/errata.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ <h2>Chapter 15</h2>
9393

9494
<h2>Chapter 16</h2>
9595

96+
<p><strong>Page 278</strong> <em>Motion and Collision</em>: The code
97+
that defines the <code>touches</code> method unintentionally (though
98+
harmlessly) used <code>var</code> instead of <code>let</code> to
99+
define variables.</p>
100+
96101
<p><strong>Page 285</strong> (2nd) <em>Pausing the Game</em>: The text
97102
refers to the <code>arrow</code> binding, where it should
98103
say <code>arrowKeys</code>.</p>

0 commit comments

Comments
 (0)