1. Trang chủ
  2. » Công Nghệ Thông Tin

AdvancED Game Design with Flash ppt

809 930 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Prelim

  • Contents at a Glance

  • Contents

  • About the Author

  • About the Technical Reviewer

  • About the Cover Image Designer

  • Acknowledgments

  • Introduction

    • Things you need to know

    • What about math?

    • Things you need to have

    • Organizing the project folder

      • FLAs and metadata for Flash Professional

    • Using the class library

      • Setting the path to the class library

      • Packages and namespaces

      • Using SWC Files

      • Testing the class library installation

    • Code format conventions

    • Public properties or getters and setters?

  • Modeling Game Data

    • The problem with Euler integration

    • Understanding Verlet integration

    • Using Verlet integration

    • Using the main application class

      • Importing the classes

      • Positioning the _player object

      • Figuring out the new velocity, checking collisions, and moving the player

      • Testing the system

    • Onward to Planet X!

      • Revving the Verlet velocity engine

      • Moving the spaceship

    • Understanding MVC

    • MVC in action

      • The view

      • The controller

      • The model

    • MVC your way

    • An MVC player and map view example

      • The PlayerModel

      • The PlayerView

      • The PlayerController

      • The MapView

      • The PlayerMVC application class

    • Verlet + MVC + physics = fun!

      • Making stars

      • Moving stars

    • Drawing lines

    • Drawing squares

    • Drawing circles

    • Adding filters

    • Gradient fills

    • Complex shapes

      • Drawing the ship

      • Drawing the ship’s thruster flame

      • Add both shapes to a container sprite

      • Using drawPath for really complex shapes

  • Vectors: Ghosts in the Machine

    • Vector characteristics

      • The x and y components

      • Vector magnitude

    • Calculating the angle

    • Vector normals

    • Normalizing vectors

    • Creating the vector model

    • Creating the vector view

    • Let’s see what those vectors look like!

      • Updating the vector each frame

      • Rotating text

      • Rounding numbers to a specific number of decimal places

    • Scaling vectors

    • Gravity in action

    • Real gravity

    • Are the vectors pointing in the same direction?

      • DragHandle objects

      • Scaling a vector object’s view

      • The VectorMath class

    • Projection in action

    • Using vector projection for environmental boundaries

    • Finding the intersection point

    • Intersection in action

    • Collision on one side of the line

      • Getting the vector magnitude and orientation

      • Detecting a collision

    • Resolving the collision

    • Bounce

    • Momentum

    • Solid objects

    • Collision on both sides of the line

    • Bounce, friction, and gravity

    • Embedding fonts

    • Embedding images

      • Create vectors

      • Vector magnitude

      • Vectors and angles

      • Left and right normals

      • Normalized vectors (unit vectors)

      • Scaling vectors

      • Gravity

      • Dot product

      • Projection

      • Define an environmental boundary

      • Resolve a collision with a vector

      • Bounce

      • Friction

  • Collisions Between Circles

    • Understanding abstract and concrete classes

    • Creating and implementing abstract classes

      • Creating an abstract Verlet motion class

      • Creating an abstract view class

      • Creating a concrete CircleView class

    • Collisions between moving and stationary circles

    • Collision between a circle and a line

      • Finding the point of contact

      • Finding the edge of the line

    • Collision between moving circles

  • Collisions Between Polygons

    • Understanding SAT

    • Using SAT

      • An SAT limitation

      • Finding the amount of overlap

      • Finding the collision side

    • Rectangle collision handling in action

    • Bounce and friction

    • SAT with triangles—the wrong way

    • SAT with triangles—the right way

    • Triangle collision handling in action

      • Make the shapes

      • Plot the hypotenuse as a vector

      • Create a distance vector between the centers of the objects

      • Project the distance vector onto the hypotenuse’s normal

      • Project the square onto the hypotenuse’s normal

      • Create a gap vector between the square and hypotenuse

      • Find the dot product

      • Check if the shapes are overlapping

      • Move the square out of the collision

    • Triangle collision wrap-up

    • Circle and square collisions

    • Circle and triangle collisions

    • Left-facing triangles

    • Case study 1: Polygon environment

      • Handling slopes

      • Building game worlds

    • Case study 2: Block Game

      • MVC saves the day again!

      • The application class

      • The GameModel

      • The GameView

      • The GameController

      • Plotting the grid of blocks

  • Pixel-Perfect Collision and Destructible Environments

    • Checking for a collision

    • The problems with bitmap collision

    • Finding the collision boundary

    • Convex shapes

      • Creating bitmaps from sprites

      • Creating the asteroid bitmap

      • Collision with the asteroid

      • Inside out

    • Surfaces

    • Concave shapes

      • A really huge cave

      • Scrolling

      • The mini-map

      • The map marker

    • Using two-dimensional arrays

    • Creating and adding the objects

    • Scrolling the objects

    • Drawing and rotating the cannon

    • Firing bullets

    • Moving and removing bullets

    • Bitmap collision using points

    • Erasing the bitmap

    • Jagged rocks

  • Explosions, Blitting, and Optimization

    • Using timer events for animation

    • Creating the Explosion class

      • Dynamic properties

      • Adding and removing explosions

    • Taking a snapshot

    • Slicing and dicing

      • Tiles, tile sheets, and grids

      • Making the bitmap explosion

    • Introducing bit-block transfer

    • Basic blitting

    • How fast is fast?

      • Calculating the frame rate and memory usage

      • MovieClip vs. copyPixels

    • To blit or not to blit?

    • Blit explosions

    • The Perlin noise effect

    • Smoke trail optimization

  • Make It Fun! Sound, Music, and AI

    • Adding sound effects

    • Playing music

      • Playing and pausing

      • Restarting music

      • Fast-forwarding and rewinding

      • Changing the volume and speaker panning

      • Looping music

    • Using sound and music in a game

    • Finding sound effects and music

    • Creating simple buttons

    • Making custom buttons

    • Chasing the player

    • Structure: your best friend and worst enemy

      • Creating a simple helper class

      • Structuring Escape!

    • Managing game screens

      • Delaying the game-over screen

    • Multiple views of the game data

    • New enemy AI techniques

      • Lying in wait

      • Traveling along a fixed path

    • Managing game states

    • Now make your own game!

  • Tile-Based Game Design

    • Making tiles

      • The tile sheet

      • Tile sheet coordinates

    • Making a map

    • Describing the map with a two-dimensional array

    • Creating the tile model

    • Putting the map in the game

    • Blitting tiles

    • Reviewing the Map application class

    • Layering maps

    • Making the game character move

      • Jumping

      • Moving with the mouse

    • Blitting a moving character in a tile-based world

    • Understanding spatial grid collision

    • Finding the corners

    • Applying a spatial grid to platform collision

    • Working with round tiles

    • Adding soft platforms

    • Adding elevators

    • Collecting objects

    • Wind them up and let them loose!

    • Squashing enemies

    • Blit animations

      • Longer blit animations

      • Movie clips vs. blitting for animation

    • Switching levels

    • Adding a camera

    • Establishing game world coordinates

    • Blitting the tile into a sprite

    • Creating the car’s control system

    • Stuck in the grass

    • Creating the AI car

    • Controlling the AI car

    • Understanding dynamic spatial grids

    • Updating a dynamic grid

    • Creating a collision map

  • Pathfinding

    • Centering game objects

    • Moving and changing direction

      • Moving Button Fairy

      • Changing direction

    • Random movement in a maze

      • Finding an intersection

      • Changing direction

    • Chasing

    • Tile-based line of sight

    • Understanding A*

      • Calculating costs

      • Finding the second step

      • Linking the nodes through their parents

    • A* in code

      • Creating a node map

      • The complete AStar class

    • Using the AStar class

    • Understanding heuristics

    • Rounding corners

    • Walking the path

    • Extending and customizing A*

      • Variable terrain

      • Influence map

      • Dijkstra’s algorithm

  • XML and External Data

    • Creating and loading shared objects

    • Using shared objects

    • Limitations of local shared objects

    • Loading and saving files to a specific location

      • Loading the file

      • Saving the file

    • The building blocks of XML

    • XML hierarchy

    • XML and ActionScript

    • Reading elements, text nodes, and attributes

      • Reading attributes

      • Looping through elements and attributes

      • Finding all the child elements

      • A better way to find what you’re looking for

    • Adding new elements and attributes

    • Building XML documents from existing variables

    • Removing nodes from XML documents

    • Creating a game level map

    • Loading and interpreting the XML map data

    • Creating multiple game levels with XML

    • Using URLLoader to load files

    • Runtime loading security issues

      • Problems loading files locally

      • Problems loading files remotely

    • 3D games

    • 2D physics

    • Online multiplayer games

    • Further reading

    • Where to next?

  • Index

    • Symbols

    • Numbers

    • A

    • B

    • C

    • D

    • E

    • F

    • G

    • H J

    • K

    • L

    • I

    • M

    • O

    • N

    • P

    • Q

    • R

    • S

    • T

    • U

    • V

    • W

    • X

    • Y

    • Z

Nội dung

REX VAN DER SPUY AdvancED Game Design with Flash All the essential techniques that every game designer should know. Physics for games, pathfinding, game structure with the MVC design pattern, tile-based games, vector math, and advanced collision detection strategies. AS3.0 Code compatible with Flash CS3 – CS5, Flash Builder, and the open-source Flex SDK. Download from Wow! eBook <www.wowebook.com> AdvancED Game Design with Flash Rex van der Spuy AdvancED Game Design with Flash AdvancED Game Design with Flash Copyright © 2010 by Rex van der Spuy All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2739-7 ISBN-13 (electronic): 978-1-4302-2740-3 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logos, or image we use the names, logos, or images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. Distributed to the book trade worldwide by Springer Science+Business Media LLC., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. For information on translations, please e-mail rights@apress.com or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is freely available to readers at www.friendsofed.com in the Downloads section. Credits President and Publisher: Paul Manning Lead Editor: Ben Renow-Clarke Technical Reviewer: Joshua Freeney Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Kelly Moritz Copy Editor: Marilyn Smith Compositor: Lynn L’Heureux Indexer: Brenda Miller Artist: April Milne Cover Designer: Bruce Tang For Mom and Jim, for all your love and support iv Contents at a Glance 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 Chapter 2: Vectors: Ghosts in the Machine 67 Chapter 3: Collisions Between Circles 161 Chapter 4: Collisions Between Polygons 223 Chapter 5: Pixel-Perfect Collision and Destructible Environments 305 Chapter 6: Explosions, Blitting, and Optimization 367 Chapter 7: Make It Fun! Sound, Music, and AI 445 Chapter 8: Tile-Based Game Design 503 Chapter 9: Pathfinding 623 Chapter 10: XML and External Data 691 Index 749 v Contents 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 Verlet integration 2 The problem with Euler integration 3 Understanding Verlet integration 4 Using Verlet integration 5 Using the main application class 13 Onward to Planet X! 18 Introducing the Model-View-Controller Pattern 22 Understanding MVC 23 MVC in action 25 MVC your way 30 An MVC player and map view example 32 Verlet + MVC + physics = fun! 44 A crash course in the drawing API 49 Drawing lines 50 Drawing squares 50 Drawing circles 52 Adding filters 53 Gradient fills 54 Complex shapes 57 Introducing interfaces 64 Summary 66 CONTENTS vi Chapter 2: Vectors: Ghosts in the Machine 67 What are vectors? 68 Vector characteristics 69 Calculating the angle 73 Vector normals 75 Normalizing vectors 78 Using and viewing vectors 80 Creating the vector model 80 Creating the vector view 87 Let’s see what those vectors look like! 87 Adding and subtracting vectors 94 Scaling vectors 96 Gravity in action 100 Real gravity 105 Projecting vectors 105 Are the vectors pointing in the same direction? 107 Projection in action 110 Using vector projection for environmental boundaries 113 Intersection 115 Finding the intersection point 116 Intersection in action 118 Collision and bounce 121 Collision on one side of the line 121 Resolving the collision 129 Bounce 135 Momentum 138 Solid objects 139 Collision on both sides of the line 141 Bounce, friction, and gravity 146 A crash course in embedding assets 151 Embedding fonts 151 Embedding images 152 Important vector formulas 155 Summary 160 CONTENTS vii Chapter 3: Collisions Between Circles 161 Abstract classes 162 Understanding abstract and concrete classes 162 Creating and implementing abstract classes 166 Keyboard and mouse control 176 Collision-handling basics 181 Collisions between moving and stationary circles 181 Collision between a circle and a line 187 Collision between moving circles 202 Multiple-object collision 211 Fast-moving circles 215 Summary 221 Chapter 4: Collisions Between Polygons 223 The separating axis theorem 224 Understanding SAT 224 Using SAT 225 Rectangle collisions 237 Rectangle collision handling in action 238 Bounce and friction 242 Triangle collisions 244 SAT with triangles—the wrong way 246 SAT with triangles—the right way 247 Triangle collision handling in action 250 Triangle collision wrap-up 261 Oriented bounding box collisions 262 Polygon and circle collisions 267 Circle and square collisions 268 Circle and triangle collisions 276 Left-facing triangles 282 Case studies 283 Case study 1: Polygon environment 283 Case study 2: Block Game 286 Multilevel games 301 Summary 303 CONTENTS viii Chapter 5: Pixel-Perfect Collision and Destructible Environments 305 Vector vs. bitmap graphics 306 Using bitmaps 308 Bitmap collisions 309 Checking for a collision 310 The problems with bitmap collision 314 Finding the collision boundary 315 Bitmap collision-detection strategies 320 Convex shapes 321 Surfaces 328 Concave shapes 330 Adding objects to scrolling environments 344 Using two-dimensional arrays 345 Creating and adding the objects 349 Scrolling the objects 350 Building a rotating gun turret 351 Drawing and rotating the cannon 352 Firing bullets 355 Moving and removing bullets 356 Destroying things! 357 Bitmap collision using points 359 Erasing the bitmap 360 Jagged rocks 362 Summary 365 Chapter 6: Explosions, Blitting, and Optimization 367 A simple particle explosion 368 Using timer events for animation 369 Creating the Explosion class 371 A more realistic explosion 378 Taking a snapshot 379 Slicing and dicing 384 Starburst explosions 396 Fast particle explosions 401 Introducing bit-block transfer 401 Basic blitting 404 [...]... you need to know AdvancED Game Design with Flash is a direct follow-up of my book Foundation Game Design with Flash (friends of ED, 2009) If you’ve read that book, and have had a bit of practical experience making some of your own games, you have all the skills and knowledge you need to enjoy the fun we’re going to have in this book If you haven’t read Foundation Game Design with Flash, but have a... 745 Online multiplayer games 746 Further reading 747 Where to next? 747 Index 749 xii About the Author Rex van der Spuy, author of Foundation Game Design with Flash, is a freelance interactive media designer specializing in Flash game design, interface design, and ActionScript programming Rex programmed his first adventure game at 10 years’ old... working examples, and game prototypes you can use in your own projects By the end of the book, you’ll be able to apply these skills to any game idea you might have There’s little that you won’t be able to approach with confidence “Hey, where’s the 3D?” Like Foundation Game Design with Flash, this book strategically omits discussing 3D games The reason is depth (pun intended!) 2D game design is itself such... was his vision for Foundation Game Design and AdvancED Game Design to be two books, and they exist thanks to his consistent vision and encouragement over the two years that it took to write them xvi Introduction Game design is unquestionably one of the most interesting and complex challenges that a programmer can take on If you’ve ever tackled the design of even a simple game, you’ll know that the questions... far better prepared for 3D games if you have a comprehensive understanding of 2D 2D and 3D game design share the same fundamentals, but it’s far easier to learn the craft of game design without the extra layers of complexity you would need to tackle to simultaneously learn a 3D engine At the end of this book, you’ll be a great game designer—in any dimension—and you’ll find 3D games a snap to develop when... the game data 489 New enemy AI techniques 491 Managing game states 498 Now make your own game! 500 Summary 501 Chapter 8: Tile-Based Game Design 503 Tile-based game advantages 504 Building the game world 505 Making tiles 505 Making a map 508 Describing the map with. .. teaches Flash game development classes focused on rapid agile production with maximum reusability He likes board games, camping, sleeping in, and anything LEGO xiv About the Cover Image Designer Bruce Tang is a freelance web designer, visual programmer, and author from Hong Kong His main creative interest is generating stunning visual effects using Flash or Processing Bruce has been an avid Flash user... create game objects using library instances Flash Builder 4: Flash Builder (formerly Flex Builder) is optimized for AS3.0 programming It doesn’t allow you to create game objects visually—there are no drawing tools and no library But it’s probably the best pure-code AS3.0 editor available Flash Builder is free for students If you don’t need or want all the bells and whistles of Flash Professional or Flash. .. modified Saving, loading, and sharing game data Streamlining your game design management and performance by using a tile-based model Pathfinding so that game objects can navigate their way around complex environments This is a classic education in making video games and a compendium of all the important techniques you’ll need to know to flourish as a professional game designer Labyrinthine complexities?... control it gives you over your game environment Things you need to have An integrated development environment (IDE) is the tool that you use to make Flash games Adobe has two commercial IDEs, and you’ve probably already used at least one of them: Flash Professional (also known as Flash CS3, CS4, or CS5): A big advantage to using the Flash IDE is that you can draw your game objects using its drawing . <www.wowebook.com> AdvancED Game Design with Flash Rex van der Spuy AdvancED Game Design with Flash AdvancED Game Design with Flash Copyright © 2010 by Rex van der. SPUY AdvancED Game Design with Flash All the essential techniques that every game designer should know. Physics for games, pathfinding, game structure with the MVC design pattern, tile-based games,. Minotaur. You have this book. Things you need to know AdvancED Game Design with Flash is a direct follow-up of my book Foundation Game Design with Flash (friends of ED, 2009). If you’ve read that

Ngày đăng: 28/03/2014, 23:20

TỪ KHÓA LIÊN QUAN