C++/CX DirectX : Simple Shooter architecture all in one place

This is from a presentation I did today at UCLA, I will put together a video to explain the whole thing.

This is just a presentation that depends heavily on the material at theseURL links:

Windows 8 and VS 2012:

https://code.msdn.microsoft.com/DirectX-3D-shooting-game-d9e47118?SRC=VSIDE

Windows 8.1 and VS 2013 RC:

https://code.msdn.microsoft.com/Metro-style-DirectX-18f98448?SRC=VSIDE

 

The DirectX Shooter game sample uses this architecture for it’s game engine. It is a simple process and one that you could learn, then memorize and never use again. But it would a basis of what you would create. (Click on image to enlarge it) Make to scroll down to see all of the discussion image

Audio

Audio.cpp/.hDefines the audio object used to mix and play music.

MediaReader.cpp/.hProvides methods for reading the PCM audio streams.

SoundEffect.cpp/.hProvides methods for the mixing and playback of sound effects.

image

Input

This is not included in the FruitBurst example but is used in the MarbleMaze and Simple Shooter game

• MoveLookController:

  • This is the class that handles input events and turns it into player intent. It aggregates, mouse, keyboard, touch and Xbox controller input into a unified single controller.

• The controller has three modes of operation:

  • None - the controller is not active and all input is ignored

• WaitForInput

  • The controller is waiting for the player to acknowledge a message from the app.

WaitForPress

  • Only a left mouse click or touch event in the rectangle specified in the WaitForPress method
  • 'Start' button has been pressed on the Xbox controller will result in IsPressComplete returning true.

• Active

  • The controller is in active game play mode.

image

GameObjects

Animate.cpp/.h

• Provides the calculations for the animation of the moving targets and pillar obstacles in the game.

Camera.cpp/.h

• Provides an implementation of a 3-D camera view of the scene, and the 2-D projection of it.

Cylinder.cpp/.h

• Defines a specific implementation of the GameObject class for cylinders.

• This includes a method that determines the point of intersection between a sphere (the ammo) and cylinder.

Face.cpp/.h

• Defines a specific implementation of the GameObject class for a rectangular flat surface (the "face").

• This includes a method for determining the point of intersection between a sphere (ammo) and the surface.

• The class is used for targets.GameConstants.hDefines a number of common constants used throughout the game.

GameObject.cpp/.h

• Defines the behaviors of the in-game object graphic primitives, including placement, movement, and collisions.

Sphere.cpp/.h

• Defines a specific implementation of the GameObject class for spheres. This includes a method for determining the point of intersection between two spheres. The class is used to represent the ammunition in the game.

image

Meshes

CylinderMesh.cpp/.h

• Defines a specific implementation of the MeshObject class used to create the mesh for cylinder game objects.

FaceMesh.cpp/.h

• Defines a specific implementation of the MeshObject class used to create the mesh for rectangular target game objects.

MeshObject.cpp/.h

• Defines the general class for graphics mesh primitives. These primitives are defined by a D3D11 vertex buffer and index buffer, as well as the virtual method to render these primitives.

SphereMesh.cpp/.h

• Defines a specific implementation of the MeshObject class used to create the mesh for spherical ammo game objects.

WorldMesh.cpp/.h

• Defines a specific implementation of the MeshObject class used to create the meshes for the world environment.

image

GameLevels

Level.cpp/.h

• Defines an abstract class containing information about game levels.

Level[1-6].cpp/.h

• Defines the attributes and objectives for each game's six levels. This includes the time limit for completing the level, as well as the animation, timing, position, and total number of the targets and obstacles in the level.

image

Rendering

ConstantBuffers.h

• Defines the D3D 11 Constant buffers used to control the graphics rendering.

DirectXBase.cpp/.h

• Provides a basic renderer that includes the Direct3D device and swap chain, and the Direct2D factory and device.

• It includes handling stereo and pre-rotation of swap chains for better rendering performance. This class is important!

GameHud.cpp/.h

• Defines the Heads Up display for current scoring.

GameInfoOverlay.cpp/.h

• Defines the 2D overlay that contains the heads-up display elements for the level instructions and score info.

GameRenderer.cpp/.h

• Defines a specific implementation of DirectXBase tailored to the specific needs of this game, including methods for asynchronous creation of game and level device-specific resources.

Material.cpp/.h

• Defines the material properties of objects. This includes the object color, specular highlight color, textures and shaders used to render the object.

StereoProjection.cpp/.h

• Provides helper code that creates the projection matrices for the 3-D stereoscopic projection. These methods are called in Camera.cpp.

TargetTexture.cpp/.h

• Defines the methods used to create the concentric circle bitmaps for the targets.

image

Shaders

ConstantBuffers.hlsl:

• Defines the Direct3D 11 constant buffers used by HLSL to control graphics rendering. This file is paired with ConstantBuffers.h.

PixelShader.hlsl

• Contains the HLSL code for the common pixel shader used for most game object rendering. It includes per pixel lighting for specular highlights.

PixelShaderFlat.hlsl

• Contains the HLSL code for the pixel shader used for the game world objects. It does much simpler shading and doesn't include any specular light effects.

VertexShader.hlsl

• Contains the HLSL code for the common vertex shader used for most game object rendering. It's paired with PixelShader.hlsl

VertexShaderFlat.hlsl

• Contains the HLSL code for the vertex shader used for the game world objects. It does much simpler shading and lighting. It's paired with PixelShaderFlat.hlsl

image

Utilities

BasicLoader.cpp/.h

• Provides methods for loading assets, such as textures, from disk.BasicMath.h

• Defines some simple types that represent vectors and matrices, and the mathematical operations that can be performed on them. This sample uses DirectXMath instead of these math functions.

BasicMath.h

Defines some simple types that represent vectors and matrices, and the mathematical operations that can be performed on them. This sample uses DirectXMath instead of these math functions.

BasicReaderWriter.cpp/.h

• Provides methods for reading and writing data synchronously and asynchronously.BasicShapes.hDefines a set of basic 3-D graphic primitives, such as cubes and spheres.

BasicShapes.h

Defines a set of basic 3-D graphic primitives, such as cubes and spheres.

DDSTextureLoader.cpp/.h

• Provides a method for loading a DDS texture and creating a Direct3D 11 runtime resource for it.

DirectXSample.h

• Defines an exception handling method used in the Windows Store DirectX samples.

GameTimer.cpp/.h

• Defines a high-resolution game clock object.

PersistentState.cpp/.h

• Provides a set of methods for saving and loading various scalar and complex type values to and from a configured storage location.

image

pch.h

To use pch.h you would add your header files there and make sure to include pch.h in each of your source (cpp) files

image
TaDaa