DirectX University Project

0

As advertised, here is an executable version of the DX/C++ project I worked on at University. It is a small space ‘game’, or rather the beginning of one. The task was to create a simple game using the DXUT framework. It included procedural terrain generation, working with vertex and index buffers, HLSL shaders, particle effects, movement and collision detection. Originally the player was to be in a stationary turret, firing on enemies that would spawn at random positions and fly across the terrain, but that wasn’t interesting enough for me, so I modified it a bit.

The terrain is created using the Diamond-Square algorithm, but I use a vertex shader to bend the terrain into a sphere by simply reading the cartesian coordinates as spherical coordinates and converting them back to cartesian coordinates for rendering, since the formula for a plane in cartesian coordinates is the same as the one for a sphere in spherical coordinates. I added additional spheres for the clouds and the atmosphere, together with a fresnel shader to render the atmosphere. Also I create the diffuse texture for the planet in its shader instead of writing it into a texture, so I can tile it to higher resolutions without breaking the universe in the process. The blending of the different terrain types is done via the height stored in the heightmap and the derivation of these values.

I added gravity and newtonian movement to control the camera’s position, so it feel like the player is flying a spaceship around the planet, but I had to modify the DXUT camera code a bit to make it work. The camera had problems when the camera’s z-axis coincided with the world’s up-axis. The movement itself is a simple Euler method, using the camera’s local coordinate system to construct a velocity vector.

Instead of enemies that fly a straight path, I spawn battleships around the planet which fire missiles towards it (both are custom models by me). The player has to intercept the missiles and destroy the battleships. All collisions are calculated using a simple distance test, so the objects are spherical internally. There is no collision between the player and the enemies/missiles, yet.

In addition to the alpha blended shader for the particles, I wrote an additive shader, so I can spawn lots of sprites without having to sort them each frame (sorting is evil). I use the additive shader for the missiles’ exhausts and explosions and the alpha blended one for the projectiles (since the alpha blended shader was required for the assignment).

There is no win- or lose-state yet, so it is a bit premature to call it a game. The enemies will respawn constantly and the planet is not damaged by the missiles, but you can fly around and destroy both the enemy ships and the missiles. I also added some ‘cheats’ that allow you to freeze everything but the player’s movement, spawn enemies or enable/disable the skybox (also one to stop the frame buffer from being cleared before rendering the next image, to demonstrate something to my Professor).

But enough text for now. Play it!

Comments

Your email address will not be published. Required fields are marked *