Members - Reputation: 135
Posted 25 June 2012 - 02:29 PM
My problem is the way the C# code handles keyboard and mouse input. As you can see by the C# code below, KeyboardInput provides the functionality for handling key releases and mouse down, mouse up and mouse move.
It uses syntax like this:
MouseInput.MouseDown += new MouseClickHandler(MouseInput_MouseDown);
I’m not sure what’s happening with this code but I assume that when somebody clicks the Mouse Down then the MouseInput_MouseDown() function is being called.
If you compare this to how I’ve been laying it out in c++.
As you can see, each down and up of a key or mouse button has its own bool. And then I’m performing logic depending on the state of these bools. But i’m finding that there is too many of them, and I never know where to reset the state of them. I’m posting the state of these bools from main here:
My main issue is that my update method is going to become too cluttered. And using this method is very slow progress. One thing i’ve considered is separating out the triggering of each event into different methods but update is being called repeatedly and I only want certain functions to be called if a given set of conditions is met (if a key is pressed or released).
So where do you think i’m going wrong and how can I change it for the better. Oh, I realise that Logans XNA code has types for handling input (MouseInput and KeyboardInput). These are built into xna. I’m assuming it has overrides for the += but i’m reaching the limit of my understanding just saying that and have no idea what I’m doing.
So is there a library of code built into vc++/directx to help me handle this. Is there a lib I can install and use, or do I have to write something to handle this myself.
I’m kind of answering my own questions as I write this which is why it is good to post questions on forums. It helps you understand your own problem better.
Members - Reputation: 124
Posted 27 June 2012 - 05:11 AM
Somebody in irc said that there's no replies because this is a boring topic field.
No, there are no replies because:
I’m not going to write a test case
I’m kind of answering my own questions as I write this which is why it is good to post questions on forums
is wrong. Write your questions out in a private area if you haven't finished working through the problem. Then post a specific, precise question relating only to what you still do not understand. People don't have spare time to donate for decoding your thought processes!