| About the Author |
|
xiii | |
| About the Technical Reviewer |
|
xiv | |
| About the Cover Image Designer |
|
xv | |
| Acknowledgements |
|
xvi | |
| Introduction |
|
xvii | |
|
Chapter 1 Programming Foundations: How To Make A Video Game |
|
|
1 | (56) |
|
|
|
2 | (3) |
|
|
|
2 | (1) |
|
2 Graphic design software |
|
|
2 | (1) |
|
3 Computer programming software |
|
|
3 | (2) |
|
|
|
5 | (1) |
|
|
|
5 | (1) |
|
And the things you don't need to know |
|
|
6 | (1) |
|
It's all about programming |
|
|
6 | (1) |
|
Programming? But I'm terrible at math! |
|
|
7 | (1) |
|
I already know how to program! |
|
|
8 | (2) |
|
What kind of games can I make? |
|
|
8 | (1) |
|
|
|
9 | (1) |
|
|
|
9 | (1) |
|
|
|
10 | (10) |
|
Setting up the work environment in Flash Builder |
|
|
10 | (10) |
|
Writing your first program |
|
|
20 | (1) |
|
ActionScript files and the as file extension |
|
|
20 | (2) |
|
|
|
22 | (10) |
|
A little magic with sprites |
|
|
23 | (2) |
|
|
|
25 | (2) |
|
Using the constructor method |
|
|
27 | (2) |
|
|
|
29 | (3) |
|
|
|
32 | (2) |
|
Adding comments to your code |
|
|
34 | (2) |
|
Running your program and compiling the SWF file |
|
|
36 | (4) |
|
What happened when you compiled the program |
|
|
38 | (2) |
|
|
|
40 | (5) |
|
Some common error messages |
|
|
43 | (2) |
|
Confirm your program with the original source files |
|
|
45 | (1) |
|
|
|
45 | (7) |
|
Editing window quirks and features |
|
|
45 | (3) |
|
|
|
48 | (4) |
|
A little more about AS3.0 and the Flash Player |
|
|
52 | (2) |
|
|
|
54 | (1) |
|
|
|
55 | (2) |
|
Chapter 2 Making Game Graphics |
|
|
57 | (64) |
|
Create a game world background |
|
|
59 | (47) |
|
Create a new file in Photoshop |
|
|
60 | (4) |
|
|
|
64 | (12) |
|
|
|
76 | (3) |
|
Drawing with the pen tool |
|
|
79 | (12) |
|
Duplicating, modifying, and arranging layers |
|
|
91 | (5) |
|
|
|
96 | (4) |
|
Making boxes with the rectangular selection tool |
|
|
100 | (6) |
|
|
|
106 | (4) |
|
|
|
106 | (1) |
|
|
|
107 | (3) |
|
|
|
110 | (8) |
|
|
|
111 | (1) |
|
|
|
111 | (3) |
|
|
|
114 | (1) |
|
|
|
115 | (2) |
|
Save your work and make the PNG files |
|
|
117 | (1) |
|
|
|
118 | (1) |
|
|
|
119 | (1) |
|
|
|
120 | (1) |
|
Chapter 3 Programming Objects |
|
|
121 | (88) |
|
But I'm a bit scared of programming! |
|
|
122 | (1) |
|
Loading and displaying images |
|
|
123 | (35) |
|
Setting up a new AS3.0 project |
|
|
124 | (2) |
|
Understanding the setup file |
|
|
126 | (1) |
|
Set up the Flash Player with a metadata tag |
|
|
127 | (3) |
|
Loading and displaying the background.png image |
|
|
130 | (2) |
|
|
|
132 | (2) |
|
|
|
134 | (1) |
|
|
|
135 | (1) |
|
|
|
136 | (1) |
|
Creating instances and objects |
|
|
137 | (3) |
|
Displaying the image on the stage |
|
|
140 | (7) |
|
Understanding the code structure |
|
|
147 | (1) |
|
Positioning Sprites on the stage |
|
|
148 | (10) |
|
|
|
158 | (20) |
|
Understanding dot notation |
|
|
159 | (1) |
|
|
|
159 | (1) |
|
|
|
160 | (1) |
|
Using function definitions |
|
|
161 | (2) |
|
|
|
163 | (5) |
|
Understanding events and event listeners |
|
|
168 | (9) |
|
|
|
177 | (1) |
|
Controlling Sprite objects with properties |
|
|
178 | (4) |
|
|
|
180 | (2) |
|
|
|
182 | (16) |
|
|
|
183 | (1) |
|
Using increment and decrement operators |
|
|
184 | (1) |
|
|
|
185 | (4) |
|
Making it bigger and smaller |
|
|
189 | (3) |
|
|
|
192 | (3) |
|
|
|
195 | (3) |
|
|
|
198 | (1) |
|
|
|
198 | (4) |
|
|
|
202 | (7) |
|
|
|
206 | (3) |
|
Chapter 4 Decision Making |
|
|
209 | (76) |
|
|
|
210 | (12) |
|
|
|
210 | (2) |
|
The classes you have to import |
|
|
212 | (1) |
|
Creating TextFormat and TextField objects |
|
|
213 | (1) |
|
Setting the format of text |
|
|
214 | (2) |
|
Configuring and displaying the output text |
|
|
216 | (2) |
|
Configuring and displaying the input field |
|
|
218 | (4) |
|
Building a simple guessing game |
|
|
222 | (2) |
|
Understanding the program structure |
|
|
222 | (2) |
|
Learning more about variables |
|
|
224 | (7) |
|
Listening for key presses |
|
|
227 | (4) |
|
|
|
231 | (9) |
|
Displaying the game status |
|
|
238 | (2) |
|
Using postfix operators to change variable values by one |
|
|
240 | (13) |
|
|
|
241 | (4) |
|
Hey, why use the gameStatus variable, anyway? |
|
|
245 | (1) |
|
Using uint vs. int variables |
|
|
245 | (1) |
|
|
|
246 | (6) |
|
Modular programming with methods |
|
|
252 | (1) |
|
|
|
253 | (7) |
|
|
|
254 | (4) |
|
|
|
258 | (2) |
|
Making really nice buttons |
|
|
260 | (11) |
|
Understanding the concepts |
|
|
262 | (1) |
|
Loading the images and displaying the button |
|
|
263 | (2) |
|
Understanding the mouse events |
|
|
265 | (6) |
|
Adding the button to the number guessing game |
|
|
271 | (8) |
|
Disabling the button at the end of the game |
|
|
272 | (6) |
|
|
|
278 | (1) |
|
|
|
279 | (2) |
|
|
|
279 | (1) |
|
|
|
280 | (1) |
|
|
|
281 | (1) |
|
|
|
281 | (1) |
|
A quick guide to embedding fonts |
|
|
281 | (3) |
|
|
|
284 | (1) |
|
Chapter 5 Controlling A Player Character |
|
|
285 | (46) |
|
Controlling a player character with the keyboard |
|
|
285 | (19) |
|
Controlling with the keyboard---the wrong way! |
|
|
286 | (4) |
|
Controlling the keyboard---the right way! |
|
|
290 | (2) |
|
|
|
292 | (2) |
|
Using the new keyDownHandler |
|
|
294 | (1) |
|
|
|
294 | (2) |
|
Using the enterFrameHandler |
|
|
296 | (2) |
|
|
|
298 | (1) |
|
Blocking movement at the stage edges |
|
|
298 | (5) |
|
|
|
303 | (1) |
|
|
|
304 | (3) |
|
|
|
307 | (16) |
|
|
|
310 | (3) |
|
|
|
313 | (7) |
|
|
|
320 | (3) |
|
|
|
323 | (6) |
|
|
|
324 | (5) |
|
|
|
329 | (2) |
|
Chapter 6 Bumping Into Things |
|
|
331 | (58) |
|
Basic collision detection with hitTestObject |
|
|
331 | (4) |
|
|
|
335 | (2) |
|
Triggering a change of state |
|
|
337 | (20) |
|
|
|
341 | (2) |
|
Using scaleX to scale the meter based on a percentage |
|
|
343 | (1) |
|
|
|
344 | (7) |
|
Picking up and dropping objects |
|
|
351 | (6) |
|
The bad news about hitTestObject |
|
|
357 | (8) |
|
Detecting collisions with the bounding box |
|
|
358 | (1) |
|
|
|
359 | (1) |
|
|
|
360 | (4) |
|
Advanced collision detection strategies |
|
|
364 | (1) |
|
Working with vector based collision detection |
|
|
365 | (22) |
|
Preventing objects from overlapping |
|
|
365 | (8) |
|
Programming with the Collision class |
|
|
373 | (5) |
|
Another look at methods, arguments, and parameters |
|
|
378 | (3) |
|
Taking a look at the Collision.block method |
|
|
381 | (6) |
|
|
|
387 | (2) |
|
|
|
389 | (76) |
|
|
|
390 | (42) |
|
|
|
391 | (16) |
|
|
|
407 | (9) |
|
|
|
416 | (13) |
|
Designing the playing field |
|
|
429 | (1) |
|
Making the Game Over graphic |
|
|
430 | (2) |
|
|
|
432 | (24) |
|
Dealing with many objects |
|
|
432 | (2) |
|
|
|
434 | (5) |
|
Looking at the TimeBombPanic application class |
|
|
439 | (5) |
|
Adding objects to the game |
|
|
444 | (2) |
|
|
|
446 | (1) |
|
Collisions between the character and the boxes |
|
|
447 | (1) |
|
|
|
447 | (1) |
|
|
|
448 | (5) |
|
|
|
453 | (3) |
|
Creating a scrolling game environment |
|
|
456 | (7) |
|
Preparing your artwork for scrolling |
|
|
457 | (1) |
|
Adding objects to the game |
|
|
458 | (2) |
|
Scrolling and stage boundaries |
|
|
460 | (3) |
|
|
|
463 | (2) |
|
Chapter 8 Making Bigger Games |
|
|
465 | (80) |
|
Understanding the game structure |
|
|
466 | (5) |
|
Using private variables and methods |
|
|
469 | (2) |
|
|
|
471 | (48) |
|
Giving LevelOne access to the stage |
|
|
471 | (1) |
|
Making sure that LevelOne is actually on the stage |
|
|
472 | (3) |
|
|
|
475 | (7) |
|
Programming the game character |
|
|
482 | (7) |
|
|
|
489 | (6) |
|
Programming the star weapon |
|
|
495 | (8) |
|
Checking for the end of the level |
|
|
503 | (2) |
|
|
|
505 | (8) |
|
Using removeChild to completely get rid of objects |
|
|
513 | (1) |
|
Communicating between classes by dispatching events |
|
|
514 | (2) |
|
|
|
516 | (2) |
|
|
|
518 | (1) |
|
Firing stars in four directions in level two |
|
|
519 | (3) |
|
|
|
522 | (19) |
|
Moving objects in a scrolling game world |
|
|
522 | (15) |
|
|
|
537 | (3) |
|
Obstacles and pathfinding |
|
|
540 | (1) |
|
A little more about game structure |
|
|
541 | (2) |
|
|
|
543 | (2) |
|
Chapter 9 Physics, Loops, Arrays, and Sounds |
|
|
545 | (60) |
|
Natural motion using physics |
|
|
545 | (22) |
|
A game object class for playing with physics |
|
|
546 | (2) |
|
|
|
548 | (7) |
|
|
|
555 | (2) |
|
|
|
557 | (2) |
|
|
|
559 | (2) |
|
|
|
561 | (6) |
|
|
|
567 | (8) |
|
Integrating sound effects in a game |
|
|
569 | (1) |
|
Looping music and setting volume and pan levels |
|
|
570 | (5) |
|
Working with many objects |
|
|
575 | (29) |
|
|
|
580 | (9) |
|
|
|
589 | (7) |
|
Collisions with many objects |
|
|
596 | (7) |
|
|
|
603 | (1) |
|
|
|
604 | (1) |
|
Chapter 10 Advanced Object And Character Control |
|
|
605 | (38) |
|
Moving objects with the mouse |
|
|
606 | (7) |
|
Fixing an object to the mouse's position |
|
|
606 | (1) |
|
Moving an object with easing |
|
|
607 | (6) |
|
Case study: Firing projectiles in all directions |
|
|
613 | (10) |
|
|
|
617 | (1) |
|
Rotating the wand around the fairy |
|
|
618 | (2) |
|
Firing stars in 360 degrees |
|
|
620 | (3) |
|
Advanced player control systems |
|
|
623 | (1) |
|
|
|
624 | (8) |
|
Running away from the player |
|
|
627 | (1) |
|
Rotating and shooting toward the mouse |
|
|
628 | (3) |
|
Using a timer to fire bullets |
|
|
631 | (1) |
|
Case study: Killer Bee Pandemonium! |
|
|
632 | (11) |
|
Flash animation and publishing your game |
|
|
640 | (3) |
| Index |
|
643 | |