Archived

This topic is now archived and is closed to further replies.

JinJo

direct input (small problem please help)

Recommended Posts

ive just finished the book game programming all in one (good book), during the book you build a directX 8 engine for simple 2d games. For input it uses DX8 and uses GetDeviceState for every key on the keyboard. so if im doing a game i check the state of a key using this function and then do whatever depending on that. Now theres a small physics engine in the book and to move an object i would check the state of the keyboard and then use a function such as applyLinearForce() to this object. however i want to do a game using grid based movement so if the left key was pressed id do if(!AtFarthestXPoint) xPos+=1; this isnt the actual code obviously the problem is pressing the key once will move the object to the furthest x position. So i was wondering if there was away to slow this down, ive tried setting the key to 0 in the buffer i pass to GetDeviceState() thanks in advance

Share this post


Link to post
Share on other sites
You could make a time limit between the keypress and the next time a key can be pressed. There are many time functions out there that you can use (as I''m sure you know). Just remember that the basic idea would be this:

if (current_time - time_of_keypress > wait_time)
//time to act on the keypress!



I will not make a list of links... I will not make a list of links... I will not make a list of links...
Invader''s Realm

Share this post


Link to post
Share on other sites