Taking control
We now have a framework to load and render game objects. But, we don't have any way to move our ship! The good news is that we already wrote an input class for RoboRacer2D, and we can reuse that code here.
Implementing input
Earlier in the chapter, I had you copy the Input
class from RoboRacer2D into the source folder for SpaceRacer3D. Now, we have to simply wire it into our game code.
Open SpaceRacer3D. First, we need to include the input header. Add the following line of code to the headers:
#include "Input.h"
We also need to create a global pointer to manage the Input
class. Add the following line just below the model pointers:
Input* m_input;
Next, we need to create an instance of the Input
class. Add the following line of code to the top of the StartGame
function:
m_input = new Input(hWnd);
Now, we have to create a function to handle our input. Add the following function just above the Update
method:
void ProcessInput(const float p_deltaTime) { Vec3 rotation; ...