Use the WDC DirectX game learning template

[ This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation ]

The Windows Developer Content DirectX game learning template sample extends the basic DirectX app template sample to add features that assist you in understanding DirectX and C++ as a game development environment. These topics show you how to use this code as a launch point into your own game projects.

The WDC simple game template adds the following features to the DirectX app template:

  • An overlay manager class (OverlayManager) that enables you to easily add and manage multiple Direct2D overlays for a Direct3D scene.
  • An input manager class (InputManager) that consolidates input from multiple sources, including touch, mouse, keyboard, and the Xbox controller. It also implements a basic tracked-touch analog controller and buttons.
  • An audio class for sound playback and music streaming.
  • Updates to Direct3D resource management.

Get started with the WDC DirectX simple game template

  • First, download the WDC DirectX game learning templatehere. Install it by double-clicking on the VSIX file after you've extracted the contents of the sample ZIP file.
  • Next, if you haven't done so, read through Use the Visual Studio 2013 DirectX templates. These topics build on top of that guidance, in the way that WDC DirectX simple game templates build off the DirectX app template.
  • Last, verify the installation by launching Microsoft Visual Studio 2013. Go to FILE > New > Project and select "DirectX game" from under Templates > Visual C++ in the New Project dialog.

Once the project is created, build and run the solution. (Use BUILD > Build Solution and, after the build completes, DEBUG > Start Debugging. Or, press F7 and then F5 after the build completes.)

You should see this screen:

Take some time and note the different controller support. Plug in up to 4 Xbox controllers via USB. If you have a touch screen, test the virtual analog support and button presses. You can use these features to test and verify your own game components as you build them out.

What's been added to the DirectX app template?

Version 1.0.0.0

There is a new directory in the project, \Helpers, that contains the new support classes. Note that these classes are primarily for instructional and learning purposes. If you are planning to ship a game, review them and then make updates that best support your game, rather than incorporating them directly. They are designed to help you get started in an interactive environment, but should not replace custom controls and audio processing that best fit your shipping game product.

The following files are added to the baseline DirectX app template:

(In the \Helpers project directory)

Project file(s) Description
DeviceResources.h/DeviceResources.cpp Largely identical to DeviceResources implementation in the DirectX app template (under \Common), but adds hardware overlay support.
InputManager.h/InputManager.cpp Declares and implements an input type consolidation and management class, which reads from mouse, keyboard, touch input, and XInput (Xbox controllers) and returns a common input state (such as "jump button pressed" or "direction moved"). This class also implements modern virtual analog controller sticks and buttons for tablets and other touch devices.
OverlayManager.h/OverlayManager.cpp Declares and implements a class for the management of multiple Direct2D overlays, and draws them using hardware (GPU-based) overlay support if available.
SoundPlayer.h/SoundPlayer.cpp Declares and implements a simple class for the streaming and PLM for background music, and for the load and playback of discrete sound files.

 

(In the \Content project directory)

Project file(s) Description
SampleDebugTextRenderer.h/SampleDebugTextRenderer.cpp An overlay that displays the current input state and data received from one of the input devices. This is a great example overlay to enable for debugging.
SampleVirtualControllerRenderer.h/SampleVirtualControllerRenderer.cpp An overlay that draws the updated touch controls for a virtual analog stick and two buttons. Use this overlay to understand how to draw input manager based controls on the display.

 

For more details...

In this section

Topic Description

Create overlays with Direct2D

Create a set of Direct2D overlays that are drawn over the Direct3D content.

Handle input state

Learn how to use and modify the WDC DirectX game learning template's InputManager class to incorporate controls into your project.

Play simple sounds and music

The WDC DirectX game learning template includes a simple audio class called SoundPlayer. This code demonstrates how to play a sound effect, and how to play music as background audio. You can use this code to experiment with playing media in your game. If you are an audio code developer, you can study this code to learn how sound effects and music can be played with XAudio2.