Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Currently in my project, the way I handle user input events is through the OS Framework, then create a generic object - basically combines all types of input: keyboard, mouse, touch, trackball, etc. all together - this object gets queued and then on update gets processed. The queuing of objects is done on the UI thread - created by the OS - and the processing of the queue on another thread - one that I have generated. I handle the threads by using turn-based concurrency.

My problem is I worry about lag of the input events when there are fast moving objects, and I am curious to see if there are better ways of handling the input events then currently?

My current idea, of handling the simple hit test of fast moving objects with user input, is that I try and use the timestamp generated by the event to work out where everything was at that time, but it seem like a lot of work - probably because the way I have implemented everything on the update side - so is there a better way?

I did think about adding a bulk of data on the generic object creation, but there might be a lag between the creation and the actual event - on Java, I have to go through JNI and the generic object is always created on the native side. So I feel that the timestamp is my best solution. If anyone has any better ideas, it would be great to hear them.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Well basically I think this is more of a game design then a programming problem. If objects are moving so fast that in between the time of clicking and the time of processing the click event the object has moved so far that the user 'misses' the intended target, then the objects are just moving too fast.

How much time is there between the actual clicking and the handling of the clicking? I assume it's not more than 1/60s (since most update loops update at 60fps). If that is the case then there is no way of fixing this problem, simply because the reaction/response time of a human is not in the range of 1/60s.

If there is more time between clicking and processing then the input will feel laggy for everything the user does, so in that case try fixing the entire problem. :)

(If you're talking about online gaming, then yes this is an unavoidable problem, but the way you phrased it, it sounds like it is all on one machine and then this should never be an issue).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.