E-Book, Englisch, 808 Seiten
Spuy AdvancED Game Design with Flash
1. ed
ISBN: 978-1-4302-2740-3
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
E-Book, Englisch, 808 Seiten
ISBN: 978-1-4302-2740-3
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
Creating games in Flash is a never-ending journey of exploration, learning, and most of all, fun. Once you've mastered the basics, a new world is opened up to you, enabling you to take your existing skills to the next level and discover new skills that will in turn open new doors. This book is a direct continuation of Foundation Game Design with Flash, and is a complete point-by-point roundup of the most important skills a Flash game designer needs to know. You'll increase your ActionScript knowledge and your game design skills while creating some excellent example games. You'll learn advanced collision detection skills; professional AI and pathfinding; and how to load and save game data, create destructible environments, and build and switch game levels. Each chapter highlights a new advanced technique illustrated by practical examples. Examples of games are given in a variety of genres, all of which take an object-oriented programming approach. Advanced game design topics are covered, including vector-based collision reaction, pathfinding, billiard ball physics, and modeling game data.
Rex van der Spuy is a video game designer and writer. He s written Foundation Game Design with Flash, Advanced Game Design with Flash and Foundation Game Design with AS3.0. Rex has designed games and done interactive interface programming Agency Interactive (Dallas), Scottish Power (Edinburgh), DC Interact (London), Draught Associates (London), and the Bank of Montreal (Canada). He also builds game engines and interactive interfaces for museum installations for PixelProject (Cape Town). In addition, he created and taught advanced courses in game design for the Canadian School of India (Bangalore, India). When not writing about games, making them, or playing them, he amuses himself by building experimental, autonomous, self-aware, multi-cellular parallel universes out of shoe boxes, scotch tape, spare milk bottle caps and bits of string . He claims, that this is a lot more entertaining than you might think, but we re skeptical.
Autoren/Hrsg.
Weitere Infos & Material
1;Title page ;1
2;Copyright page ;2
3;Contents at a Glance;4
4;Table of contents ;5
5;About the Author;13
6;About the Technical Reviewer;14
7;About the Cover Image Designer;15
8;Acknowledgments;16
9;Introduction;17
9.1;Enter the labyrinth!;17
9.1.1;Things you need to know;17
9.1.2;What about math?;19
9.1.3;Things you need to have;19
9.2;What kind of games will we make?;20
9.3;How to read this book;21
9.4;The files you’ll need;22
9.5;Setting up your work environment;23
9.5.1;Organizing the project folder;23
9.5.1.1;FLAs and metadata for Flash Professional;24
9.5.2;Using the class library;25
9.5.2.1;Setting the path to the class library;25
9.5.2.2;Packages and namespaces;26
9.5.2.3;Using SWC Files;28
9.5.2.4;Testing the class library installation;29
9.6;Optimizing the code;31
9.7;About the code;32
9.7.1;Code format conventions;32
9.7.2;Public properties or getters and setters?;35
9.8;Layout conventions;37
10;Chapter 1 Modeling Game Data;38
10.1;Verlet integration;39
10.1.1;The problem with Euler integration;40
10.1.2;Understanding Verlet integration;41
10.1.3;Using Verlet integration;42
10.1.4;Using the main application class;50
10.1.4.1;Importing the classes;52
10.1.4.2;Positioning the _player object;52
10.1.4.3;Figuring out the new velocity, checking collisions, and moving the player;52
10.1.4.4;Testing the system;54
10.1.5;Onward to Planet X!;55
10.1.5.1;Revving the Verlet velocity engine;55
10.1.5.2;Moving the spaceship;58
10.2;Introducing the Model-View-Controller Pattern;59
10.2.1;Understanding MVC;60
10.2.2;MVC in action;62
10.2.2.1;The view;65
10.2.2.2;The controller;66
10.2.2.3;The model;67
10.2.3;MVC your way;67
10.2.4;An MVC player and map view example;69
10.2.4.1;The PlayerModel;71
10.2.4.2;The PlayerView;73
10.2.4.3;The PlayerController;77
10.2.4.4;The MapView;78
10.2.4.5;The PlayerMVC application class;80
10.2.5;Verlet + MVC + physics = fun!;81
10.2.5.1;Making stars;84
10.2.5.2;Moving stars;85
10.3;A crash course in the drawing API;86
10.3.1;Drawing lines;87
10.3.2;Drawing squares;87
10.3.3;Drawing circles;89
10.3.4;Adding filters;90
10.3.5;Gradient fills;91
10.3.6;Complex shapes;94
10.3.7;Drawing the ship;94
10.3.8;Drawing the ship’s thruster flame;95
10.3.9;Add both shapes to a container sprite;96
10.3.10;Using drawPath for really complex shapes;98
10.4;Introducing interfaces;101
10.5;Summary;103
11;Chapter 2 Vectors: Ghosts in the Machine;104
11.1;What are vectors?;105
11.1.1;Vector characteristics;106
11.1.1.1;The x and y components;107
11.1.1.2;Vector magnitude;109
11.1.1.3;Calculating the angle;110
11.1.1.4;Vector normals;112
11.1.1.5;Normalizing vectors;115
11.2;Using and viewing vectors;117
11.2.1;Creating the vector model;117
11.2.2;Creating the vector view;124
11.2.3;Let’s see what those vectors look like!;124
11.2.4;Updating the vector each frame;127
11.2.5;Rotating text;128
11.2.6;Rounding numbers to a specific number of decimal places;130
11.3;Adding and subtracting vectors;131
11.3.1;Scaling vectors;133
11.3.2;Gravity in action;137
11.3.3;Real gravity;142
11.4;Projecting vectors;142
11.4.1;Are the vectors pointing in the same direction?;144
11.4.2;DragHandle objects;145
11.4.3;Scaling a vector object’s view;146
11.4.4;The VectorMath class;146
11.4.5;Projection in action;147
11.4.6;Using vector projection for environmental boundaries;150
11.5;Intersection;152
11.5.1;Finding the intersection point;153
11.5.2;Intersection in action;155
11.6;Collision and bounce;158
11.6.1;Collision on one side of the line;159
11.6.2;Getting the vector magnitude and orientation;161
11.6.3;Detecting a collision;162
11.6.4;Resolving the collision;166
11.6.5;Bounce;172
11.6.6;Momentum;175
11.6.7;Solid objects;176
11.6.8;Collision on both sides of the line;178
11.6.9;Bounce, friction, and gravity;183
11.7;A crash course in embedding assets;188
11.7.1;Embedding fonts;188
11.7.2;Embedding images;190
11.8;Important vector formulas;192
11.8.1;Create vectors;192
11.8.2;Vector magnitude;193
11.8.3;Vectors and angles;193
11.8.4;Left and right normals;193
11.8.5;Normalized vectors (unit vectors);193
11.8.6;Scaling vectors;194
11.8.7;Gravity;194
11.8.8;Dot product;195
11.8.9;Projection;195
11.8.10;Define an environmental boundary;195
11.8.11;Resolve a collision with a vector;195
11.8.12;Bounce;196
11.8.13;Friction;197
11.9;Summary;197
12;Chapter 3 Collisions Between Circles;198
12.1;Abstract classes;199
12.1.1;Understanding abstract and concrete classes;199
12.1.2;Creating and implementing abstract classes;203
12.1.2.1;Creating an abstract Verlet motion class;203
12.1.2.2;Creating an abstract view class;209
12.1.2.3;Creating a concrete CircleView class;211
12.2;Keyboard and mouse control;213
12.3;Collision-handling basics;218
12.3.1;Collisions between moving and stationary circles;218
12.3.2;Collision between a circle and a line;224
12.3.2.1;Finding the point of contact;225
12.3.2.2;Finding the edge of the line;230
12.3.3;Collision between moving circles;239
12.4;Multiple-object collision;248
12.5;Fast-moving circles;252
12.6;Summary;258
13;Chapter 4 Collisions Between Polygons;259
13.1;The separating axis theorem;260
13.1.1;Understanding SAT;260
13.1.2;Using SAT;261
13.1.2.1;An SAT limitation;267
13.1.2.2;Finding the amount of overlap;268
13.1.2.3;Finding the collision side;270
13.2;Rectangle collisions;273
13.2.1;Rectangle collision handling in action;274
13.2.2;Bounce and friction;278
13.3;Triangle collisions;280
13.3.1;SAT with triangles—the wrong way;282
13.3.2;SAT with triangles—the right way;283
13.3.3;Triangle collision handling in action;286
13.3.3.1;Make the shapes;287
13.3.3.2;Plot the hypotenuse as a vector;287
13.3.3.3;Create a distance vector between the centers of the objects;288
13.3.3.4;Project the distance vector onto the hypotenuse’s normal;289
13.3.3.5;Project the square onto the hypotenuse’s normal;290
13.3.3.6;Create a gap vector between the square and hypotenuse;295
13.3.3.7;Find the dot product;295
13.3.3.8;Check if the shapes are overlapping;296
13.3.3.9;Move the square out of the collision;297
13.3.4;Triangle collision wrap-up;297
13.4;Oriented bounding box collisions;298
13.5;Polygon and circle collisions;303
13.5.1;Circle and square collisions;304
13.5.2;Circle and triangle collisions;312
13.5.3;Left-facing triangles;318
13.6;Case studies;319
13.6.1;Case study 1: Polygon environment;319
13.6.1.1;Handling slopes;321
13.6.1.2;Building game worlds;322
13.6.2;Case study 2: Block Game;322
13.6.2.1;MVC saves the day again!;323
13.6.2.2;The application class;325
13.6.2.3;The GameModel;326
13.6.2.4;The GameView;328
13.6.2.5;The GameController;330
13.6.2.6;Plotting the grid of blocks;336
13.7;Multilevel games;337
13.8;Summary;339
14;Chapter 5 Pixel-Perfect Collision and Destructible Environments;340
14.1;Vector vs. bitmap graphics;341
14.2;Using bitmaps;343
14.3;Bitmap collisions;344
14.3.1;Checking for a collision;345
14.3.2;The problems with bitmap collision;349
14.3.3;Finding the collision boundary;350
14.4;Bitmap collision-detection strategies;355
14.4.1;Convex shapes;356
14.4.1.1;Creating bitmaps from sprites;356
14.4.1.2;Creating the asteroid bitmap;358
14.4.1.3;Collision with the asteroid;359
14.4.1.4;Inside out;362
14.4.2;Surfaces;363
14.4.3;Concave shapes;365
14.4.3.1;A really huge cave;372
14.4.3.2;Scrolling;374
14.4.3.3;The mini-map;375
14.4.3.4;The map marker;379
14.5;Adding objects to scrolling environments;379
14.5.1;Using two-dimensional arrays;380
14.5.2;Creating and adding the objects;384
14.5.3;Scrolling the objects;385
14.6;Building a rotating gun turret;386
14.6.1;Drawing and rotating the cannon;387
14.6.2;Firing bullets;390
14.6.3;Moving and removing bullets;392
14.7;Destroying things!;392
14.7.1;Bitmap collision using points;394
14.7.2;Erasing the bitmap;395
14.7.3;Jagged rocks;397
14.8;Summary;400
15;Chapter 6 Explosions, Blitting, and Optimization;402
15.1;A simple particle explosion;403
15.1.1;Using timer events for animation;404
15.1.2;Creating the Explosion class;406
15.1.2.1;Dynamic properties;409
15.1.2.2;Adding and removing explosions;410
15.2;A more realistic explosion;413
15.2.1;Taking a snapshot;414
15.2.2;Slicing and dicing;419
15.2.2.1;Tiles, tile sheets, and grids;421
15.2.2.2;Making the bitmap explosion;423
15.3;Starburst explosions;431
15.4;Fast particle explosions;436
15.4.1;Introducing bit-block transfer;436
15.4.2;Basic blitting;439
15.4.3;How fast is fast?;451
15.4.3.1;Calculating the frame rate and memory usage;451
15.4.3.2;MovieClip vs. copyPixels;454
15.4.4;To blit or not to blit?;456
15.4.5;Blit explosions;459
15.5;Lookup tables;464
15.6;An Explosion Controller;469
15.7;Smoke trails;473
15.7.1;The Perlin noise effect;473
15.7.2;Smoke trail optimization;477
15.8;Summary;479
16;Chapter 7 Make It Fun! Sound, Music, and AI;480
16.1;Put fun first;481
16.2;Sound effects and music;482
16.2.1;Adding sound effects;483
16.2.2;Playing music;486
16.2.2.1;Playing and pausing;488
16.2.2.2;Restarting music;490
16.2.2.3;Fast-forwarding and rewinding;490
16.2.2.4;Changing the volume and speaker panning;491
16.2.2.5;Looping music;494
16.2.3;Using sound and music in a game;495
16.2.4;Finding sound effects and music;497
16.3;Buttons;498
16.3.1;Creating simple buttons;498
16.3.2;Making custom buttons;499
16.4;Enemy AI: Line of sight;502
16.4.1;Chasing the player;511
16.5;Case study: Escape!;512
16.5.1;Structure: your best friend and worst enemy;514
16.5.1.1;Creating a simple helper class;516
16.5.1.2;Structuring Escape!;518
16.5.2;Managing game screens;519
16.5.2.1;Delaying the game-over screen;523
16.5.3;Multiple views of the game data;524
16.5.4;New enemy AI techniques;526
16.5.4.1;Lying in wait;526
16.5.4.2;Traveling along a fixed path;531
16.5.5;Managing game states;533
16.5.6;Now make your own game!;535
16.6;Summary;536
17;Chapter 8 Tile-Based Game Design;537
17.1;Tile-based game advantages;538
17.2;Building the game world;539
17.2.1;Making tiles;539
17.2.1.1;The tile sheet;539
17.2.1.2;Tile sheet coordinates;541
17.2.2;Making a map;542
17.2.3;Describing the map with a two-dimensional array;544
17.2.4;Creating the tile model;546
17.2.5;Putting the map in the game;549
17.2.6;Blitting tiles;555
17.2.7;Reviewing the Map application class;558
17.3;Adding a game character;562
17.3.1;Layering maps;563
17.3.2;Making the game character move;566
17.3.3;Jumping;567
17.3.4;Moving with the mouse;568
17.3.5;Blitting a moving character in a tile-based world;571
17.4;Platform collision;572
17.4.1;Understanding spatial grid collision;574
17.4.2;Finding the corners;576
17.4.3;Applying a spatial grid to platform collision;580
17.4.4;Working with round tiles;588
17.5;Adding more interaction;589
17.5.1;Adding soft platforms;589
17.5.2;Adding elevators;592
17.5.3;Collecting objects;596
17.5.4;Wind them up and let them loose!;600
17.5.5;Squashing enemies;604
17.5.6;Blit animations;607
17.5.6.1;Longer blit animations;612
17.5.6.2;Movie clips vs. blitting for animation;612
17.5.7;Switching levels;613
17.6;Blit scrolling;619
17.6.1;Adding a camera;621
17.6.2;Establishing game world coordinates;622
17.7;Using sprites in a tile-based world;624
17.7.1;Blitting the tile into a sprite;626
17.7.2;Creating the car’s control system;629
17.7.3;Stuck in the grass;632
17.8;Storing extra game data in arrays;633
17.8.1;Creating the AI car;637
17.8.2;Controlling the AI car;638
17.9;Collision maps;639
17.9.1;Understanding dynamic spatial grids;640
17.9.2;Updating a dynamic grid;641
17.9.3;Creating a collision map;645
17.10;Other broad-phase collision strategies;654
17.11;Summary;655
18;Chapter 9 Pathfinding;656
18.1;Moving through a maze;657
18.1.1;Centering game objects;658
18.1.2;Moving and changing direction;659
18.1.2.1;Moving Button Fairy;660
18.1.2.2;Changing direction;664
18.1.3;Random movement in a maze;666
18.1.3.1;Finding an intersection;667
18.1.3.2;Changing direction;670
18.1.4;Chasing;675
18.1.5;Tile-based line of sight;680
18.2;Finding the shortest path;688
18.2.1;Understanding A*;689
18.2.1.1;Calculating costs;690
18.2.1.2;Finding the second step;693
18.2.1.3;Linking the nodes through their parents;700
18.2.2;A* in code;700
18.2.2.1;Creating a node map;701
18.2.2.2;The complete AStar class;702
18.2.3;Using the AStar class;709
18.2.4;Understanding heuristics;713
18.2.5;Rounding corners;717
18.2.6;Walking the path;718
18.2.7;Extending and customizing A*;721
18.2.7.1;Variable terrain;721
18.2.7.2;Influence map;721
18.2.7.3;Dijkstra’s algorithm;722
18.3;Summary;722
19;Chapter 10 XML and External Data;723
19.1;Local shared objects;724
19.1.1;Creating and loading shared objects;724
19.1.2;Using shared objects;725
19.1.3;Limitations of local shared objects;730
19.1.4;Loading and saving files to a specific location;731
19.1.4.1;Loading the file;732
19.1.4.2;Saving the file;734
19.2;Understanding XML;736
19.2.1;The building blocks of XML;736
19.2.2;XML hierarchy;738
19.2.3;XML and ActionScript;741
19.3;Creating XML objects;742
19.3.1;Reading elements, text nodes, and attributes;743
19.3.1.1;Reading attributes;744
19.3.1.2;Looping through elements and attributes;745
19.3.1.3;Finding all the child elements;746
19.3.1.4;A better way to find what you’re looking for;750
19.4;Changing XML data;751
19.4.1;Adding new elements and attributes;752
19.4.2;Building XML documents from existing variables;754
19.4.3;Removing nodes from XML documents;755
19.5;Loading game levels from XML data;756
19.5.1;Creating a game level map;757
19.5.2;Loading and interpreting the XML map data;758
19.5.3;Creating multiple game levels with XML;762
19.6;Loading XML files at runtime;773
19.6.1;Using URLLoader to load files;773
19.6.2;Runtime loading security issues;774
19.6.2.1;Problems loading files locally;775
19.6.2.2;Problems loading files remotely;776
19.7;Are we there yet?;777
19.7.1;3D games;777
19.7.2;2D physics;777
19.7.3;Online multiplayer games;778
19.7.4;Further reading;779
19.7.5;Where to next?;779
20;Index;780




