About the Author |
|
xiii | |
About the Technical Reviewer |
|
xiv | |
About the Cover Image Designer |
|
xv | |
Acknowledgments |
|
xi | |
Introduction |
|
xvii | |
|
Chapter 1 Modeling Game Data |
|
|
1 | (66) |
|
|
2 | (1) |
|
The problem with Euler integration |
|
|
3 | (19) |
|
Understanding Verlet integration |
|
|
4 | (1) |
|
|
5 | (8) |
|
Using the main application class |
|
|
13 | (5) |
|
|
18 | (4) |
|
Introducing the Model-View-Controller Pattern |
|
|
22 | (27) |
|
|
23 | (2) |
|
|
25 | (5) |
|
|
30 | (2) |
|
An MVC player and map view example |
|
|
32 | (12) |
|
Verlet + MVC + physics = fun! |
|
|
44 | (5) |
|
A crash course in the drawing API |
|
|
49 | (15) |
|
|
50 | (1) |
|
|
50 | (2) |
|
|
52 | (1) |
|
|
53 | (1) |
|
|
54 | (3) |
|
|
57 | (7) |
|
|
64 | (2) |
|
|
66 | (1) |
|
Chapter 2 Vectors: Ghosts in the Machine |
|
|
67 | (94) |
|
|
68 | (12) |
|
|
69 | (4) |
|
|
73 | (2) |
|
|
75 | (3) |
|
|
78 | (2) |
|
Using and viewing vectors |
|
|
80 | (14) |
|
Creating the vector model |
|
|
80 | (7) |
|
|
87 | (1) |
|
Let's see what those vectors look like! |
|
|
87 | (7) |
|
Adding and subtracting vectors |
|
|
94 | (11) |
|
|
96 | (4) |
|
|
100 | (5) |
|
|
105 | (1) |
|
|
105 | (10) |
|
Are the vectors pointing in the same direction? |
|
|
107 | (3) |
|
|
110 | (3) |
|
Using vector projection for environmental boundaries |
|
|
113 | (2) |
|
|
115 | (6) |
|
Finding the intersection point |
|
|
116 | (2) |
|
|
118 | (3) |
|
|
121 | (30) |
|
Collision on one side of the line |
|
|
121 | (8) |
|
|
129 | (6) |
|
|
135 | (3) |
|
|
138 | (1) |
|
|
139 | (2) |
|
Collision on both sides of the line |
|
|
141 | (5) |
|
Bounce, friction, and gravity |
|
|
146 | (5) |
|
A crash course in embedding assets |
|
|
151 | (4) |
|
|
151 | (1) |
|
|
152 | (3) |
|
Important vector formulas |
|
|
155 | (5) |
|
|
160 | (1) |
|
Chapter 3 Collisions Between Circles |
|
|
161 | (62) |
|
|
162 | (14) |
|
Understanding abstract and concrete classes |
|
|
162 | (4) |
|
Creating and implementing abstract classes |
|
|
166 | (10) |
|
Keyboard and mouse control |
|
|
176 | (5) |
|
Collision-handling basics |
|
|
181 | (30) |
|
Collisions between moving and stationary circles |
|
|
181 | (6) |
|
Collision between a circle and a line |
|
|
187 | (15) |
|
Collision between moving circles |
|
|
202 | (9) |
|
Multiple-object collision |
|
|
211 | (4) |
|
|
215 | (6) |
|
|
221 | (2) |
|
Chapter 4 Collisions Between Polygons |
|
|
223 | (82) |
|
The separating axis theorem |
|
|
224 | (13) |
|
|
224 | (1) |
|
|
225 | (12) |
|
|
237 | (7) |
|
Rectangle collision handling in action |
|
|
238 | (4) |
|
|
242 | (2) |
|
|
244 | (18) |
|
SAT with triangles---the wrong way |
|
|
246 | (1) |
|
SAT with triangles---the right way |
|
|
247 | (3) |
|
Triangle collision handling in action |
|
|
250 | (11) |
|
Triangle collision wrap-up |
|
|
261 | (1) |
|
Oriented bounding box collisions |
|
|
262 | (5) |
|
Polygon and circle collisions |
|
|
267 | (16) |
|
Circle and square collisions |
|
|
268 | (8) |
|
Circle and triangle collisions |
|
|
276 | (6) |
|
|
282 | (1) |
|
|
283 | (18) |
|
Case study 1 Polygon environment |
|
|
283 | (3) |
|
|
286 | (15) |
|
|
301 | (2) |
|
|
303 | (2) |
|
Chapter 5 Pixel-Perfect Collision and Destructible Environments |
|
|
305 | (62) |
|
Vector vs. bitmap graphics |
|
|
306 | (2) |
|
|
308 | (1) |
|
|
309 | (11) |
|
|
310 | (4) |
|
The problems with bitmap collision |
|
|
314 | (1) |
|
Finding the collision boundary |
|
|
315 | (5) |
|
Bitmap collision-detection strategies |
|
|
320 | (24) |
|
|
321 | (7) |
|
|
328 | (2) |
|
|
330 | (14) |
|
Adding objects to scrolling environments |
|
|
344 | (7) |
|
Using two-dimensional arrays |
|
|
345 | (4) |
|
Creating and adding the objects |
|
|
349 | (1) |
|
|
350 | (1) |
|
Building a rotating gun turret |
|
|
351 | (6) |
|
Drawing and rotating the cannon |
|
|
352 | (3) |
|
|
355 | (1) |
|
Moving and removing bullets |
|
|
356 | (1) |
|
|
357 | (8) |
|
Bitmap collision using points |
|
|
359 | (1) |
|
|
360 | (2) |
|
|
362 | (3) |
|
|
365 | (2) |
|
Chapter 6 Explosions, Blitting, and Optimization |
|
|
367 | (78) |
|
A simple particle explosion |
|
|
368 | (10) |
|
Using timer events for animation |
|
|
369 | (2) |
|
Creating the Explosion class |
|
|
371 | (7) |
|
A more realistic explosion |
|
|
378 | (18) |
|
|
379 | (5) |
|
|
384 | (12) |
|
|
396 | (5) |
|
|
401 | (28) |
|
Introducing bit-block transfer |
|
|
401 | (3) |
|
|
404 | (12) |
|
|
416 | (5) |
|
|
421 | (3) |
|
|
424 | (5) |
|
|
429 | (5) |
|
|
434 | (4) |
|
|
438 | (6) |
|
|
438 | (4) |
|
|
442 | (2) |
|
|
444 | (1) |
|
Chapter 7 Make It Fun! Sound, Music, and Al |
|
|
445 | (58) |
|
|
446 | (1) |
|
|
447 | (16) |
|
|
448 | (3) |
|
|
451 | (9) |
|
Using sound and music in a game |
|
|
460 | (2) |
|
Finding sound effects and music |
|
|
462 | (1) |
|
|
463 | (4) |
|
|
463 | (1) |
|
|
464 | (3) |
|
|
467 | (10) |
|
|
476 | (1) |
|
|
477 | (24) |
|
Structure: your best friend and worst enemy |
|
|
479 | (5) |
|
|
484 | (5) |
|
Multiple views of the game data |
|
|
489 | (2) |
|
|
491 | (7) |
|
|
498 | (2) |
|
|
500 | (1) |
|
|
501 | (2) |
|
Chapter 8 Tile-Based Game Design |
|
|
503 | (120) |
|
Tile-based game advantages |
|
|
504 | (1) |
|
|
505 | (23) |
|
|
505 | (3) |
|
|
508 | (2) |
|
Describing the map with a two-dimensional array |
|
|
510 | (2) |
|
|
512 | (3) |
|
Putting the map in the game |
|
|
515 | (6) |
|
|
521 | (3) |
|
Reviewing the Map application class |
|
|
524 | (4) |
|
|
528 | (10) |
|
|
529 | (3) |
|
Making the game character move |
|
|
532 | (5) |
|
Blitting a moving character in a tile-based world |
|
|
537 | (1) |
|
|
538 | (17) |
|
Understanding spatial grid collision |
|
|
540 | (2) |
|
|
542 | (4) |
|
Applying a spatial grid to platform collision |
|
|
546 | (8) |
|
|
554 | (1) |
|
|
555 | (30) |
|
|
555 | (3) |
|
|
558 | (4) |
|
|
562 | (4) |
|
Wind them up and let them loose! |
|
|
566 | (4) |
|
|
570 | (3) |
|
|
573 | (6) |
|
|
579 | (6) |
|
|
585 | (5) |
|
|
587 | (1) |
|
Establishing game world coordinates |
|
|
588 | (2) |
|
Using sprites in a tile-based world |
|
|
590 | (9) |
|
Blitting the tile into a sprite |
|
|
592 | (3) |
|
Creating the car's control system |
|
|
595 | (3) |
|
|
598 | (1) |
|
Storing extra game data in arrays |
|
|
599 | (6) |
|
|
603 | (1) |
|
|
604 | (1) |
|
|
605 | (15) |
|
Understanding dynamic spatial grids |
|
|
606 | (1) |
|
|
607 | (4) |
|
|
611 | (9) |
|
Other broad-phase collision strategies |
|
|
620 | (1) |
|
|
621 | (2) |
|
|
623 | (68) |
|
|
624 | (31) |
|
|
625 | (1) |
|
Moving and changing direction |
|
|
626 | (7) |
|
Random movement in a maze |
|
|
633 | (9) |
|
|
642 | (5) |
|
|
647 | (8) |
|
Finding the shortest path |
|
|
655 | (34) |
|
|
656 | (11) |
|
|
667 | (9) |
|
|
676 | (4) |
|
|
680 | (4) |
|
|
684 | (1) |
|
|
685 | (3) |
|
Extending and customizing A |
|
|
688 | (1) |
|
|
689 | (2) |
|
Chapter 10 XML and External Data |
|
|
691 | (58) |
|
|
692 | (12) |
|
Creating and loading shared objects |
|
|
692 | (1) |
|
|
693 | (5) |
|
Limitations of local shared objects |
|
|
698 | (1) |
|
Loading and saving files to a specific location |
|
|
699 | (5) |
|
|
704 | (6) |
|
The building blocks of XML |
|
|
704 | (2) |
|
|
706 | (3) |
|
|
709 | (1) |
|
|
710 | (9) |
|
Reading elements, text nodes, and attributes |
|
|
711 | (8) |
|
|
719 | (5) |
|
Adding new elements and attributes |
|
|
719 | (2) |
|
Building XML documents from existing variables |
|
|
721 | (1) |
|
Removing nodes from XML documents |
|
|
722 | (2) |
|
Loading game levels from XML data |
|
|
724 | (17) |
|
Creating a game level map |
|
|
725 | (1) |
|
Loading and interpreting the XML map data |
|
|
726 | (4) |
|
Creating multiple game levels with XML |
|
|
730 | (11) |
|
Loading XML files at runtime |
|
|
741 | (4) |
|
Using URLLoader to load files |
|
|
741 | (1) |
|
Runtime loading security issues |
|
|
742 | (3) |
|
|
745 | (4) |
|
|
745 | (1) |
|
|
745 | (1) |
|
|
746 | (1) |
|
|
747 | (1) |
|
|
747 | (2) |
Index |
|
749 | |