Last week, while playing a game, I realized how convenient it is to be able to set your own keybindings while playing something. I thought this might be useful sometime in the future and decided to make a keyboard class and mouse class rather than use what is built into MonoGame. I created a keyboard class that would take in the keyboard input of the user, and a mouse class that would take in right-click and left-click on a mouse.
I also updated my main character’s movement to use the new keyboard class input rather than MonoGame’s built-in keyboard functions. Currently, the player moves around using WASD and can move in 8 different directions (up, down, left, right, up-right, up-left, down-right, and down-right). I do not currently have plans to have the mouse placement impact character movement. I did include a new temporary asset for the mouse cursor so that it is more obvious when the cursor is in the game window.
After going through this process, I realized that I should have spent my time doing other things since I might not use this feature in the game. I thought it would be good for future options but will not be used for my initial version of the game. Below is a small screenshot of my keyboard class to show the amount of code that went into it (included: clicking, clicking and holding, and releasing for left click).
Leave a Reply