Help With Pacman Program

As you all probably know, the enemies, or "ghosts" as they're called, don't stop moving, unless they are in the cage. I was wondering how i can make a program make them move continually while still getting the input direction to move Pacman through getch();. I would like to make them move them according to the difficulty the user sets. They way I want to count how long it takes them to move, or how long they have to wait inside the cage through <time.h>. Is there a way that it can continually run in the background, and then when the instance is met, execute a specific region of code?

If you can help me out any way it will be greatly appreciated.
Do you know any graphics libs? SDL SFML?

Otherwise you would want to look into the latter of the above set, and it would be trivial to implement your design.
No i do not know them, wasn't planning on making this program too complicated, just ordinary char array for the board and simple getch statements for direction.
You would be well served to learn a graphics lib.
There may be a function kbhit() that returns true if a keypress is available. If not, the way I'd do it is to set stdin to be non-blocking and do a read() of the file descriptor. (See fcntl and read functions).
If you're on windows, you can simply use getasynckeystate...
I still think you should learn a graphics lib.
Topic archived. No new replies allowed.