PDF Download: ActionScript 3.0 Game Programming University by Gary Rosenzweig

ActionScript 3.0 Game Programming University E-Book
ActionScript 3.0 Game Programming University E-Book

Trying to learn game programming in Adobe Flash? Want to learn game programming using AS3? Try this e-book that I’m going to share with you. It covers Adobe Flash CS3 Professional, so it’s perfect if you use Flash CS3.

Link:

Buy and download it from Amazon

NOTE: No more free download link so we don’t violate copyright.

I’m letting you see the contents. Please bear with the messy table of contents that follows “Contents at a Glace”. It comes straight from the e-book and looks like that when pasted here in my text editor. ^_^

More PDF’s about Adobe Flash and ActionScript 3.0 – coming soon! 😉

Contents at a Glance

Introduction
1. Using Flash and ActionScript 3.0
2. ActionScript Game Elements
3. Basic Game Framework: A Matching Game
4. Brain Games: Memory and Deduction
5. Game Animation: Shooting and Bouncing Games
6. Picture Puzzles: Sliding and Jigsaw
7. Direction and Movement: Space Rocks
8. Casual Games: Match Three
9. Word Games: Hangman and Word Search
10. Questions and Answers: Trivia and Quiz Games
11. Action Games: Platform Games
12. Game Worlds: Driving and Exploration Game
Index

Contents


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1
Flash and Game Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Who Is This Book For? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
What Do You Need To Use This Book? . . . . . . . . . . . . . . . . . . . . . .3
Prerequisite Knowledge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
Software Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Source Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Using the Example Games in Your Projects . . . . . . . . . . . . . . . . . . . .4
What You’ll Find in This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
The FlashGameU.com Website . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
1. Using Flash and ActionScript 3.0 . . . . . . . . . . . . . . . . . . . .7
What Is ActionScript 3.0? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8
Creating a Simple ActionScript Program . . . . . . . . . . . . . . . . . . . . . .9
A Simple Use of trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
Creating Screen Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Our First ActionScript 3.0 Class . . . . . . . . . . . . . . . . . . . . . . . . .13
Working with Flash CS3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Display Objects and Display Lists . . . . . . . . . . . . . . . . . . . . . . . .16
The Stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
The Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
The Timeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
Writing and Editing ActionScript . . . . . . . . . . . . . . . . . . . . . . . . . . .19
ActionScript Game Programming Strategies . . . . . . . . . . . . . . . . . .22
Single Class Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Smallest Step Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Good Programming Practices . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Basic ActionScript Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26
Creating and Using Variables . . . . . . . . . . . . . . . . . . . . . . . . . . .26
Condition Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Testing and Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Types of Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Methods of Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .30
Using the Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
Publishing Your Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
ActionScript Game Programming Checklist . . . . . . . . . . . . . . . . . . .36
Publishing and Document Settings . . . . . . . . . . . . . . . . . . . . . . .36
Class, Function, and Variable Names . . . . . . . . . . . . . . . . . . . . .37
Runtime Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38
Testing Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .39
2. ActionScript Game Elements . . . . . . . . . . . . . . . . . . . . . . .41
Creating Visual Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Using Movie Clips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Making Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
Drawing Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Drawing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
Creating Linked Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Creating Sprite Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Setting Sprite Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Accepting Player Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Mouse Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Keyboard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .56
Text Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .58
Creating Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Sprite Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
Using Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Time-Based Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .62
Physics-Based Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .63
Programming User Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Moving Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Dragging Sprites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Collision Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Accessing External Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
External Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Loading Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Saving Local Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Miscellaneous Game Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Custom Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Playing Sounds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Loading Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .75
Random Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .76
Shuffling an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .77
Displaying a Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78
System Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
Game Theft and Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
3. Basic Game Framework: A Matching Game . . . . . . . . . . . .83
Placing Interactive Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Methods for Creating Game Pieces . . . . . . . . . . . . . . . . . . . . . . .85
Setting Up the Flash Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
Creating the Basic ActionScript Class . . . . . . . . . . . . . . . . . . . . .87
Using Constants for Better Coding . . . . . . . . . . . . . . . . . . . . . . .90
Shuffling and Assigning Cards . . . . . . . . . . . . . . . . . . . . . . . . . .92
Game Play . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
Adding Keyboard Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . .95
Setting Up Game Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Checking for Game Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Encapsulating the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
Creating the Game Movie Clip . . . . . . . . . . . . . . . . . . . . . . . . .103
Adding an Introduction Screen . . . . . . . . . . . . . . . . . . . . . . . . .104
Adding a Play Again Button . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Adding Scoring and a Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
Adding Scoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .106
Adding a Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .109
Displaying Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Displaying Score and Time after the Game Is Over . . . . . . . . . .112
Adding Game Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Animated Card Flips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .113
Limited Card-Viewing Time . . . . . . . . . . . . . . . . . . . . . . . . . . .116
Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
4. Brain Games: Memory and Deduction . . . . . . . . . . . . . . .121
Arrays and Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Arrays of Data Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Memory Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Preparing the Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
Programming Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
Setting the Text, Lights, and Sounds . . . . . . . . . . . . . . . . . . . . .130
Playing the Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .133
Switching Lights On and Off . . . . . . . . . . . . . . . . . . . . . . . . . .134
Accepting and Checking Player Input . . . . . . . . . . . . . . . . . . . .135
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
Deduction Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Setting Up the Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Defining the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141
Starting a New Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143
Checking Player Guesses . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145
Evaluating Player Moves . . . . . . . . . . . . . . . . . . . . . . . . . . . . .146
Ending the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
Clearing Game Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .152
5. Game Animation: Shooting and Bouncing Games . . . . . . .155
Game Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
Time-Based Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .156
Coding Time-Based Animation . . . . . . . . . . . . . . . . . . . . . . . . .158
Air Raid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
Movie Setup and Approach . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Flying Airplanes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
Moving Gun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .166
Skyward Bullets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169
The Game Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .171
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
Paddle Ball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Setting Up the Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .179
Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .181
Starting the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .183
Starting a New Ball . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .185
Game Animation and Collision Detection . . . . . . . . . . . . . . . . .186
Game Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .193
6. Picture Puzzles: Sliding and Jigsaw . . . . . . . . . . . . . . . . .195
Manipulating Bitmap Images . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
Loading a Bitmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .196
Breaking a Bitmap into Pieces . . . . . . . . . . . . . . . . . . . . . . . . .198
Sliding Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .200
Setting Up the Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
Setting Up the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
Loading the Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .204
Cutting the Bitmap into Pieces . . . . . . . . . . . . . . . . . . . . . . . . .204
Shuffling the Pieces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Reacting to Player Clicks . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Animating the Slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .211
Game Over and Cleanup . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .213
Jigsaw Puzzle Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
Setting Up the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .214
Loading and Cutting the Image . . . . . . . . . . . . . . . . . . . . . . . .216
Dragging Puzzle Pieces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219
Game Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .224
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225
7. Direction and Movement: Space Rocks . . . . . . . . . . . . . .227
Using Math to Rotate and Move Objects . . . . . . . . . . . . . . . . . . . .228
The Sin and Cos Functions . . . . . . . . . . . . . . . . . . . . . . . . . . .228
Using Cos and Sin to Drive a Car . . . . . . . . . . . . . . . . . . . . . . .230
Calculating an Angle from a Location . . . . . . . . . . . . . . . . . . . .233
Air Raid II . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
Altering the Gun . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
Changing the Bullets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
Changes to AirRaid2.as . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .241
Space Rocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .242
Game Elements and Design . . . . . . . . . . . . . . . . . . . . . . . . . . .242
Setting Up the Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244
Setting Up the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .246
Starting the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .248
Score and Status Display Objects . . . . . . . . . . . . . . . . . . . . . . .249
Ship Movement and Player Input . . . . . . . . . . . . . . . . . . . . . . .252
Shields Up! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .256
Rocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Missiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261
Game Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .265
8. Casual Games: Match Three . . . . . . . . . . . . . . . . . . . . . .267
Reusable Class: Point Bursts . . . . . . . . . . . . . . . . . . . . . . . . . . . . .268
Developing the Point Burst Class . . . . . . . . . . . . . . . . . . . . . . .269
Using Point Bursts in a Movie . . . . . . . . . . . . . . . . . . . . . . . . .273
Match Three . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
Playing Match Three . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
Game Functionality Overview . . . . . . . . . . . . . . . . . . . . . . . . . .277
The Movie and MatchThree Class . . . . . . . . . . . . . . . . . . . . . . .278
Setting Up the Grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279
Player Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .282
Animating Piece Movement . . . . . . . . . . . . . . . . . . . . . . . . . . .285
Finding Matches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .287
Finding Possible Moves . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292
Score Keeping and Game Over . . . . . . . . . . . . . . . . . . . . . . . .295
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .296
9. Word Games: Hangman and Word Search . . . . . . . . . . . .297
Strings and Text Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .298
ActionScript 3.0 String Handling . . . . . . . . . . . . . . . . . . . . . . .298
Applying Text Formatting to Text Fields . . . . . . . . . . . . . . . . . .303
Hangman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
Setting Up the Hangman . . . . . . . . . . . . . . . . . . . . . . . . . . . . .309
The Hangman Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .310
Word Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Development Strategy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .313
Defining the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315
Creating the Word Search Grid . . . . . . . . . . . . . . . . . . . . . . . .316
User Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320
Dealing with Found Words . . . . . . . . . . . . . . . . . . . . . . . . . . . .323
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .326
10. Questions and Answers: Trivia and Quiz Games . . . . . . . .327
Storing and Retrieving Game Data . . . . . . . . . . . . . . . . . . . . . . . .328
Understanding XML Data . . . . . . . . . . . . . . . . . . . . . . . . . . . .328
Importing External XML Files . . . . . . . . . . . . . . . . . . . . . . . . . .330
Trapping Load Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
Trivia Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .332
Designing a Simple Quiz Game . . . . . . . . . . . . . . . . . . . . . . . .333
Setting Up the Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .333
Setting Up the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .334
Loading the Quiz Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .337
Message Text and Game Button . . . . . . . . . . . . . . . . . . . . . . . .337
Moving the Game Forward . . . . . . . . . . . . . . . . . . . . . . . . . . .339
Displaying the Questions and Answers . . . . . . . . . . . . . . . . . . .340
Judging the Answers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .342
Ending the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .343
Deluxe Trivia Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .344
Adding a Time Limit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .344
Adding Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .347
Adding a Factoid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349
Adding Complex Scoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . .350
Randomizing the Questions . . . . . . . . . . . . . . . . . . . . . . . . . . .352
Picture Quiz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .353
Better Answer Arrangement . . . . . . . . . . . . . . . . . . . . . . . . . . .353
Recognizing Two Types of Answers . . . . . . . . . . . . . . . . . . . . .355
Creating Loader Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . .355
Determining the Right Answer . . . . . . . . . . . . . . . . . . . . . . . . .356
Expanding the Click Area . . . . . . . . . . . . . . . . . . . . . . . . . . . .357
Images for Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .358
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .359
11. Action Games: Platform Games . . . . . . . . . . . . . . . . . . . .361
Designing the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .362
Designing the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .368
Planning Which Functions Are Needed . . . . . . . . . . . . . . . . . . .369
Building the Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370
Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .370
Starting the Game and Level . . . . . . . . . . . . . . . . . . . . . . . . . .372
Keyboard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .376
The Main Game Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .377
Character Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .378
Scrolling the Game Level . . . . . . . . . . . . . . . . . . . . . . . . . . . . .384
Checking for Collisions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Enemy and Player Death . . . . . . . . . . . . . . . . . . . . . . . . . . . . .385
Collecting Points and Objects . . . . . . . . . . . . . . . . . . . . . . . . . .387
Showing Player Status . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .389
Ending the Levels and the Game . . . . . . . . . . . . . . . . . . . . . . .389
The Game Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .390
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .391
12. Game Worlds: Driving and Exploration Game . . . . . . . . . .393
Creating a Top-Down Driving Game . . . . . . . . . . . . . . . . . . . . . . .394
Creating a Top-Down World . . . . . . . . . . . . . . . . . . . . . . . . . .394
Game Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .397
The Class Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .400
The Constructor Function . . . . . . . . . . . . . . . . . . . . . . . . . . . .402
Finding the Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404
Placing the Trash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .404
Keyboard Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .406
The Game Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .407
Moving the Car . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .408
Checking for Trash and Trashcan Collisions . . . . . . . . . . . . . . .411
The Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .413
The Score Indicators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .413
Game End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .414
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415
Building a Flash Racing Game . . . . . . . . . . . . . . . . . . . . . . . . . . .415
Racing Game Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .415
Making the Track . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416
Sound Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418
Constants and Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .418
Starting the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .419
The Main Game Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .420
Car Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .422
Checking Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .424
The Countdown and the Clock . . . . . . . . . . . . . . . . . . . . . . . . .425
Game Over . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
Modifying the Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .427
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .429

Related Posts:

Posts that may be related to "PDF Download: ActionScript 3.0 Game Programming University by Gary Rosenzweig":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

One comment on “PDF Download: ActionScript 3.0 Game Programming University by Gary Rosenzweig

 

Leave a Reply

Your email address will not be published. Required fields are marked *