Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 1.754 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
1.754
Dung lượng
14,71 MB
Nội dung
Killer Game Programming in Java By Andrew Davison Publisher: O'Reilly Pub Date: May 2005 ISBN: 0-596-00730-2 Pages: 1008 Table of Contents | Index Although the number of commercial Java games is still small compared to those written in C or C++, the market is expanding rapidly Recent updates to Java make it faster and easier to create powerful gaming applications-particularly Java 3D-is fueling an explosive growth in Java games Java games like Puzzle Pirates, Chrome, Star Wars Galaxies, Runescape, Alien Flux, Kingdom of Wars, Law and Order II, Roboforge, Tom Clancy's Politika, and scores of others have earned awards and become bestsellers Java developers new to graphics and game programming, as well as game developers new to Java 3D, will find Killer Game Programming in Java invaluable This new book is a practical introduction to the latest Java graphics and game programming technologies and techniques It is the first book to thoroughly cover Java's 3D capabilities for all types of graphics and game development projects Killer Game Programming in Java is a comprehensive guide to everything you need to know to program cool, testosterone-drenched Java games It will give you reusable techniques to create everything from fast, full-screen action games to multiplayer 3D games In addition to the most thorough coverage of Java 3D available, Killer Game Programming in Java also clearly details the older, better-known 2D APIs, 3D sprites, animated 3D sprites, first-person shooter programming, sound, fractals, and networked games Killer Game Programming in Java is a must-have for anyone who wants to create adrenaline-fueled games in Java Killer Game Programming in Java By Andrew Davison Publisher: O'Reilly Pub Date: May 2005 ISBN: 0-596-00730-2 Pages: 1008 Table of Contents | Index Copyright Preface Who Are You? What This Book Is About This Book (and More) Is Online What This Book Is Not About A Graphical View of This Book Conventions Used in This Book Using Code Examples Comments and Questions Safari Enabled Acknowledgments Chapter 1 Why Java for Games Programming? Java Is Too Slow for Games Programming Java Has Memory Leaks Java Is Too High-level Java Application Installation Is a Nightmare Java Isn't Supported on Games Consoles No One Uses Java to Write Real Games Sun Microsystems Isn't Interested in Supporting Java Gaming Chapter 2 An Animation Framework Animation as a Threaded Canvas Converting to Active Rendering FPS and Sleeping for Varying Times Sleeping Better FPS and UPS Pausing and Resuming Other Animation Approaches Chapter 3 Worms in Windows and Applets Preliminary Considerations Class Diagrams for the WormChase Application The Worm-Chasing Application The Game Panel Storing Worm Information Worm Obstacles Application Timing Results WormChase as an Applet Compilation in J2SE 5.0 Chapter 4 Full-Screen Worms An Almost Full-Screen (AFS) Worm An Undecorated Full-Screen (UFS) Worm A Full-Screen Exclusive Mode (FSEM) Worm Timings at 80 to 85 FPS Chapter 5 An Introduction to Java Imaging Image Formats The AWT Imaging Model An Overview of Java 2D Buffering an Image Managed Images VolatileImage Java 2D Speed Portability and Java 2D JAI Chapter 6 Image Loading, Visual Effects, and Animation Loading Images Applying Image Effects Displaying Image Sequences Visual Effects for 'o' Images Packaging the Application as a JAR Chapter 7 Introducing Java Sound Applet Playing The AudioClip Class The Sound Player The Java Sound API Sampled Audio MIDI Java Sound API Compared with JMF and JOAL Java Sound API Resources Audio Resources Chapter 8 Loading and Playing Sounds Loader Design and Implementation Issues Testing the Loaders The Sounds Panel The Clips Loader Storing Clip Information The Midi Sequences Loader Storing Midi Information LoadersTests as a JAR File Chapter 9 Audio Effects Audio Effects on Sampled Audio Audio Effects on MIDI Sequences Chapter 10 Audio Synthesis Sampled Audio Synthesis MIDI Synthesis Audio Synthesis Libraries Chapter 11 Sprites Bats, Balls, and Sprites Class Diagrams for BugRunner The Bug Starts Running The Animation Framework Defining a Sprite Coding a Sprite Specifying a Sprite with a Statechart The Ball Sprite Defining the Bat Chapter 12 A Side-Scroller JumpingJack in Layers Class Diagrams for JumpingJack Start Jack Jumping The Animation Framework Managing the Ribbons Wraparound Ribbons Managing the Bricks Storing Brick Information The Fireball The Jumping Sprite Other Side-Scroller Examples Tiling Software Chapter 13 An Isometric Tile Game Isometric Tiles Class Diagrams for AlienTiles The Animation Framework Managing the World Managing WorldItems The Tile Occupier A Sprite on a Tile The Player Sprite The Alien Sprite The Quadrant-Based Alien Sprite The A*-Based Alien Sprite Storing Tile Details Further Reading Chapter 14 Introducing Java 3D Java 3D Java 3D Strengths Criticisms of Java 3D for Games Programming Alternatives to Java 3D Chapter 15 A 3D Checkerboard: Checkers3D Class Diagrams for Checkers3D Integrating Java 3D and Swing Scene Graph Creation Floating Spheres The Floor Viewer Positioning Viewer Movement Viewing the Scene Graph Chapter 16 Loading and Manipulating External Models An Overview of LoaderInfo3D Loaders in Java 3D Displaying a Model Examining a Model's Scene Graph Adjusting a Model's Shape Attributes An Overview of Loader3D Using Loader3D Creating the Scene Managing the Model Building the Model's Scene Graph Chapter 17 Using a Lathe to Make Shapes Class Diagrams for Lathe3D Creating the Scene The Lathe Curve The Lathe Shape Subclassing the Lathe Shape Chapter 18 3D Sprites Class Diagrams for Tour3D Creating the Scene The Basic 3D Sprite The User's Touring Sprite The Alien Sprite Behaviors in Java 3D Controlling the Touring Sprite Updating the Alien Sprite Chapter 19 Animated 3D Sprites Class Diagrams for AnimTour3D Creating the Scene The Animated 3D Sprite Controlling the Sprite Animating the Sprite Full-Screen Exclusive Mode (FSEM) A Full-Screen Version of the Application Pros and Cons of Keyframe Animation Chapter 20 An Articulated, Moveable Figure The Articulated Figure Application Forward and Inverse Kinematics Class Diagrams for Mover3D Creating the Scene Processing User Input The Commands Panel Making and Moving the Figure Modeling a Limb Moving a Limb Other Articulated Figures Articulation and Mesh Deformation Articulation and Skinning Articulation and Morphing Chapter 21 Particle Systems Particle Systems in Java 3D Class Diagrams for Particles3D Creating the Scene A Fountain of Points A Fountain of Lines A Fountain of Quads Performance Results More Particle Systems Other Java 3D Approaches Non-Java 3D Approaches Chapter 22 Flocking Boids A Flocking Application Scene Creation Adding Obstacles Types of Boids Grouping the Boids Flock Behavior Chapter 23 Shooting a Gun Class Diagrams for Shooter3D Scene Creation The Sound of Shooting Picking Scene Objects Controlling the Gun Preparing the Laser Beam Causing an Explosion Picking with a Mouse Click Shooting Behavior Firing the Beam More on Picking Chapter 24 A First-Person Shooter Class Diagrams for FPShooter3D Setting Up the Target Positioning and Moving the User's Viewpoint Initializing the User's Viewpoint Adding an Image to the Viewpoint Managing the Ammunition Managing a Laser Beam Moving the Viewpoint Chapter 25 A 3D Maze Class Diagrams for Maze3D Making a Maze Plan The User Interface Managing the Maze Scenery Creation Tiling the Floor Viewpoint Creation The Back Facing Camera Moving the Viewpoint The Bird's-Eye View Related Approaches to Scene Generation Chapter 26 Fractal Land Class Diagrams for the Fractal Land Building the Fractal Land Creating the Landscape Constructing the Ground Generating a Fractal Landscape Responding to Key Presses Terrain Following and Collision Avoidance Placing Objects in the Scene Other Fractal Landscapes Chapter 27 Terrain Generation with Terragen Class Diagrams for Terra3D Terragen Scenery Creation Building the Landscape Making 3D Scenery Adding Landscape Walls Creating Ground Cover Moving over the Surface Finding the Surface Height Accelerating Terrain Following More on Terrain Generation Chapter 28 Trees That Grow Class Diagrams for Trees3D Creating the Scene Building a Tree Limb Executing the Rules Displaying Leaves Comparison with L-Systems Chapter 29 Networking Basics The Elements of Network Communication The Client/Server Model The Peer-to-Peer Model Client/Server Programming in Java P2P Programming in Java Firewalls Other Kinds of Java Networking Chapter 30 Network Chat Threaded TCP Clients and Server UDP Multicasting Clients and a Name Server Clients Using a Servlet as a Server Chapter 31 A Networked Two-Person Game The Standalone Tic-Tac-Toe Game The Networked Tic-Tac-Toe Game Comparing NetFourByFour and FourByFour Chapter 32 A Networked Virtual Environment Background on NVEs An Overview of NetTour3D Scene Creation on the Client Defining Sprites Local Sprites Watching the Server Server Activities Other Java NVEs Appendix A Installation Using install4j install4j Versus JWS The Java 3D Components The BugRunner Application The Checkers3D Application Appendix B Installation Using Java Web Start JWS Benefits JWS Downsides The JNLP Deployment File Steps in Developing a JWS Application A JWS Installer for BugRunner A JWS Installer for Checkers3D Another Way to Install Checkers3D The JWS Portal Page Third-Party Certificates More Information Colophon About the Author Colophon Index jME graphics engine Kahlua OpenMind Xith3D scene graph viewing scene graphs background creating lighting viewing SceneGraphObject class ScoreClient class ScoreServer class SecondViewPanel class Selector class SeqSynth, extending Sequencer class ServerSocket class 2nd Shape3D class SharedGroup class Shooter3D (third-person) class diagrams for code for explosions rotating series of images, displaying FireBeam thread globals in repeated calculations gun, controlling laser beam shooting picking with mouse click intersections, finding picked object scene creation scene objects, picking what to pick shooting behavior cone rotation explosion facing the viewer picking debugging sounds problems with ShootingBehaviour class 2nd ShortMessage class ShowImage class showMsg( ) bug SimpleUniverse class Skeleton class SkinnedMesh class sleep( ) call accuracy of inaccuracy, handling of SleepAcc class Socket class SocketChannel class sound APIs Applet playing audio effects AudioClip class background music callbacks ClipsLoader formats copyrights of J2SE 5.0 short sound bug Java Sound API resources versus JMF, JOAL loading and playing preloading resources SoundPlayer application WAV bug sound effects examples, location of sound synthesis libraries sampled audio note names NotesSynth, extending playing notes synthesizing notes SoundsPanel class SoundsPanel constructor SoundsWatcher interface SourceDataLine class Sphere class spheres, floating coloring positioning Spotlight class Sprite class Sprite3D class sprites 3D animated common approaches keyframe animation 2nd animation framework animation loop finishing the game user interaction ball statechart specification translating ball textual specification bat statechart specification translating bat textual specification BugRunner class diagrams coding bounding box constructor drawing image updating statechart for translating to code StopWatch class StopWatchSource class strip file images, loading Stripifier class Sun Game Server SurfaceOfRevolution class swing timer SwingUtilities class synthesizer receiver port, MIDI messages to SysexMessage class Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] Terra3D class diagrams code for ground cover ground shape moving over what added where am I? landscapes building walls scenery 3D creation 2nd surface height HeightFinder picking terrain DEM following, accelerating generation Java 3D, other projects mesh decomposition ROAM threads Terragen landscaping tool extracting textures from TexCoordGeneration class Text2D class TexturedFloor class TexturedPlane class 2nd Thread class threaded animation double buffered drawing game termination local memory variables, preventing with volatile sleep necessity stopping threads synchronization concerns ThreadedChatServerHandler class ThreadedScoreHandler class 2nd tic-tac-toe elements, main networked game canvas, writing on class comparison to standalone client game initialization 2nd client game play client game termination code for player handlers 2nd playing top-level server two-person protocols standalone game class comparison to networked code for marker creation origins of picking and dragging representing the game scene creation TiledImage class TiledSprite class TilesList class TilesPriQueue class tiling software TimeBehavior class Timer class timer resolution (granularity) TimerRes class timers J2SE Java 3D bug alert non-J2SE resolution of TimerTask class TimeUnit class Tour3D behaviors in Java 3D class diagrams code for scene creation background image full-screen display obstacle creation scenery and obstacles, adding sprites alien 2nd basic 3D user's touring 2nd TourGroup class TouristControls class TouristInfo class TourServer class TourServerHandler class 2nd TourSprite class TourWatcher class 2nd TransformGroup class TransparencyAttributes class TreeLimb class 2nd Trees3D class diagrams code for L-systems comparison Java 3D and what to use leaves, displaying limbs color change leaves scaling sorting information on subgraph creation rule execution scene creation growth leaves transparency depth-sorting TriangleArray class TriangleStripArray class TurnStile class Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] UninstallAction class UPS (updates per second) utility timer Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] Viewer class ViewerAvatar class viewers movement positioning ViewingPlatform class ViewPlatformBehavior class volatile, preventing local memory variables VolatileImage class VolChanger class VRAM information on VolatileImage objects in Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] WakeupCondition class WakeupOnAWTEvent class WakeupOnElapsedFrames class WakeupOnElapsedTime class WAV bug WormChase (AFS) class WormChase (FSEM) class WormChase (UFS) class WormChase class WormChase game full-screen 80-85 FPS OS timings AFS approaches code for FSEM worm UFS worm window and applet applet application information application timing, OS class diagrams class reuse code for considerations game panel J2SE 5.0 compilation obstacles speed testing timer choice worm information, storing WormChaseApplet class WormPanel class WrapAnimTour3D class WrapCheckers3D class WrapCheckers3D JPanel WrapFlocking3D class WrapFourByFour class 2nd WrapFractalLand3D class WrapLoader3D class WrapLoaderInfo3D class WrapMaze3D class WrapMover3D class WrapNetFBF class WrapNetTour3D class WrapShooter3D class WrapTour3D class WrapTrees3D class Index [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] Xith3D screen graph API ... Why Java for Games Programming? Java Is Too Slow for Games Programming Java Has Memory Leaks Java Is Too High-level Java Application Installation Is a Nightmare Java Isn't Supported on Games Consoles... The A*-Based Alien Sprite Storing Tile Details Further Reading Chapter 14 Introducing Java 3D Java 3D Java 3D Strengths Criticisms of Java 3D for Games Programming Alternatives to Java 3D Chapter 15... The Peer-to-Peer Model Client/Server Programming in Java P2P Programming in Java Firewalls Other Kinds of Java Networking Chapter 30 Network Chat Threaded TCP Clients and Server UDP Multicasting Clients and a Name Server