delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/04/14:28:27

From: "Roland Moritz" <hotel DOT moritz AT utanet DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: How to empty the keyboard buffer
Date: Mon, 4 Oct 1999 16:45:59 +0200
Organization: UTANET Newsserver
Lines: 23
Message-ID: <7tajaf$q2a$1@rohrpostix.uta4you.at>
NNTP-Posting-Host: mibeu01-0910.utaonline.at
X-Trace: rohrpostix.uta4you.at 939053199 26698 212.152.131.148 (4 Oct 1999 16:06:39 GMT)
X-Complaints-To: news-admin AT utanet DOT at
NNTP-Posting-Date: 4 Oct 1999 16:06:39 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I want to program a game, where Keyboard input is handled throught getch();
there is a mainloop, which looks something like

if (kbhit)
{
  c = getch();
   if (c == etc...
}

And now my question is, how do I empty the keyboard buffer everytime the
loop is through, since I don't want, for example, that if a message is shown
for 5 Seconds, and the player pushes some keys, that they will be used as
keyboard input the next time the loop is running through, since there are
still keys in the buffer...I've tried it with something simple like

while (kbhit()
  c = getch();

But it does'nt work...Maybe there is a way to turn off keyboard input at
all, so that the keys pressed are not stored in the kb-buffer?
I would appreciate your help alot!


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019