http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

Wise2Food



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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/caaacr0bUrGczbU68iFa/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/caaab6ebUrGczbU68iFf/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
==^================================================================