954,152 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Accepting Characters Without Waiting

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.

Attachments The_Tank_and_the_#.zip (131.5KB)
DigitalPackrat
Light Poster
35 posts since Jan 2008
Reputation Points: 10
Solved Threads: 1
 

>>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

if( kbdhit() )
   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 key too.

Ancient Dragon
Retired & Loving It
Team Colleague
30,042 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
 

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 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.

DigitalPackrat
Light Poster
35 posts since Jan 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You