《Delphi图形和游戏编程突破》
Delphi 教程 系列书籍 (075) 《Delphi图形和游戏编程突破》 网友(邦)整理 EMail: shuaihj@163.com
下载地址:
- by John Ayres
- Wordware Publishing, Inc.
- ISBN: 1556226373 Pub Date: 12/01/99
内容简介
In the beginning, there was darkness. In this Age of Innocence, the unwashed masses practiced the art of
entertainment with small pieces of paper bearing symbolic images of kings, queens, and jesters. Sometimes,
they used minute pieces of metal and plastic, shaped like various real-world objects, moving them about on
large, colored cardboard sheets in accordance with the runes inscribed upon small white cubes. To the casual
observer, all was content, but in the minds of the newest generation born of this age, there was a yearning for
more. Unbeknownst to the world, this yearning grew, and soon these young pioneers began working in the
dark recesses of colleges and universities to bring about a change that would alter the course of history in
ways no learned scholar could have ever imagined. Brandishing vacuum tube sabers and using arcane words
of power such as RAM, ROM, Bit, and Byte, these acolytes of technology brought forth a new creation
known as the Computer. But, their new creation was naive, and lacked intelligence or sophistication; to
control it, they had to use a mystical, magical language known as Code. Thus, the Art was born, and a new era
had begun.
The First Age was marked by the genesis of immense, hulking beasts that required enormous resources to
sustain life. These new life forms were rare, but typically stood several stories tall and required incredible life
support systems to maintain an agreeable environment. These giants were moody and possessed little
intelligence, but through great effort, they could be trained to perform incredible feats, for their day. The
digital landscape was dotted with few of these behemoths, and their trainers were monk-like in their
dedication. Unable to break free of their confines due to the immense size of their charges, these monks were
forced to toil maddeningly long hours. Their torturous task of preparing the vegetarian meal of holy leaves
consumed by these monsters had them working late into the night, and the Art required to create these holy
leaves was arcane indeed.
These monks practiced the great Art in the same dark recesses from whence it was conceived, and the Art
grew. The once young pioneers had become pedantic, wizened old masters. These old wizards were still
rebellious and, yearning for a new form of entertainment, they used the Art in ways that the Powers That Be
felt were unproductive. Away from the watchful eyes of their overseers, they shaped the Art in ways that
previously existed only in their dreams.
In the dark hours of the morning, these masters used the Art to coax the new creations into providing their
long-sought-after entertainment, and they played games such as Tic-Tac-Toe and Pong. Several of these
wizards used the Art to create much more sophisticated forms of entertainment, and played games such as
Checkers and Chess with their silicon automatons. In the wake of the First Age, walking in the shadow of the
evolving Art, a new form of the Art began to grow.
Like dinosaurs, the reign of these behemoths was relatively short-lived. A new catalyst known as the
Corporation had used the knowledge learned in the First Age to effect an evolutionary step known as the
Home PC. Thus, the Second Age began.
In the Second Age, the pantheon of overlord gods began to form, controlling the evolution of this new
creation from on high. Deities known as Gates and Jobs worked their mystical creation power behind the
curtains of reality, but their new creations were protozoan in nature. A step back from their massive
predecessors, these new single-cell machines were much less sophisticated and powerful, and teetered on the
edge of extinction almost as soon as they had appeared. However, these new creatures had become visible to
the unwashed masses, and began to elicit their attention. At first, few of the Untrained could afford to adopt
one as a pet, but their popularity grew, and soon many of these creations made their homes on desktops in
homes and businesses. The Art, still arcane in nature, had begun to emerge from its dark recesses, and several
of the Untrained began to delve into its mystical powers.
The Net, the once-dark netherworld populated solely by the wizards and masters of the Art, has now become a
tourist attraction, replete with amusement parks, rest stops, and gift shops. Rumors of new CPUs with speeds
in excess of 1,000 MHz are being whispered in the dark corners of cyber cafÈs and coffee shops. Thus, we
stand at the dawn of yet another New Age. As the sun breaks over the distant horizon, its golden, shimmering
rays cascading over the silicon juggernaut that stands before us, the prospects of the future are at once both
exciting and frightening.
Thus, our journey begins.
目录
CHAPTER 1—The Lure of Game Programming
The Dark Side of the Game Programming Industry
Difficult Learning Curve
Long Hours
Corporate Instability
The Light Side of the Game Programming Industry
Fun and Rewarding
Fame and Fortune
The People
Game Programming, In Delphi?
Delphi as a Games Development Platform
Opportunities
Untapped Markets
Types of Games
Real-Time Strategy
Turn-Based Strategy
First-Person Shooters
Adventure Games
Action Games
Puzzle Games
Sports Games
Board and Card Games
Simulations
Windows, Delphi, and Games
Summary
CHAPTER 2—The Anatomy of a Game
Game Dissection: The Vital Organs
Graphics
Sound
User Input
Real-Time Event-Driven Programming
Basic Game Architecture
Initialization
Introduction
Game Startup
The Game Loop
Game Ending
Shutdown and Exit
The Game Loop
Retrieve User Input
Perform Antagonist AI and Other Game Logic
Update Sprite Positions
Check for Collisions
Start Sound Effects
Start Music
Render the Next Frame
Check for Game End
Speed Delay
Game States
The Demo State
The Playing State
The Intermission State
The Paused State
The Game Over State
Case Study
Summary
CHAPTER 3—Basic Graphics Programming
The Graphical Device Interface
Graphical Elements
Pixels
Lines
Polygons
Bitmaps
Graphical Element Classifications
Video Mode Resolutions and Color Depth
Resolution
Color Depth
Video Board Memory
The Components of a Color
Palettized Modes
Non-palettized Modes
Graphics Output Techniques
The Device Context
Painting on the Canvas
Bitmap Essentials
Bitmap Types: DDB and DIB
The TBitmap Object
Raster Operations
Simulating Transparency
Palettes
Logical vs. System Palettes
Using a Palette
Further Adventures in Windows Programming
Summary
CHAPTER 4—An Introduction to DirectX
What is DirectX?
The Promise of DirectX
Benefits and Drawbacks of DirectX Programming
The DirectX Architecture
DirectX Components
DirectX and Delphi
The DirectX SDK
Project JEDI
Other Components and Headers
A DirectDraw Tutorial
Features
Functional Overview
COM Fundamentals
Surfaces
Page Flipping
Resolution, Color Depth, and Video Memory
Windowed Versus Full-Screen
Initializing DirectDraw
Rendering with GDI
Flipping the Surfaces
Displaying Bitmaps
Surface Memory Location
Loading and Displaying the Bitmap
Blitting Surfaces
Lost Surfaces
Retrieving DirectDraw Capabilities
The DirectX Baseline Application
DirectX Result Codes
Retrieving the DirectX Version
Summary
CHAPTER 5—Palettes
What is a Palette?
The IDirectDrawPalette Object
Creating the Palette Object
Defining Palette Colors
Using the Palette Object
Disconnecting Palettes
Palettes and GDI Functions
Palette Animation
Animating the Palette
Screen Transitions
Summary
CHAPTER 6—Sprite Techniques
The Illusion of Animation
Constructing the Animation Frames
Producing the Animation
The Illusion of Motion
Sprite Attributes
The Animation Cycle
Transparency Issues
Color Keying
Pixel Checking
Collision Detection
Bounding Boxes
Pixel Overlap Comparison
Animation Issues
Timing
Z-Order
Summary
CHAPTER 7—Input Techniques
Human/Computer Interaction
Input Devices
Input Considerations
DirectInput
Features
Functional Overview
Initializing DirectInput
Retrieving Input Data
Keyboard Input
Mouse Input
Game Controller Input
Summary
CHAPTER 8—Force Feedback
Features
Functional Overview
Basic Concepts
Kinetic Force
Condition
Magnitude
Coefficient
Duration
Sample Period
Gain
Axes
Direction
Envelope
Force Feedback Effects
Base Effect Structure
Creating Effects
Create and Acquire the DirectInput Device
Query for Force Feedback Support
Initialize a TDIEffect Structure and the Type-Specific Parameters Structure
Create the Effect Object
Download the Effect
Start the Effect
Stop the Effect
Case Study
Additional Effect Considerations
Retrieving Effect Status
Retrieving the Force Feedback System State
Sending Commands to the Force Feedback System
Modifying an Effect at Run Time
Envelopes
Summary
CHAPTER 9—Sound and Music
Sound Effects
Simplistic Sound Effects
DirectSound
Music
MCISendCommand
MIDI
CD Audio
Summary
CHAPTER 10—Optimization Techniques
Optimization Theory
Timing Code
Examining the Algorithm
Effective Optimization
Delphi-Specific Optimization Techniques
Automatic Compiler Optimizations
Additional Compiler Optimizations
Other Delphi-Specific Optimization Techniques
General Optimization Techniques
Loop Unrolling
Lookup Tables
Binary Bit Shifting
Additional Optimization Considerations
Summary
CHAPTER 11—Special Effects
Bitmap Manipulation
Bitmap Transformations
Scaling
Rotation
Lighting Tricks
Transition Effects
Simple Texture Mapping
Dynamic Images
Star Fields
Fire
Summary
CHAPTER 12—Artificial Intelligence Techniques
Movement
Random Movement
Aggression/Evasion
Patterned Movement
Finite State Machines
Probability Machines
Path Finding
Algorithms
Basic Implementation
Back Stepping
Case Study
Enhancements
Summary
CHAPTER 13—Putting It All Together
Delphi Blocks
General Game Architecture
Player Advancement
Game States
User Input
Sound and Music
Graphics
Enhancements
The Case Study Code
Summary
Appendix A
Glossary
Bibliography
Index