Below describes how to make the Star Invaders app for Windows using UWP (Universal Windows Platform) using DirectX 12.
This app will work on any Windows computer / tablet and also the Xbox. It creates an app on the computer that will be compatible with the Windows Store.
I will build the game using the DirectX 12 Kit. This contains helper code that takes care of much of the functionality of 2D / 3D graphics, audio and input (keyboard / mouse / gamepad) to help build the game.
To display graphics, DirectX uses Direct3D which is 3D graphics, but 2D graphics is a subset of 3D graphics. For example, a 3D point uses (x,y,z) coordinates while a 2D point uses (x,y) coordinates. This means that a 2D point in 3D is (x,y,0) where z=0.
To build this app, I am using the following resources:
- Visual Studio Community IDE / Compiler
- the book Introduction to Game Programming with Direct 3D 12.0 – this book helps you to understand DirectX code
- code from the book – you can get it on GitHub here
- DirectX documentation from Microsoft
- code from Microsoft’s DirectX 12 Tool Kit
- Adobe Photoshop for textures and 2D images (you can use the free Gimp app instead)
- Logic Pro X (similar to Garage Band), FL Studio and Audacity (free app) for music / audio creation and recording
Setting up the DirectX12 Kit
To setup the DirectX12 Kit, read the following documentation. Read the Getting Started guide, then go through the tutorials.
Game Loop
The first tutorial and the second tutorial takes you through the Game Loop using win32 and winUWP respectively. On this page, I used the second tutorial as I wanted to use Windows UWP with Device Resources (DR).
You download and install the VSIX file, then create a new project.
Select the project Direct3D12 UWP Game DR (C++/WinRT) as below.

Then save it to a folder on your computer. I called my game Star Invaders.
When you run it by pressing the green play button (I changed it to 64 bit)

it will look like below:

The tutorial explains what is going on.
The following classes are created:
- Game – the main game class for our game.
- IDeviceNotify – checks if the Direct3D device is created or lost
- DeviceResources – this class creates the Direct3D device and has the code to display graphics to the screen
- StepTimer – the timer for the game to keep the game running smoothly
- ViewProvider – creates the Window app using WinRT. You might be more familiar with win32 code to create a Windows app, but Microsoft has updated its C++ to use WinRT for the future.
Adding the DirectX12 Kit
The third tutorial runs through adding the DirectX12 Kit to our game. Read the instructions carefully on doing this.