pauses the program for 1000 milliseconds (1 second).Code:sleep(1000);
Does not work with DJGPP.
pauses the program for 1000 milliseconds (1 second).Code:sleep(1000);
Does not work with DJGPP.
but that still pauses the program
Code:#if _emo #define stereo_type_i_dislike #endif
okay, here:Originally posted by bluehead
but that still pauses the program
Code:int x; while(x != 'q') // break out of the loop if the user presses q { while(!kbhit()) // check to see if keyboard buffer has anything in it { // WITHOUT pausing the program to wait drawGraphicsBit(); // drawgraphics bit draws the graphics sleep(10); // wait 10 ms before drawing next frame } if(kbhit()) // if the keyboard buffer has stuff in it { x = getch(); // move the first character from the buffer to int x switch(x) { case 52/*left*/: moveLeft(); break; // moveleft and case 54/*right*/:moveRight();break; // moveright move the ship case ' '/*space*/:shoot();break; default: break; } } /* go back to the beginning of the loop and do next frame */ }
Last edited by Brian; 02-23-2002 at 10:45 PM.
Ok...picture this
You have a little circle bouncing around while a timer goes up one every second(1000 milliseconds). Right now we are trying to figure out how to do that....
like
Now the problem with this is After the timer goes up one, the ball bounces. We want it to bounce with the timer. Get it? Please help us...we stranded.Code:while(1) { delay(1000);//one second counter++; printf("Time: %d",counter); //do bouncing ball }
okay hang on..I'll cook up some code..I know how to do this..
Understand?Code:int microcounter = 0; // the microcounter counts milliseconds int counter = 0; while(1) { delay(1);//one ms microcounter++; if(microcounter == 1000) // 1000 ms = 1 second { printf("Time: %d",counter); counter++; // so add one second to the counter :) microcounter = 0; // reset microcounter } //do bouncing ball }
Last edited by Brian; 02-23-2002 at 10:55 PM.
nope...ive tried that. That may work with the bouncing ball, but input? When someone inputs somthing, it doesn't work because its doing delay(1).
No, the character stays in the keyboard buffer until getch() is called, so the delay shouldn't affect it.
#include <all of the #includes.h>
int time;
int main()
{
while (1)
{
while(!khbit())
{
clrscr();
seconds = seconds + 1;
cout<<seconds;
}
while(khbit())
{
}
}
Code:#if _emo #define stereo_type_i_dislike #endif
I think this is closer (it will not compile because some functions haven't been done):
Code:#include <stdio.h> #include <conio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int microcounter = 0; // the microcounter counts milliseconds int counter = 0; int x; while(x != 'q') // break out of the loop if the user presses q { while(!kbhit()) // check to see if keyboard buffer has anything in it { // WITHOUT pausing the program to wait microcounter += 10; // add 10 ms to the microcounter because we are pausing 10 ms if(microcounter == 1000) { counter++; microcounter = 0; } drawGraphicsBit(); // drawgraphics bit draws the graphics sleep(10); // wait 10 ms before drawing next frame } if(kbhit()) // if the keyboard buffer has stuff in it { x = getch(); // move the first character from the buffer to int x switch(x) { case 52/*left*/: moveLeft(); break; // moveleft and case 54/*right*/:moveRight();break; // moveright move the ship case ' '/*space*/:shoot();break; default: break; } } /* go back to the beginning of the loop and do next frame */ } }
*sigh* Allegro is so much easier than BGI.
he, i have something that works and is alot simpler: in the attachments, tell me if it works
Code:#if _emo #define stereo_type_i_dislike #endif
THIS ONE IS BETTER:
Code:#if _emo #define stereo_type_i_dislike #endif
>.< i KEEP doing mistakes!!!! here is the attachment
SOWWIE
Code:#if _emo #define stereo_type_i_dislike #endif
Muahahahahaha!!!i have solved the problem~!
Code:#if _emo #define stereo_type_i_dislike #endif