I’m fairly new to directx so this may sound really basic.
I have started working on a first person game where you can walk through rooms, the language i am coding in is c++ and I’m using directx to help me create my game.
So far i have all the rooms drawn with doors etc but im a bit stuck how to make a first person camera and allow the user move forwards, backwards and side to side using the arrow keys on a keyboard.
The simpler the better as i am a beginner.
Could anyone help me out with this or point me in the right direction?
Thanks in advance
I am more of an OpenGL guy so I cannot help you with the technical side, what I can do is give you a direction.
In general, a 3D camera has:
Translation – where the camera is (x, y, z)
Rotation – angle of the camera around each axis
What you want do is related to the translation part only:
Let’s assume that your game runs at 60Hz, and you add, say, 1/60 units to the camera translation each iteration for each direction the user wants to go. If the user held up the up arrow key for 2 seconds, the camera would have moved forward 2 units.
This is the “theory” in general, now I can only point you to web pages I found that may be useful for solving the technical side of your problem:
DirectX camera movement – I’m guessing this article has a lot more than you need, but it looked pretty good and I think that you should read it anyway… But you can just skip to the View Transformation part.
Input handling – nothing much to say, regular Win32 input handling. If you are not familiar with win32 input handling I think that you should take an hour or two to learn that first.
Alright that’s it, hope I helped