Mail Archives: djgpp/1998/11/08/10:07:59
-----Original Message-----
From: Lazer ---¤--- <lazer_hassing AT yahoo DOT com>
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Sunday, November 08, 1998 8:58 AM
Subject: loop'ing
>I need a function for looping until 'esc' is press'ed!
>my code look like this:
>
>-----------------------------------------------
>again:
>
> /* the game code */
>
> if (key[KEY_ESC]) {
> return 0;
> }
>
>goto again
>-----------------------------------------------
>
>is there a better way of doing this?
>
You can just hava a while loop for that:
while (1) {
if (keypressed()) {
// proccess all key events, movement, fireing, etc. also
// check for exit
thekey = readkey();
if (thekey >> 8 == KEY_ESC) break;
}
// some other game loop stuff
}
- Raw text -