|
|
|
|
| Preface
|
|
|
| About the Author
|
|
|
| About the Contributing Authors
|
|
|
| About the Technical Reviewers
|
|
|
| Acknowledgments
|
|
|
| Introduction
|
|
|
| Why Java?
|
|
|
| What You Need
|
|
|
| What Is in this tutorial
|
|
|
| What's Not in this tutorial
|
|
|
| About the Code in this tutorial
|
|
|
| Using Ant
|
|
|
| Summary
|
|
|
| Part I. Java Game Fundamentals
|
|
|
| 1. Java Threads
|
|
|
| What Is a Thread?
|
|
|
| Creating and Running Threads in Java
|
|
|
| Synchronization
|
|
|
| Using wait() and notify()
|
|
|
| The Java Event Model
|
|
|
| When to Use Threads
|
|
|
| When Not to Use Threads
|
|
|
| Sum It Up: Thread Pools
|
|
|
| Summary
|
|
|
|
| 2. 2D Graphics and Animation
|
|
|
| Full-Screen Graphics
|
|
|
| Images
|
|
|
| Getting Rid of Flicker and Tearing
|
|
|
| Simple Effects
|
|
|
| Summary
|
|
|
|
| 3. Interactivity and User Interfaces
|
|
|
| The AWT Event Model
|
|
|
| Keyboard Input
|
|
|
| Mouse Input
|
|
|
| Mouselook-Style Mouse Movement
|
|
|
| Creating an Input Manager
|
|
|
| Using the Input Manager
|
|
|
| Designing Intuitive User Interfaces
|
|
|
| Using Swing Components
|
|
|
| Creating a Simple Menu
|
|
|
| Letting the Player Configure the Keyboard
|
|
|
| Summary
|
|
|
|
| 4. Sound Effects and Music
|
|
|
| Sound Basics
|
|
|
| The Java Sound API
|
|
|
| Playing a Sound
|
|
|
| Creating a Real-Time Sound Filter Architecture
|
|
|
| Creating a Real-Time Echo Filter
|
|
|
| Emulating 3D Sound
|
|
|
| Creating a Sound Manager
|
|
|
| Playing Music
|
|
|
| Summary
|
|
|
|
| 5. Creating a 2D Platform Game
|
|
|
| Creating a Tile-Based Map
|
|
|
| Collision Detection
|
|
|
| Finishing Things Up and Making It Fast
|
|
|
| Creating an Executable .jar File
|
|
|
| Ideas to Expand the Game
|
|
|
| Summary
|
|
|
|
| 6. Multi-Player Games
|
|
|
| The Revolution in Java's I/O Libraries
|
|
|
| ChatterBox, A Basic Multi-Player app
|
|
|
| Multi-Player Game Server Framework
|
|
|
| A Sample Game: RPS (Rock, Paper, Scissors)
|
|
|
| Complete the Look: Building on the Framework
|
|
|
| Server Administration
|
|
|
| Advanced Topics
|
|
|
| Summary
|
|
|
|
| Part II. 3D Graphics and Advanced Techniques
|
|
|
| 7. 3D Graphics
|
|
|
| Types of 3D Rendering
|
|
|
| Don't Forget Your Math
|
|
|
| 3D Basics
|
|
|
| 3D Math
|
|
|
| Polygons
|
|
|
| 3D Transforms
|
|
|
| A Simple 3D Pipeline
|
|
|
| Camera Movement
|
|
|
| Solid Objects and Back-Face Removal
|
|
|
| Scan-Converting Polygons
|
|
|
| 3D Clipping
|
|
|
| Final Rendering Pipeline
|
|
|
| Summary
|
|
|
|
| 8. Texture Mapping and Lighting
|
|
|
| Perspective-Correct Texture Mapping Basics
|
|
|
| A Simple Texture-Mapper
|
|
|
| Optimizing Texture Mapping
|
|
|
| Simple Lighting
|
|
|
| Implementing Texture Lighting
|
|
|
| Advanced Lighting Using a Shade Map
|
|
|
| Additional Concepts
|
|
|
| Summary
|
|
|
|
| 9. 3D Objects
|
|
|
| Hidden Surface Removal
|
|
|
| 3D Animation
|
|
|
| Polygon Groups
|
|
|
| Loading Polygon Groups from an OBJ File
|
|
|
| Game Objects
|
|
|
| Managing Game Objects
|
|
|
| Putting It All Together
|
|
|
| Future Enhancements
|
|
|
| Summary
|
|
|
|
| 10. 3D Scene Management Using BSP Trees
|
|
|
| BSP Tree Intro
|
|
|
| Binary Tree Basics
|
|
|
| The One-Dimensional BSP Tree
|
|
|
| The Two-Dimensional BSP Tree
|
|
|
| Implementing a 2D BSP Tree
|
|
|
| Drawing Polygons Front to Back
|
|
|
| First BSP Example
|
|
|
| Drawing Objects in the Scene
|
|
|
| Loading Maps from a File
|
|
|
| Putting It All Together
|
|
|
| Enhancements
|
|
|
| Summary
|
|
|
|
| 11. Collision Detection
|
|
|
| Collision Basics
|
|
|
| Object-to-Object Collisions
|
|
|
| Object-to-World Collisions
|
|
|
| Basic Collision-Detection Demo
|
|
|
| Collision Handling with Sliding
|
|
|
| Collision Detection with Sliding Demo
|
|
|
| Enhancements
|
|
|
| Summary
|
|
|
|
| 12. Path Finding
|
|
|
| Path-Finding Basics
|
|
|
| Some Initial Path-Finding Attempts
|
|
|
| Basics of the A* Algorithm
|
|
|
| Applying the A* Algorithm
|
|
|
| Using the A* Algorithm with a BSP Tree
|
|
|
| Generic Path Finding
|
|
|
| Making a PathBot
|
|
|
| Enhancing the A* Search
|
|
|
| Summary
|
|
|
|
| 13. Artificial Intelligence
|
|
|
| AI Basics
|
|
|
| Take Away Those Godlike Powers!
|
|
|
| State Machines and Reacting
|
|
|
| Probability Machines
|
|
|
| Making Decisions
|
|
|
| Patterns
|
|
|
| Object Spawning
|
|
|
| Putting It All Together
|
|
|
| Evolution
|
|
|
| Other Game AI Ideas
|
|
|
| Summary
|
|
|
|
| 14. Game Scripting
|
|
|
| Scripting Cookbook: What You Need
|
|
|
| Implementing Touch and Release Notifications
|
|
|
| Game Object Listeners
|
|
|
| Scripting
|
|
|
| Delayed Events
|
|
|
| Putting It All Together
|
|
|
| Enhancements
|
|
|
| Summary
|
|
|
|
| 15. Persistence-Saving the Game
|
|
|
| Game-Saving Basics
|
|
|
| Using Java's Serialization API for Game State Persistence
|
|
|
| Creating Game Screen Snapshots
|
|
|
| Saving Games to the Right Destination
|
|
|
| Summary
|
|
|
|
| Part III. Tuning and Finishing Your Game
|
|
|
| 16. Optimization Techniques
|
|
|
| Optimization Rules
|
|
|
| Profiling
|
|
|
| HotSpot
|
|
|
| Optimization Tricks
|
|
|
| Memory Usage and the Garbage Collector
|
|
|
| Perceived Performance
|
|
|
| Summary
|
|
|
|
| 17. Creating Game Art and Sounds
|
|
|
| Choosing a Look and Feel
|
|
|
| Getting Royalty-Free Game Media
|
|
|
| Working with Artists and Sound Effect Engineers
|
|
|
| Tools
|
|
|
| Creating Sounds
|
|
|
| Creating Textures and Sprites
|
|
|
| Creating Splash Screens and HUD Graphics
|
|
|
| Creating UI Graphics
|
|
|
| Creating Your Own Fonts
|
|
|
| Summary
|
|
|
|
| 18. Game Design and the Last 10%
|
|
|
| The Last 10%
|
|
|
| Elements of Game Design
|
|
|
| Creating a Map Editor
|
|
|
| Debugging
|
|
|
| Protecting Code
|
|
|
| Game Deployment
|
|
|
| Game Deployment with Java Web Start
|
|
|
| Game Deployment with Native Compilation
|
|
|
| Updates and Patches
|
|
|
| Bandwidth Issues
|
|
|
| Getting Feedback and Beta Testing
|
|
|
| Making Money
|
|
|
| Putting It All Together
|
|
|
| Summary
|
|
|
|
| 19. The Future
|
|
|
| How Java Evolves
|
|
|
| The Future: Java 1.5 "Tiger"
|
|
|
| What the Java Platform Needs
|
|
|
| New Devices and the Java Games Profile (JSR 134)
|
|
|
| Summary
|
|
|
|
| Index
|