I'm trying to make a variation of the game PacMan, and I am running into some problems, one of them beeing not knowing how to print the whole map and pacman moving without the screen flickering. This is what i do for printing:
while(commmand) {
system("CLS");
display();
if(kbhit()) {
command = getch();
move(command);
}
move(command);
printf("SCORE: %d",score);
}
command, display, and move are my functions, they work properly. Is there any other way of doing this without the screen flickering?
yes there is. You want to look at double-buffering (or multiple-buffering). The general idea, is that you have two (or more buffers), while one buffer, say buffer A, is displayed on the screen, you are preforming all your computations (i.e. physics, movement, AI for the four ghosts) and drawing to the second buffer, say buffer B. When all the computations are done, we swap A and B so that buffer B is being displayed and you use buffer A for calculations.
OpenGL supports double buffering natively, see this tutorial. I've never used DirectX so I can not speak about it, but I would be surprised if it didn't have a way to do double-buffering.