Direct3D (DirectX 8.1) Code Samples - Page 6

Solid Node BSP Tree Compiler
 

One method of speeding up a game engine is to use a BSP-Tree (Binary-Space Partitioning Tree) to subdivide and sort your game's world geometry.

This is done by dividing up, sorting, and storing polys in a BSP Tree in a such as way as to denote their relationship to one another (i.e. being in front of or in back of another poly). Once the BSP tree is compiled or built, the engine can quickly decide whether or not it should render certain polys based on the view’s current location within the world.

For example, the BSP compiler in this sample demonstrates how early game programmers, who didn't have hardware accelerated z-buffers, used a simple solid-node style BSP tree to sort their scene polys into a back-to-front order for proper rendering. The sample also demonstrates how a BSP Tree can be used for collision detection by identifying whether or not a unobstructed line-of sight can be established between two 3D points.

Unfortunately, the code doesn't go into a lot of BSP Tree theory or teach the basics, so if you're new to the concept of a BSP Tree, check out this cool little Java Applet for a real-time demonstration of how they work.

This sample is based on one of the BSP demos that came with the "Advanced 3D BSP, PVS and CSG Techniques" course offered at GameInstitute.com. If you're truly interested in learning about BSP trees and how they're used in games, this course is the best by far and I highly recommend it.

Check out the OpenGL source code page for the OpenGL equivalent of this sample.

 

Sprite Animation Through Surface Blitting
 

This bare bones introduction to sprite animation is a good to place to start for those who want to write 2D games and already have a general understanding of DirectX. It creates animated 2D sprites by performing bit-block transfers, or 'blitting', from one DirectDraw surface to another.

 

Sprite Class with Test Program
 

This was the test application I used to error check and debug my sprite class which I use in most of my 2D games, including the 2D side-scroller sample above. It animates a series of sprites which are based on some bitmaps I stole from the DirectX 8.0 SDK.

 

Xena Puzzle Game
 

This is one of my early puzzle games that I wrote using DirectX 5.0. which I later converted over to DirectX 7.0.

 

2D Demo Game of a Side-Scrolling Shooter
 

Re-live such classic side-scrolling shooters as Gradius and R-Type by writing your own. Of course, this sample is a far cry from a fully featured side-scroller, but it will definitely put you on the right track.

 

The DirectX Grab Bag
 

Well, I'm too lazy to write a descriptive paragraph for all the samples I've written, so I'll just clump them together in a big "grab bag" and let you have 'em! This download contains numerous samples dealing with everything from capturing the keyboard, mouse, and joysticks with DirectInput to mode-switching and directly manipulating a DirectDraw surface at the pixel level.