3D Game Programming

(C. Jardin) #1
river-rafting game, 185 ,
188 , 197 , 200–205
sound effects, 105
<script> tags, using, 86
semicolons
and functions, 54
errors, 19
setLinearVelocity(), 197
setTimeout(), 139 , 155–156
shadow boxes, 188
shadowMapEnabled attribute, 113
shadows
cameras and, 188
lights and, 113 , 148 , 187
tilt-a-board game, 147 ,
149
shakeTree(), 102
shapes
creating avatars, 26–32
creating simple, 1–15,
217
pulling corners, 193
warping, 189–193
shininess, 111–113
showing code, 5
sine
JavaScript function, 71–
72
jumping animation in
fruit-hunt game, 104
river creation, 193
solar-system animation,
119
walking animation, 62
wiggling animation in
fruit-hunt game, 102
sizing
camera aspect ratio, 87
code for web posting, 214
spheres, 4
web browser screen, 88
skeleton functions, 190
skipping code with if, 74 , 76
slashes
commenting with, 69
division with, 70
slipperiness, 169
smoothing, shapes, 5
solar-system projects
moon phases, 125–132,
243–245
orbit simulation, 117–
123 , 241–243
sounds
about, 277

cave-puzzle game, 183
fruit-hunt game, 100 ,
105
Sounds.js library, about,
105 , 277 , see also sounds
space bar
jumping with, 103
pushing raft with, 198
space simulations
orthographic camera, 91
phases of the moon, 125–
132 , 243–245
solar-system project,
117–123, 241–243
specular attribute, 112
speed
limiting in cave-puzzle
game, 170
phases of the moon, 129
purple fruit monster
game, 138
resetting in river-rafting
game, 197
speed variable, 129
spelling, error messages, 21
SphereGeometry(), 164
spheres
creating, 3–6
creating avatars, 26–32
debugging example, 21–
23
spinAvatar(), 83
spinning
animation for avatar, 82–
84
animation for shapes, 14
animation in fruit-hunt
game, 105
donut, 115
ramps for cave-puzzle
game, 173
splicing lists, 204
splitting code, 179
spot lights, 148
square brackets, listing with,
77
stalactites, 182
stalagmites, 182
Star Trek II: The Wrath of
Khan, 95
Star Wars, 160
stars
solar-system project, 120
tilt-a-board game, 155

startGame(), 198
starter code, 85–91
starting
cartwheel and flipping
animations, 39
games over, 138 , 143 ,
149 , 154 , 196
river-rafting game, 196
spinning animation, 83
walking animation, 64
stopping
cartwheel and flipping
animations, 39
cave-puzzle game, 174
in collision avoidance, 97
game-over check, 138 ,
200
phases-of-the-moon sim-
ulation, 129–130
river-rafting game, 198
spinning animation, 83
walking animation, 64
strings
closing quotes, 54 , 68
defined, 54
joining, 73
subtraction, 69
sun in solar-system project,
118–123
sunlight
river-rafting game, 187
shadows example, 114
shininess example, 112
swinging hands and feet, 60–
63
switching, cameras, 122 , 130

T
tangent, 71
thingsOnCurrentLevel(), 180
third-quarter moon, 131
this keyword, 161–162, 173 ,
180
three-dimensional games and
objects, see 3D
Three.js, about, 22 , 273
tilt(), 152
tilt-a-board game, 145–157,
249–253
time variable, 129
timers
animation, 61 , 115 , 119
cave-puzzle game, 174 ,
181
multilevel games, 181

Index • 286


Prepared exclusively for Michael Powell

Free download pdf