|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] RE: Problem with getch( )
============================================================ Shopping for auto insurance? Compare up to four companys' rates at progressive.com, rated the top online insurance carrier by internet quality measurement firm Gomez.com. http://click.topica.com/caaacoBbUrGczbU68iFa/Progressive ============================================================ There probably is, but it's not all that hard to write your own checker: int c if (kbhit()) c = getch(); That's all there is to it. The low order byte stores the ASCII representation. Of course, this method (and getch() in general) relies on the typematic rate set by BIOS. If you hold down a key, it will write one character, pause for a little bit, and then write that character repeatedly at varying speeds. For games, it's better to use direct keyboard access via a library. -----Original Message----- From: gwang@i-mail.com.au [mailto:gwang@i-mail.com.au] Sent: Tuesday, June 19, 2001 2:29 AM To: gameprogrammer@topica.com Subject: Problem with getch( ) ============================================================ YOU'VE EARNED IT! If you are over age 50, subscribe to the SeniorDiscounts.com Email newsletter and get the discounts you deserve. It's fast, easy and FREE at: http://click.topica.com/caaacr0bUrGczbVM1hDa/Senior ============================================================ Hi, I've been trying to make a simple space game which runs by something like this: main() { while(QuitGame != 1){ ObtainArrowKeyPressFromUser(); RedrawSpaceshipAtNewLocation(); /* erase old ship, draw new ship */ UpdateBackground(); /* Just scrolling stars */ } } And I run into a problem when I used getch() in ObtainArrowKeyPressFromUser(). Understandably the background does not update until the user presses a key, ie if the user does not press anything, the stars stop scrolling. Apparently it's because getch() waits on me for a keypress, and wouldn't go on unless something if pressed; after I pressed one key, the stars scroll half an inch and stop again as another keypress is needed. How can I get by this problem? I thought about checking the keyboard buffer or borrow timer interrupt, but it seems too complicated and un-necessary... Is there a simple way out eg. a getch() which automatically exits if a key is not pressed say within 1/5 of a second? Thanks a lot. GEORGE (By the way, the C I use is TurboC 2.0 for MS-DOS) __________________________________________________________________ Free POP e-mail, fax, SMS and calendar at http://www.i-mail.com.au ============================================================ Want to save a fortune? It's fast, easy, and fun with outrageous deals from TopOffers. http://click.topica.com/caaab6ebUrGczbVM1hDf/TopOffers ============================================================ ============================================================ Want to save a fortune? It's fast, easy, and fun with outrageous deals from TopOffers. http://click.topica.com/caaacgJbUrGczbU68iFf/TopOffers ============================================================ ==^================================================================ EASY UNSUBSCRIBE click here: http://topica.com/u/?bUrGcz.bU68iF Or send an email To: gameprogrammer-unsubscribe@topica.com This email was sent to: list@pendleton.com T O P I C A -- Register now to manage your mail! http://www.topica.com/partner/tag02/register ==^================================================================
|
|