In response to the success of the first edition of __Foundation Game Design with Flash__, **Rex van der Spuy** has revised and updated all the code to meet current programming best practices, and the focus is now on accurate ActionScript 3.0, regardless of the IDE that you use. We’ve all sneaked the odd five minutes here or there playing the latest Flash game that someone sent around the office, but creating those games is trickier than it looks. The aim of __Foundation Game Design with ActionScript 3.0__ is to take you, even if you’ve minimal multimedia or programming experience, through a series of step-by-step examples and detailed case studies—to the point where you'll have the skills to independently design any conceivable 2D game using Flash and ActionScript. __Foundation Game Design with ActionScript 3.0__ is a non-technical one-stop shop for all the most important skills and techniques a beginning game designer needs to build games with Flash from scratch. Whether you're creating quick blasts of viral amusement, or more in-depth action or adventure titles, this is the book for you. * Focused and friendly introduction to designing games with Flash and ActionScript * Detailed case studies of Flash games * Essential techniques for building games, with each chapter gently building on the skills of preceding chapters * Modern best practices and new content on ActionScript 3.0 * Also covers asset creation in Photoshop and Illustrator ## What you’ll learn ## Who this book is for This book is for a non-technical, creative person who wants to learn the art of video game design, but has no idea where to start or where to look for help. It is a lucid, friendly and step-by-step guide though all the technical and creative issues involved in game design with Flash and ActionScript. The book treats programming as a creative artistic tool, and will help anyone who may be afraid of programming come to love the subject as much as the author does. The techniques in the book are comprehensive enough to form the basis of career as a game designer, and form a solid foundation for continued study of programming and ActionScript. This book is the missing link that will guide and inspire any curious and creative person turn a good game idea into a reality. ## Table of Contents Title Page......Page 2 Copyright Page......Page 3 Table of Contents......Page 5 ABOUT THE AUTHOR......Page 14 ABOUT THE TECHNICAL REVIEWER......Page 15 ABOUT THE COVER IMAGE DESIGNER......Page 16 ACKNOWLEDGMENTS......Page 17 About the second edition......Page 18 Layout conventions......Page 19 Chapter 1 Programming Foundations:How To Make A Video Game......Page 20 2. Graphic design software......Page 21 3. Computer programming software......Page 22 Things you need to know......Page 24 It’s all about programming......Page 25 Programming? But I’m terrible at math!......Page 26 What kind of games can I make?......Page 27 Laying the foundation......Page 28 Setting up the work environment in Flash Builder......Page 29 Create a new, blank ActionScript project......Page 31 Telling Flash Builder to run your programs in the Flash Player......Page 36 ActionScript files and the .as file extension......Page 39 I’ll take that to go!......Page 41 A little magic with sprites......Page 42 Don’t skip class!......Page 44 Using the constructor method......Page 46 Aligning code......Page 48 What’s your directive?......Page 51 Adding comments to your code......Page 53 Running your program and compiling the SWF file......Page 55 What happened when you compiled the program......Page 57 It didn’t work?......Page 59 Some common error messages......Page 62 Collapsing code......Page 64 Breakpoints......Page 65 Perspectives......Page 67 Creating a clean compile of your program......Page 70 A little more about AS3.0 and the Flash Player......Page 71 Naming conventions......Page 73 Summary......Page 74 Chapter 2 Making Game Graphics......Page 75 Create a new file in Photoshop......Page 78 What are pixels?......Page 80 Draw the sky......Page 82 Add a gradient......Page 89 Understanding layers......Page 94 Anchor points and paths......Page 97 Make curves with direction handles......Page 102 Resizing paths......Page 105 Fill the path with color......Page 106 Duplicating, modifying, and arranging layers......Page 109 Bevel and emboss......Page 114 Making boxes with the rectangular selection tool......Page 118 Saving the image......Page 123 Create a new file......Page 124 Draw your character......Page 125 Making circles......Page 126 Linking and grouping layers......Page 127 Making buttons......Page 128 Draw the button......Page 129 Using the type tool......Page 132 Making more buttons......Page 133 Save your work and make the PNG files......Page 135 Checking your work......Page 136 More about Photoshop......Page 137 Summary......Page 138 Programming Objects......Page 139 But I’m a bit scared of programming!......Page 140 Loading and displaying images......Page 141 Setting up a new AS3.0 project......Page 142 Understanding the setup file......Page 144 Set up the Flash Player with a metadata tag......Page 145 Loading and displaying the background.png image......Page 148 Create the Sprite and Loader objects......Page 150 Variables......Page 152 Variable types......Page 153 Creating empty boxes......Page 154 Creating instances and objects......Page 155 Displaying the image on the stage......Page 158 Understanding the code structure......Page 165 Positioning Sprites on the stage......Page 166 Understanding x and y positions of objects......Page 168 Displaying and positioning the buttons......Page 173 Programming buttons......Page 176 Methods......Page 177 Using method calls......Page 178 Using function definitions......Page 179 Using a basic method......Page 181 Creating method arguments and parameters......Page 183 Using multiple arguments and parameters......Page 185 Understanding events and event listeners......Page 186 Adding an event listener......Page 188 Using the event handler......Page 189 Understanding other events......Page 192 Making your buttons work......Page 195 Controlling Sprite objects with properties......Page 196 Going up and down......Page 198 Moving incrementally......Page 200 Tracing the output......Page 201 Using increment and decrement operators......Page 202 Limiting movement......Page 203 Making it bigger and smaller......Page 207 Vanishing!......Page 210 Spinning around......Page 213 Centering Sprites......Page 216 Code summary......Page 220 Summary......Page 224 Chapter 4 Decision Making......Page 226 Setting up the project......Page 227 The classes you have to import......Page 229 Creating TextFormat and TextField objects......Page 230 Setting the format of text......Page 231 Configuring and displaying the output text......Page 233 Configuring and displaying the input field......Page 235 Understanding the program structure......Page 239 Learning more about variables......Page 241 Listening for key presses......Page 244 Making decisions......Page 248 Displaying the game status......Page 255 Using postfix operators to change variable values byone......Page 257 Tying up strings......Page 258 Using uint vs. int variables......Page 262 Winning and losing......Page 263 Modular programming with methods......Page 269 Polishing up......Page 270 Tackling random numbers......Page 271 Disabling the Enter key......Page 275 Making really nice buttons......Page 277 Understanding the concepts......Page 279 Loading the images and displaying the button......Page 280 Understanding the mouse events......Page 282 Adding the button to the number guessing game......Page 288 Disabling the button at the end of the game......Page 289 Managing complex code......Page 295 Make a Play again button......Page 296 Tracking guesses......Page 297 A quick guide to embedding fonts......Page 298 Summary......Page 301 Controlling a player character with the keyboard......Page 302 Controlling with the keyboard—the wrong way!......Page 303 Controlling the keyboard—the right way!......Page 307 Moving with velocity......Page 309 Using the keyUpHandler......Page 311 Using the enterFrameHandler......Page 313 Blocking movement at the stage edges......Page 315 Screen wrapping......Page 320 Embedding images......Page 321 Scrolling......Page 324 Embedding the character and background images......Page 327 Positioning the background......Page 329 Scrolling the background......Page 330 Better scrolling......Page 331 Even better scrolling......Page 337 Taking it further......Page 340 Parallax scrolling......Page 341 Summary......Page 346 Basic collision detection with hitTestObject......Page 347 Using hitTestObject......Page 351 Triggering a change of state......Page 353 Reducing a health meter......Page 357 Using scaleX to scale the meter based on a percentage......Page 359 Updating a score......Page 360 Checking for the end of the game......Page 365 Picking up and dropping objects......Page 367 The bad news about hitTestObject......Page 373 Detecting collisions with the bounding box......Page 374 Learning to live with it......Page 375 Creating subobjects......Page 376 Advanced collision detection strategies......Page 380 Preventing objects from overlapping......Page 381 Programming with the Collision class......Page 389 Another look at methods, arguments, and parameters......Page 394 Using the block method’s arguments with the Collision class......Page 396 Taking a look at the Collision.block method......Page 397 Summary......Page 403 Chapter 7 Making Games......Page 404 Making the game graphics......Page 405 Getting accustomed to Adobe Illustrator......Page 406 Setting up the workspace......Page 408 Choosing the colors......Page 409 Drawing the outside shape......Page 411 Drawing the inside shape......Page 413 Making the bomb......Page 422 Drawing the antenna......Page 431 Make the second antenna......Page 435 Making the character’s eyes......Page 436 Adding the smile......Page 439 Bring in the stylist!......Page 440 Drawing the shoes......Page 441 Add some extra cuteness......Page 443 Designing the playing field......Page 444 Making the Game Over graphic......Page 445 Dealing with many objects......Page 447 What is a class, really?......Page 449 Looking at the TimeBombPanic application class......Page 454 Adding objects to the game......Page 459 Stage boundaries......Page 461 Defusing the bombs......Page 462 Understanding timers......Page 463 Using a timer in Time Bomb Panic......Page 467 Ending the game......Page 468 Creating a scrolling game environment......Page 471 Preparing your artwork for scrolling......Page 472 Adding objects to the game......Page 473 Scrolling and stage boundaries......Page 475 Summary......Page 478 Chapter 8 Making Bigger Games......Page 480 Understanding the game structure......Page 481 Using private variables and methods......Page 484 Giving LevelOne access to the stage......Page 486 Making sure that LevelOne is actually on the stage......Page 487 The LevelOne class......Page 490 Understanding properties and methods......Page 497 Moving the character......Page 500 Checking for stage boundaries......Page 501 Checking for collisions between the character and the monster......Page 502 The order of the code in the enterFrameHandler......Page 503 Programming the monsters......Page 504 Moving the monsters......Page 508 Programming the star weapon......Page 511 Launching the star......Page 513 Checking the star’s collisions......Page 514 Vanquishing the monsters and creating an explosion......Page 516 Checking for the end of the level......Page 519 If the monsters win.........Page 521 If the character wins.........Page 523 Using removeChild to completely get rid of objects......Page 529 Communicating between classes by dispatching events......Page 530 Event bubbling......Page 532 Finishing off level one......Page 534 Firing stars in four directions in level two......Page 535 Moving objects in a scrolling game world......Page 538 The scrolling game code......Page 539 How the scrolling code works......Page 550 Scrolling the explosions......Page 552 Intelligent monsters......Page 553 Obstacles and pathfinding......Page 556 A little more about game structure......Page 557 Summary......Page 559 Natural motion using physics......Page 560 A game object class for playing with physics......Page 561 Acceleration......Page 563 The Acceleration class......Page 564 Friction......Page 570 Bouncing......Page 572 Gravity......Page 574 Jumping......Page 576 Adding sounds to games......Page 582 Integrating sound effects in a game......Page 584 Looping sounds......Page 585 Volume and pan setting......Page 587 Working with many objects......Page 590 Using for loops......Page 591 Using arrays......Page 595 Pushing elements into an array......Page 597 Looping arrays......Page 598 Searching arrays......Page 600 Arrays inside arrays......Page 601 Making many boxes......Page 604 Collisions with many objects......Page 611 Case studies......Page 618 Summary......Page 619 Chapter 10 Advanced Object And Character Control......Page 620 Fixing an object to the mouse’s position......Page 621 Moving an object with easing......Page 622 Easing......Page 625 Click to move an object......Page 626 Case study: Firing projectiles in all directions......Page 628 Making the game objects......Page 632 Rotating the wand around the fairy......Page 633 Firing stars in 360 degrees......Page 635 Advanced player control systems......Page 638 Following another object......Page 639 Rotating and shooting toward the mouse......Page 643 Shooting at random intervals......Page 647 Case study: Killer Bee Pandemonium!......Page 648 Flash animation and publishing your game......Page 655 Summary......Page 656 Index......Page 658
In response to the success of the first edition of Foundation Game Design with Flash, Rex van der Spuy has revised and updated all the code to meet current programming best practices, and the focus is now on accurate ActionScript 3.0, regardless of the IDE that you use.
Weâve all sneaked the odd five minutes here or there playing the latest Flash game that someone sent around the office, but creating those games is trickier than it looks. The aim of Foundation Game Design with ActionScript 3.0 is to take you, even if youâve minimal multimedia or programming experience, through a series of step-by-step examples and detailed case studies-to the point where you'll have the skills to independently design any conceivable 2D game using Flash and ActionScript.
Foundation Game Design with ActionScript 3.0 is a non-technical one-stop shop for all the most important skills and techniques a beginning game designer needs to build games with Flash from scratch. Whether you're creating quick blasts of viral amusement, or more in-depth action or adventure titles, this is the bookfor you.
- Focused and friendly introduction to designing games with Flash and ActionScript
- Detailed case studies of Flash games
- Essential techniques for building games, with each chapter gently building on the skills of preceding chapters
- Modern best practices and new content on ActionScript 3.0
- Also covers asset creation in Photoshop and Illustrator
What youâll learn
- How to build interactive movies and objects with Flash
- Athorough grounding in ActionScript 3.0 and good programming practices, with minimal prior programming experience required
- How to build interactive storybooks, space-shooter, adventure and drag-and-drop games
- To master collision detection, enemy AI systems, player control, managing game data, basic physics and trigonometry
- To make use of design patterns andobject-oriented programmingtechniques to build robust games
- Strategies for making games fun to play and easy to build
Who this book is forThis book is for a non-technical, creative person who wants to learn the art of video game design, but has no idea where to start or where to look for help. It is a lucid, friendly and step-by-step guide though all the technical and creative issues involved in game design with Flash and ActionScript. The book treatsprogramming as a creative artistic tool, and will help anyone who may be afraid of programming cometo love the subject as much as the author does. The techniques in the book are comprehensive enough to form the basis of career as a game designer, and form a solid foundation for continued study of programming and ActionScript. This book is the missing link that will guide and inspire any curious and creative person turn a good game idea into a reality.
Table of Contents
- Programming Foundations: How to Make a Video Game
- Making Objects
- Programming Objects
- Controlling Movie Clip Objects
- Decision Making
- Controlling a Player Character
- Bumping into Things
- Object-Oriented Game Design
- Platform Game: Physics and Data Management
- Advanced Object and Character Control
- Using Flash Professional
Annotation In response to the success of the first edition ofFoundation Game Design with Flash, Rex van der Spuyhas revised and updated all the code to meet current programming best practices, and the focus is now on accurate ActionScript 3.0, regardless of the IDE that you use. Weve all sneaked the odd five minutes here or there playing the latest Flash game that someone sent around the office, but creating those games is trickier than it looks. The aim ofFoundation Game Design with ActionScript 3.0is to take you, even if youve minimal multimedia or programming experience, through a series of step-by-step examples and detailed case studiesto the point where you''ll have the skills to independently design any conceivable 2D game using Flash and ActionScript. Foundation Game Design with ActionScript 3.0is a non-technical one-stop shop for all the most important skills and techniques a beginning game designer needs to build games with Flash from scratch. Whether you''re creating quick blasts of viral amusement, or more in-depth action or adventure titles, this is the bookfor you. Focused and friendly introduction to designing games with Flash and ActionScriptDetailed case studies of Flash gamesEssential techniques for building games, with each chapter gently building on the skills of preceding chaptersModern best practices and new content on ActionScript 3.0Also covers asset creation in Photoshop and IllustratorWhat youll learnHow to build interactive movies and objects with FlashAthorough grounding in ActionScript 3.0 and good programming practices, with minimal prior programming experience requiredHow to build interactive storybooks, space-shooter, adventure and drag-and-drop gamesTo master collision detection, enemy AI systems, player control, managing game data, basic physics and trigonometryTo make use of design patterns andobject-oriented programmingtechniques to build robust gamesStrategies for making games fun to play and easy to buildWho this book is forThis book is for a non-technical, creative person who wants to learn the art of video game design, but has no idea where to start or where to look for help. It is a lucid, friendly and step-by-step guide though all the technical and creative issues involved in game design with Flash and ActionScript. The book treatsprogramming as a creative artistic tool, and will help anyone who may be afraid of programming cometo love the subject as much as the author does. The techniques in the book are comprehensive enough to form the basis of career as a game designer, and form a solid foundation for continued study of programming and ActionScript. This book is the missing link that will guide and inspire any curious and creative person turn a good game idea into a reality. Table of ContentsProgramming Foundations: How to Make a Video GameMaking ObjectsProgramming ObjectsControlling Movie Clip ObjectsDecision MakingControlling a Player CharacterBumping into ThingsObject-Oriented Game Design & Aci