I
ICE Code Editor
debugging in, 19 , 86
freezing, 14 , 23
line numbers for error
messages, 22
using, 1–4
id= attribute and web hosting,
213
if
skipping code with, 74 ,
76
tilt-a-board game logic,
156
images, adding simple, 141
immovable objects, see obsta-
cles
index, list, 204
initializing, 172
Internet, publishing code to,
207–215
Internet Explorer, xv, 2
intersections and rays, 94–98
isActive property, 173
isGoal property, 170
isWalking(), 64
J
JavaScript
about, xvi, 67
advantages, 78
boilerplate code, 85–91
Booleans, 73
console, 17–24, 160–161
debugging, 19–23
describing things, 67
documentation, 273–278
geometry, 71–72
libraries, 273–278
listing things, 77 , 204
mathematics, 69–72
objects, 159–164
shape creation, 4–14
strings, 54 , 68 , 73
joining strings, 73
jump(), 103
jumping
fruit-hunt game, 103
purple fruit monster
game, 133–143
K
keyboard controls
avatar movement, 36–40,
46 , 140
camera switching, 122 ,
130
cartwheels and flips, 66
cave-puzzle game, 169 ,
173
collision avoidance, 97
if and else keyword con-
trols, 76
jumping, 103
pausing animations, 130
purple fruit monster
game, 140
resetting games, 143
river-rafting game, 197
tilt-a-board game, 145 ,
152–153
walking animation, 63–65
keycodes, 37
keywords
about, 67
control, 74–76
Kung Fu Panda, 163
L
launchFruit(), 139
lazy programming, 27 , 129
levelUp(), 181
levels, creating, 177–184, see
also multilevel games
Levels object, 179–184
lids, 190 , 193
lights
ambient, 113 , 118 , 148
directional, 187
flashing, 154
goal, 154–155
point, 118 , 148
shadows, 113 , 148
shininess and, 111–113
spot, 148
sunlight, 112 , 114 , 187
tilt-a-board game, 147
using, 109–116, 240–241
line numbers and error mes-
sages, 21
linear factor, 137 , 169
linear velocity, 138 , 197
listenForEvents(), 173
lists
collision avoidance, 96
color, 43 , 110
multilevel games, 180
removing items from, 204
square brackets, 77
of trees in fruit-hunt
game, 101
local coordinates, 205
localToWorld(), 205
log
functions example, 49–
58 , 222
JavaScript console, 18 ,
160–161
logic, game, 156
M
m_angle, 128
makeBorder(), 167
makeGround(), 190–192
makeTree(), 101
makeTreeAt(), 40–43, 96
markers, avatar, 45–47, 82
Mars
phases-of-the-moon
project, 126
solar-system project,
119–123
materials
bouncy, 169
changing color, 109–113
defined, 4
image, 141
reusing, 27
shininess, 111–113
slippery, 169
using, 109–116, 240–241
Math.abs(), 170
Math.cos(), 72
Math.floor(), 102 , 204
Math.PI, 71 , 81
-Math.PI/2, 81
Math.random(), 102 , 170 , 203
Math.sin()
about, 62 , 72
river creation, 193
walking animation, 62
wiggling animation, 102
mathematics, see also geome-
try
in JavaScript, 69–72
order of operations, 70
matrix, 205
me variable, 173
Mesh(), 164
mesh
changing color, 109–113
construction function,
164
defined, 4
Index • 283
Prepared exclusively for Michael Powell