Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 377 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
377
Dung lượng
10,07 MB
Nội dung
So y ou wanna be a hotshot g ame desi g ner? Well, if y ou have a basic g ras p of MacromediaFlash MX, y ou can. Unafraid to tackle some of the more complicated aspects of game creation (including physics and trigonometry!), this comprehensive reference covers it all. MacromediaFlashGameDesign Demystified starts out withthe basics: planning, adapting ActionScript techniques, using introductory Flashgame techniques, and more. Then it gets down tothe real business of building simple games. You'll tackle simple-lo g ic and q uiz games before moving on to multiplayer and complex-logic games (chess, for example) learning about importing 3-D graphics, adding sound effects, and licensing your games in the process. The book's companion CD includes the source files for a number of games as well as the tutorials and lessons that go alon g withthe book and XML server software to facilitate multi p la y er g ames. If y ou're tired of the g • Table of Contents • Examples Macromedia® Flash™MXGameDesignDemystified: The OfficialGuideto Creating GameswithFlash By Jobe Makar Publisher : Peachpit Press Pub Date : September 09, 2002 ISBN : 0-201-77021-0 Pages : 648 M • Table of Contents • Examples Macromedia® Flash™MXGameDesignDemystified: The OfficialGuideto Creatin g GameswithFlash By Jobe Makar Publisher : Peachpit Press Pub Date : September 09, 2002 ISBN : 0-201-77021-0 Pages : 648 Copyright Acknowledgments About the Contributors Derek Baird Eric Dolecki Robert Firebaugh Michael Grundvig Introduction Why Flash? How to use this book Part 1. Getting Started withFlashGameDesign Chapter 1. First Steps Inspirational Kick-Start Terminology Game Genres Flash Limitations Points to Remember Chapter 2. The Plan: From Idea toDesignTheDesign Process Points to Remember Part 2. Examining the Nuts and Bolts Chapter 3. Trigonometry 101 Why Learn Trigonometry? TheFlash Coordinate System Anatomy of a Triangle The Pythagorean Theorem The Heart of Trig Vectors Points to Remember Chapter 4. Basic Physics Introduction to Physics Speed, Velocity, and Acceleration Newton's Three Laws of Motion Gravity Friction Points to Remember Chapter 5. Collision Detection What Is a Collision? Detection Using hitTest() Detection Using Math Collision Detection with Advanced Shapes Points to Remember Chapter 6. Collision Reactions Bouncing Off the Walls Conservation of Momentum and Energy Applying the Conservation Laws Points to Remember Chapter 7. Tile-Based Worlds Introduction to Tiles Top-Down Tile Creation and Management Adding a Character tothe World Externalizing the World Data Points to Remember Chapter 8. The Isometric Worldview Introduction to Isometrics A Technical Look at Isometrics Z-sorting Deconstruction of a Simple World Points to Remember Chapter 9. Artificial Intelligence Types of AI Homegrown AI The Perfect Maze Pathfinding Algorithms Points to Remember Chapter 10. Using a High Score List Administration of the High Score Lists The List in Action Points to Remember Chapter 11. Graphics in Games Taking a Graphic Approach Stages of Graphic Development Trouble-Free Techniques Points to Remember Chapter 12. The Sound of Games Why Sound Is Important Managing Sound Effects Creating Sound Effects Creating Music Loops Points to Remember Chapter 13. Dissecting a Chat Introduction tothe Chat Hands-On Tour of the Chat Points to Remember Part 3. TheGames Chapter 14. Word Search Game Overview Game Logic Points to Remember Chapter 15. Ice World: A Platform GameGame Overview The XML and the Level Editor Game Structure and Resource Files Game Code Possible Game Enhancements Points to Remember Chapter 16. Pinball Game Overview Game Code Possible Game Enhancements Points to Remember Chapter 17. Tic-Tac-Toe: Your First Multiplayer GameGame Overview The Multiplayer Aspect Game Code Points to Remember Chapter 18. 9-Ball Game Overview Multiplayer Aspects of theGameGame Code Possible Game Enhancements Points to Remember Chapter 19. Don't Fall! Game Overview Multiplayer Actions Game Actions Possible Game Enhancements Points to Remember Appendixes Appendix A. Protecting Your Games Theft and Antitheft So You Found Your Game on Another Web Site? Appendix B. Multiuser Servers What Is a Socket Server? Introducing ElectroServer Appendix C. The ElectroServerAS Object Click-and-Drag Actions Methods and Properties of ElectroServerAS Appendix D. XML Basics in Flash Learning XML Basics Using the XML Object Introducing Socket Servers Using the XML Socket Object Appendix E. Developer Resources General Game Resources Flash Resource Sites AI Isometric Math Physics Audio Appendix F. Other Games 3D_race.fla asteroids cards.fla foxandgeese.fla fruit_smash.fla invaders iso_maze.fla j i g saw.fla matching.fla pacman projectile_motion.fla raiseTheBlocks.fla robust_tracing shared_object_highscore_list ship.fla shuffle_deck.fla tic_tac_toe_ai.fla tile_boat Acknowledgments Lookin g at the final draft of this book I can't hel p but be sur p rised and p roud of its q ualit y . What man y p eo p le don't realize is that a project of this magnitude can't be brought about by just one person. Actually, this book is the combined effort of man y p eo p le, some of whom have done as much work as the author himself, and all of whom have brought their own brand of expertise tothe task. So I have many people to thank: Wendy Katz, for your amazing work. Thanks to your great edits, suggestions, and comments, my chapters look like an intelligent person wrote them! Eric Dolecki, for doing a magnificent job withthe figures and screenshots for this book, turning my scribbled instructions into clear illustrations, thanks a lot! Robert Firebaugh, for the phenomenal graphics you created to go withthegames in this book, and for the very informative chapter on the graphical approach in games. Mike Grundvig, for developing ElectroServer, miscellaneous server-side scripts, and for writing the appendix on multiuser gaming. Not to mention your great suggestions and guidance for good code structure. Derek Baird, for your contribution of music and sound effects for thegames in this book, and content for the Sound chapter. Branden Hall, for your wddx_mx.as file, which is a great asset to multiplayer gaming. I am grateful for the support and contributions of the entire Peachpit Press crew and production team, es p eciall y Wend y Shar p , Mar j orie Baer, Lisa Brazieal, David Van Ness, Elissa Rabellino, and Rebecca Plunkett. I also want to acknowledge Kurt Wolken of Wolken Communica for the cover design and Bentley Wolfe of Macromedia for his sharp-eyed technical verifications. Support and encouragement of friends and family have enabled me to gain the experience and determination needed to write this book. A big all-around thank you to mom, dad, Grambo, my grandparents, and Janie. Of course I also need to acknowled g e the smaller creatures ( even thou g h the y can't read ) , Free, Chance, Ha y es, and Ross—you furry guys provide a frequent and welcome distraction. And finally, to Kelly, my amazing wife and constant source of inspiration: thank you for being my toughest critic and yet my biggest supporter. M About the Contributors I've alread y said that a book is not the work of a j ust one p erson. In the case of this book, four others hel p ed actually get the material on the pages, and I want to recognize them specifically here. I l @ve RuBoard I l @ve RuBoard Derek Baird www.wireheadmedia.com Derek Baird is a composer, sound designer, and multimedia developer with a degree in music composition North Carolina School of the Arts. He's pursued additional studies in film music and music technology at LaGrange College. He is also a professional guitarist who has performed with Grammy-winning acts and on internationally released albums. Derek currently runs Wireheadmedia.com, an Internet multimedia that specializes in sound design and high quality music composition. Derek contributed the " Creating Sound Effects" and "Creating Music Loops" sections of Chapter 12, "The of Games." I l @ve RuBoard I l @ve RuBoard Eric Dolecki www.ericd.net Eric E. Dolecki is currently a Director of Interactive Technological Innovation, working in Boston, MA. He maintains his own site ( www.ericd.net) and contributes regularly within theFlash community. Eric recently Macromedia Site of the Day for his Flashforward 2002 NYC Event Guide application (which runs via Flash on Pocket PCs, utilizes local XML data storage, and even allows for wireless polling). Eric is co-author of books, including MacromediaFlash Super Samurai, FlashMX Audio Magic, and FlashMX Dynamic A winner of numerous interactive awards, and with his work appearing in numerous publications, Eric seeks help drive Flash in new directions. Eric created all of the technical illustrations for this book. I l @ve RuBoard I l @ve RuBoard Robert Firebaugh www.electrotank.com www.vectorkid.com Robert Firebaugh, with over ten years of illustration and gamedesign experience, is creative director and founder of Electrotank, Inc. Thegames that he has designed have won numerous international awards and have been acknowled g ed by many publications. In addition to his work with Electrotank, he runs a Web site dedicated to photo-realistic vector artwork created in Flash. Robert wrote Chapter 11, "Graphics in Games." I l @ve RuBoard I l @ve RuBoard Michael Grundvig www.electrotank.com Michael Grundvig is a co-founder of Electrotank Inc. He has co-authored and contributed to several books Flash, presented at an international Flash conference, and moderates on several prominent Flash community Web sites. He is currentl y em p lo y ed at Hallmark Cards Inc., in the IT Solutions Center Of Excellence, focusin g primarily on Java and Application Architecture development. Michael contributed Appendix B,"Multiuser Servers." I l @ve RuBoard I l @ve RuBoard Introduction People are always asking me about game development—how they can get into it, what's the best tool for it, etc. I answer questions like this wherever I go. And it got me thinking that if so many people had all these in- depth questions, there must not be a good resource out there…. This book brings you into the world of game development—specifically, game development in Flash, withthe powerful ActionScript tool to help you automate, repeat, change, anticipate, and govern the actions of games from a simple word gameto a complicated multiplayer game of pool. It is in no way a basic Flash tutorial, fair amount of familiarity withFlash is assumed, without which you might have a hard time navigating the terrain. If you're new toFlash gaming, here you'll acquire the knowledge and techniques to build your own games a good sense of the overall process and its pitfalls. If you aren't new to gaming, you'll be able to see what you can do better (or worse) by using Flash, and still come away withthe knowledge and techniques necessary to build Flash games. A book about games wouldn't make any sense without source material—would y ou rather learn how to create platform game by hearing about it, or by playing through example files?—and this book is no exception. Each chapter is accompanied by Flash movie files and sometimes other supporting format files to emphasize and describe the point at hand, and allow you to see the function in action. I welcome your input on this book; you can send me feedback at jobe@electrotank.com. I also encourage to visit GameBook.net ( www.gamebook.net), the Web site for this book, for updates, innovations, and inspiration. I l @ve RuBoard I l @ve RuBoard Why Flash? MacromediaFlashMX is many things to many people. In its few years on earth so far, it's been an animation tool, a Web site creation program, an application development program, and now a game development platform. In Part 1 of this book you'll hear more about Flash's strengths and weaknesses in this area, and in course of this book you'll be able to see some of the many things it can help you achieve. System Requirements Windows 200 MHz Intel Pentium processor Windows 98 SE, Me, NT4, 2000, or XP 64 MB of free available system RAM (128 MB recommended) 85 MB of available disk space 1024 x 768, 16-bit (thousands of colors) color display or better CD-ROM drive Macintosh Mac OS 9.1 and higher, or OS X 10.1 and higher 64 MB of free available system RAM (128 MB recommended) 85 MB of available disk space 1024 x 768, 16-bit (thousands of colors) color display or better CD-ROM drive I l @ve RuBoard I l @ve RuBoard How to use this book This book introduces you tothe world of online gaming, shows where Flash fits into the larger universe of online gaming, shows what it is and isn't good for, and goes into great detail on how to create games using Flash. Game development isn't all fun and games. It requires a lot of planning, projecting, and imposing logical structures on information. Part 1 introduces you tothe g eneral world of g amin g , its terminolo g y, and its basic genres. The chapters in Part 2 move through the important concepts that underlie the actual game creation. While not exactly in linear succession, these chapters proceed from the most fundamental of gaming tools (such as trigonometry) tothe more complex topics such as collision reactions and the use of artificial intelligence to add complexity and interaction to your games. In the latter portion of Part 2 we introduce chapters on enhancements such as fine-tuning graphics for your games, creating optimal soundtracks, and using high score lists. We end Part 2 with a chapter on understanding (and writing and modifying) an online chat file, without which no online multiplayer game is possible. Wherever you start reading, we'll keep you apprised of what you might need to refer to elsewhere to be sure you are getting the most out of the In Part 3 of the book, armed withthe knowledge you've amassed in the several hundred pages leading up to you'll work directly with complete games and see exactly what went into them. You'll even see ways you improve them on your own! Some of the appendices will guide you through a few complex topics that are intertwined withgamedesign development but which are, in fact, distinct topics with other applications as well. We use the following icons to call attention to special sections: This indicates a helpful suggestion—advice that will help you get the most out of the subject at hand. This means "Pay attention; important stuff here!" Indicates that you should open a designated file from the CD to follow along withthe text. Suggests another idea you might want to try in addition tothe main point that's made. This arrow refers you to a related section of the book, where the same topic is [...]... about the major advantages and disadvantages of using Flashto develop games, as well as discuss certain types of games that are not easily workable in FlashFlash vs Non -Flash Games While I'd like to tell you that Flash can outperform all other game- development platforms with its hands tied behind its back, that's just not the case There are many reasons to choose Flash for game development, and there... some of thegames that you'll know—literally inside and out—when you're done reading this book 9-BALL WORD SEARCH What kinds of games are possible in Flash? Take a look at some of thegames that are dissected and in detail in the third section of this book (The source files for these games are provided on the accompanying CD-ROM.) All of the information and techniques needed to make games like these... your game as a Projector file, Flash cannot easily talk to the local operating system to do things like browse files on the hard drive (But this type of possible withthe use of third-party software such as Northern Codeworks' SWF Studio, available at http://www.northcode.com.) Most of the developers who choose Flash as their game- creation tool do so because they want their games be available to many... from the simple to the extremely complex Flash' s strengths and limitations make it ideal for creating some kinds of games and less than optimal for others ActionScript the programming language used in Flash is going to be the main tool through which bring your gamesto fruition Familiarizing yourself withgame genres and terminology is a good first step toward deciding what and levels, of games interest... then attempts to knock the 8 ball into a pocket If the player succeeds, he wins thegame If either player knocks the 8 ball into a pocket before he has finished sinking all of his numbered balls, that player loses thegame If the cue ball ever goes into a pocket, the player's turn ends If a player hits one of her numbered balls into a pocket without hitting the cue ball into a pocket, then the player's... where you need to brush up! For reasons of portability, extensibility, integration, file size, and near-universal access, Flash is a good choice for games you'd like to make available on the Internet Flash is easy enough to learn that you can be up and creatinggames in a very short time A high cost of the small file sizes and accessibility of Flashgames is their slow performance relative togames created... possible FlashWith this book you'll learn about all the pieces you need to build a game, from graphics to sound, and you'll see how everything was put together in several finished games By the end of the book you should be well on your way to making your own gaming ideas a reality! I l@ve RuBoard I l@ve RuBoard Points to Remember Flash is a powerful authoring tool that can help you create games from the. .. emotionally attached Build theGame Now that you have an excellent idea of what your final game is supposed to do, you can focus on actually creating it Strategies for how to build specific games are covered in Part 3 of this book As there are many types of games, so there are many ways to approach putting them together In the most generic sense, you always: 1 Create or collect all of thegame assets, such... confused with RPGs, adventure games let you control a character in an environment the story is discovered Unlike what happens in an RPG, your actions do not affect your character's overall abilities Examples of adventure games range from Super Mario Brothers to the games in the King's Quest series Casino— One of the most popular genres to play on the Internet is casino (that is, gambling) games, such... explaining it on an instruction in a commercial game Make sure that thegame has an objective The Idea: Multiplayer 8-ball The Object: To knock the cue ball into the player's own set of pool balls (solid or striped) to send them into pocket The Rules: Thegame of 8-ball is played on a pool table with six pockets There are 16 balls (numbered 1 through 15, plus the white cue ball) Balls 1 through 8 are each . to facilitate multi p la y er g ames. If y ou're tired of the g • Table of Contents • Examples Macromedia Flash MX Game Design Demystified: The Official Guide to Creating Games with. choose Flash as their game- creation tool do so because they want their games be available to many people easily on the Internet. If the intention is to have the game available offline on ROM, then. talk about the major advantages and disadvantages of using Flash to develop games, as well as discuss certain types of games that are not easily workable in Flash. Flash vs. Non -Flash Games While