943,898 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 621
  • C++ RSS
Apr 29th, 2008
0

Accepting Characters Without Waiting

Expand Post »
I am creating a game, without using any game related libraries, only the "standard" (read aside) ones and an edited conio.h. So I get to use getch(), kbhit() et al. My problem is with kbhit(), is there no way of resetting it, so that I can reuse it?

Aside : I understand that this is related to game development, I felt its not directly related.
I am a student and I was given the freedom to chose my own program to do as a project. The restrictions though was that I should use "standard" libraries only (they use Borland compilers and call it "standard" ).

Attached : A working version of the game. Unfortunately, I have reached a stage where I have moved forward and cannot compile the program and I have the older executable, so the EXE.
Attached Files
File Type: zip The Tank and the #.zip (131.5 KB, 5 views)
Last edited by DigitalPackrat; Apr 29th, 2008 at 10:53 am.
Reputation Points: 10
Solved Threads: 1
Light Poster
DigitalPackrat is offline Offline
33 posts
since Jan 2008
Apr 29th, 2008
0

Re: Accepting Characters Without Waiting

>>My problem is with kbhit(), is there no way of resetting it, so that I can reuse it?
Yes, extract the character from the keyboard
C++ Syntax (Toggle Plain Text)
  1. if( kbdhit() )
  2. getche(); // or some other function that extracts the key

>>The restrictions though was that I should use "standard" libraries only
There is NOTHING in conio.h that is standard C or C++. And there is no standard way to get one character from the keyboard without <Enter> key too.
Last edited by Ancient Dragon; Apr 29th, 2008 at 11:03 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,953 posts
since Aug 2005
Apr 29th, 2008
0

Re: Accepting Characters Without Waiting

Two straight replies that helped. Thanks Ancient Dragon. Though, I am waiting for a reply on this.

>>There is NOTHING in conio.h that is standard C or C++. And there is no standard way to get one character from the keyboard without <Enter> key too.

I understand that conio.h is not a part of standard library, what I was trying to say there is that I am not using the one provided by Borland.
Last edited by DigitalPackrat; Apr 29th, 2008 at 11:09 am. Reason: Forgot to thank :)
Reputation Points: 10
Solved Threads: 1
Light Poster
DigitalPackrat is offline Offline
33 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: String Input - Not Happening Second Time
Next Thread in C++ Forum Timeline: What will happen if caught exception when new a object





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC