... Project, Add Files to Project, Files.
Now let’s compile our first project.
1. Fire up your Visual C+ + configured development environment.
2. Click on Open Workspace.
3. Choose basics.dsp.
4. Check ... objects, which now are set directly by calling the methods of
IDirect3DDevice7
. Direct3D 7 dropped the special interface used in Direct3D 6 to access tex-
tures. The
IDirect3DDrawSurface7
interface ... interface to help you accomplish this.
3D Textures
With 3D volumetric textures, you can accomplish exact per-pixel lighting effects, point- and
spot-light effects, and atmospheric effects.
Direct3DX...
... Direct3D/DirectX Graphics game for the PC, including:
•3D graphics and algorithms
• Gameprogramming techniques and data structures
•Using 3D files to construct game worlds
Programming your own character ... character engine with a character animation system
• DirectX Graphics programming
• And more!
xxi
Introduction
Beginning
Direct3D
®
Game
Programming
2
nd
Edition
Chapter 3
Programming Conventions . . ... Tochter Anja
Beginning
Direct3D
®
Game
Programming
2
nd
Edition
Wolfgang F. Engel
which features advanced shader programming material by 27 authors. The tremendous
success of Beginning Direct3D...
... Events
Event Code Explanation
CLICK function btnpress(myevent:MouseEvent): void {
trace("you clicked me");
}
myBtn.addEventListener(MouseEvent.CLICK,btnpress);
Happens when
the mouse is
clicked ... a rectangle changing color from blue to orange.
7. Lock the Background layer. Now move to the Objects layer. In frame 1, create two objects: a
gray half circle for the moon and a yellow circle ... Masking.
Notice the mask.
Figure 4.19
After Masking.
xscale Specifies the x scale (percentage from 0 to 1) for the movie clip
yscale Specifies the y scale (percentage from 0 to 1) for the movie clip
width...
... subtraction or even a while
loop. No, no, no. I wanted recursion.
Name: CCC .C
#include <stdio.h>
int string_count(char *s)
{
int count = 1;
if(*s++)
count += string_count(s);
else
count ... source code into your editor, or Shift+click this link to
download the source code. This is a subtle modification of the original
DOSVER .C program (which you can download if you Shift+Click ... I.
Machine language consists of codes, often one- or two-byte instructions
that tell the microprocessor to do something: access memory, compare
must never change:
first = (struct pres...
... the process of building the game, I show you how to make
a game change according to players’ actions.
State of Nonconfusion
The states of an game are like the scenes of a movie. Each movie scene
describes ... 29
xv
Table of Contents
Part VI: The Part of Tens 341
Chapter 14: Ten Math Concepts for Game Programmers . . . . . . . . .343
Managing Velocity 343
Accelerating an Object 344
Calculating a Distance 344
Projecting ... punctuation and other special
characters. These characters often have a
special meaning that could cause you prob-
lems. For example, the asterisk (
*) charac-
ter is sometimes used as a wildcard
character,...
... If Circle is outside box limits, add to distance.
If CircleCenterZ < Me.MinZ Then
Dist += Math.Sqr(CircleCenterZ - Me.MinZ)
Else
If CircleCenterZ > Me.MaxZ Then
Dist += Math.Sqr(CircleCenterZ ... ways to calculate
proximities for circles and between circles and squares.
The basic idea behind such algorithms is to calculate the distance between
the centers of two objects, and then check the ... that can be
approximated by circles.
Figure 1-13. Circle proximity
When dealing with circular objects, you achieve a perfect calculation using
the Pythagorean Theorem, which allows you to calculate...
... methods.
Game Loop
Most of the game processing occurs inside the game loop. Here, the game checks if there is
player input to process, the game characters’ artificial intelligence is calculated, ... the location in which your project will be created.
You’re free to change this location to another directory of choice. Click OK to create a
new game project named WindowsGame1.
3. Once the ... to do the correct calculations—for example, to
calculate the correct position for the game components according to their speeds in the game.
Let’s take a closer look at the GameTime class properties:
ElapsedGameTime:...
... languages.
4 Chapter 1
n
Welcome to the Dungeon
chapters), and the player can choose from several character classes. Good non-
player characters (NPCs) also help the player to successfully complete the
game s ... C# , Basic, Java,
DirectX, Allegro, Lua, DarkBasic, Pocket PC, and game consoles. He is the author
of the recent books Beginning Java SE 6 Game Programming, Third Edition;
Visual Basic GameProgramming ... 500);
rand = new Random();
//create a new picturebox
pb = new PictureBox();
pb.Parent = this;
pb.Dock = DockStyle.Fill;
pb.BackColor = Color.Black;
//create graphics device
surface = new Bitmap(this.Size.Width,...
... industry conferences, including the Game Developers’ Conference. He
received his bachelor’s degree in Computer Science from the University of Utah, where he
specialized in graphics, artificial intelligence, ... Graphics group at Qualcomm, Inc. He is the
cofounder and executive producer of GameDev.net, the leading online community for
game developers. He has authored or contributed to several gamedevelopment ... artificial intelligence
■
Networking
■
User interface and menuing system
Each of these areas can be further divided into more specific systems. For example, game
logic would consist of physics and...
... Visual C+ + .NET configured development environment.
2. Click on Open Solution.
3. Choose basics.sln.
4. Check whether you’ve configured the paths to the directories as described previously.
5. Choose ... dialog box.
The include file directories are C: \dxsdk\include and C: \DXSDK9\Samples \C+ +\Common\
Include. You should point your Visual C+ + .NET IDE to these directories by clicking on the
New button ... of
IDirect3DDevice7. Direct3D 7 dropped the special interface used in Direct3D 6 to access tex-
tures. The IDirect3DDrawSurface7 interface also provided an easier way to manage the textures.
DirectX...
... endeavoring to master. Games are as
much works of art as they are grand technical achievements. Many technically
fantastic games go unnoticed and unappreciated, while less technically savvy
games go on ... E. Caudill
Executive Producer
Firaxis Games
2K Games
Take 2 Interactive
vi Foreword
Beginning Game
Programming
Second Edition
Jonathan S. Harbour
intervening years, DirectX has grown to become ... source code file (at least until we build the game framework), but most real
games have many source code files. You might have source code files for your
Direct3D routines, DirectInput code, DirectSound...
... MyRegisterClass(HINSTANCE);
LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);
//the window event callback function
LRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hdc;
char ... properties
GetObject(image, sizeof(BITMAP), &bm);
//create a device context for the bitmap
hdcMem = CreateCompatibleDC(global_hdc);
SelectObject(hdcMem, image);
//draw the bitmap to the window (bit block ... nostalgic.
The GameLoop Project 73
void Game_ Run()
{
//this is called once every frame
//do not include your own loop here!
intx=0,y=0;
RECT rect;
GetClientRect(global_hwnd, &rect);
if (rect.right...