Programming III – FPS
|
This is a few days late, but eh, here it is. Last week I implemented Xbox360-controll input with XInput for our FPS game. I used a really good tutorial for this since I’ve never used XInput before. Most of what it goes through was fairy straight forward, but the thing I appreciated the most was the way it made it so that after you set a deadzone and surpass it, the method wont return 0.3f (for example) immediately instead it will start counting up from 0.0f even if we already have moved the stick a bit. I got this working very quick thanks to the tutorial so I started working on Keybindings for both the controller and Keyboard/Mouse. The way I create the binds ins’t very fancy at all, I just created a map that holds an int and a WORD(The key that we want to bind). To make things even simpler I used an enum where I store every possible action that the player can make so it will be easy to bind things without wasting memory on strings everywhere.
And then I can just check for input like this.
Then I just did pretty much the same for the controller, but because we are dealing with axes here as well I decided to take the easy route and not give the players full control over their bindings for the controller. Instead I just created a few presets that the player will be able to choose from just like in most console games that give you the ability to change the bindings. Other than that I’ve moved the skybox to its separate class and created a GUI class that handles all the shaders and stuff for us so that we can just select a texture and draw it directly. Filed under: Uncategorized Tagged: 5SD048 |


