• Advertisement

Archived

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

Better way to get input in games?

This topic is 5154 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am using c\c++, and right now I''m gettin input like that:
while(kbhit())
 {
  k=getch();
  switch(k)
   {
    //all the input processing

    //based on the ''k'' I got on

    //this round of the loop.

   }
 }
I was using this method when I was programing in c. Is there a better way to do it on c++? ----------------------------------------- Everyboddy need someboddy!

Share this post


Link to post
Share on other sites
Advertisement
Or, if you want a quick and easy way, include windows.h and use SHORT GetAsyncKeyState(int vKey). I''d also recommend SDL or DirectX for more serious stuff though.

Share this post


Link to post
Share on other sites
I am using turbo c++ 3 and I don''t have that inclue.

-----------------------------------------
Everyboddy need someboddy!

Share this post


Link to post
Share on other sites
You don''t have "windows.h"? Might I suggest upgrading your compiler? =)

If you want to get keyboard input the "Windows" way, your window procedure will probably look very similar to what you already have set up right now. However, if you''re aiming for a more.. platform-independent (straight C++) solution, I''m afraid I don''t know C++ console input well.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
will directx solve the problem of not been able to input with two
keys at the same time

I''m doing my own version of rtype and i can''t move up and down and fire at the same time

any ideas?

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
will directx solve the problem of not been able to input with two
keys at the same time

I'm doing my own version of rtype and i can't move up and down and fire at the same time

any ideas?


Yes. DirectX will support as many simultaneous key presses as your hardware will allow. Typically it's 4 keys.

edit -- I believe SDL will allow this, as well.


[edited by - Dave Hunt on January 15, 2004 12:47:59 PM]

Share this post


Link to post
Share on other sites

  • Advertisement