I made some progress on the input-binding system for the game engine today.
I’m sort of using a similar setup to what I implemented for Ecosystem, in which a Handler “subscribes” to whatever Components it needs to handle, then receives all Entities with those Components during the update. In the case of player input, an Action “subscribes” to any number of Keys, and only those Keys with at least one active Action are tracked for input changes. I’m just focusing on Keyboard/Mouse for now. I lost a fair amount of time trying to fit Joysticks into this abstraction, but that can spiral out of control pretty quickly, which is especially bad because I might not even need it. I still think Joysticks will fit into this formula, but I don’t need to try and figure out Trigonometry before I get Algebra I down.
It’s been surprisingly difficult to find any intermediate-level discussion about input handling in Monogame/XNA. Every tutorial is geared toward absolute beginner-level projects, usually just checking key state in a big nested if-statement
Game1.Update(). Beyond that, it’s usually just “don’t worry about it, use my library”. But I’m just as stubborn as all the other library-developers and want to figure this one out myself, so I might be in for the long-haul. I did find a thread from 2008 that gave me a little bit of inspiration, particularly this comment about making input management more generic.
Making an engine from scratch is kind of a double-edged sword. On one hand, I get to know exactly how everything in the engine works (well, down to its Monogame core, in this case). But on the other, I know I’m spending a lot of time solving problems that have been solved several times before. I’ve tried to get started with a handful of libraries in the past, but usually don’t get far beyond controlling a single sprite on-screen before I either A) get stuck on documentation and end up looking through source code, or B) don’t like how the API is implemented and get demotivated. I’m 110% sure I’m going to run into the same hurdles that these hundreds of other devs have run into before, but I kind of want to see how they ended up where they did, you know?
Or maybe I’m subconsciously just trying to put off the impossible task of “creating sprites” as long as possible.↑ Top