www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/08/10:07:59

Message-ID: <000801be0b29$cb5284a0$7b6195cc@uic>
From: "Andrew Deren" <aderen AT interaccess DOT com>
To: <djgpp AT delorie DOT com>
Subject: Re: loop'ing
Date: Sun, 8 Nov 1998 09:09:33 -0600
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 4.72.3110.1
X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3
Reply-To: djgpp AT delorie DOT com

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


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