delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/26/12:01:06

Date: Sat, 26 Jul 1997 09:00:42 -0700 (PDT)
Message-Id: <199707261600.JAA29599@adit.ap.net>
Mime-Version: 1.0
To: xanathar AT videotron DOT ca
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: Loop not doing what it should :( USES ALLEGRO
Cc: djgpp AT delorie DOT com

You wrote:
>Hello fellow DJGPP'ers, I have a bit of code that does not exactly do
>what I think IT should do. I think that the code should loop without
>any user intervention but that does not seem to be the case. The
>printf statement is only executed whenver I touch a key, I wanteds it
>to be continous without key input, what am I doing wrong?
>
>Sorry for teh following code snippet, but I'm at work now and don't
>have the real code in front of me, but here is what it does
>
>The "readkey" is an ALLEGRO function for reading keyboard input
A direct quote from ALLEGRO.TXT:
int readkey();
   Returns the next character from the keyboard buffer. If the buffer is
   empty, it waits until a key is pressed.

>void main_loop(void)
>{
>
> while (quit != 1)
> {
>  readkey(...
>  readkey(...
>  readkey(...
>  readkey(...
>  readkey(...
What are all these readkeys trying to accomplish? As it reads you are just
getting keypresses and ignoring them. There's a function called clear_keybuf
if that's what you want.
>
>  if (this and that) do this...
>  if (this and that) do this...
>  if (this and that) do this...
>
>  printf("Depth: %d Heading: %d   Speed: %d\n",depth,heading,speed);
> } // end while loop
>} //end function
HTH

Nate Eldredge
eldredge AT ap DOT net



- Raw text -


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