Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simultaneous Processes 1

Status
Not open for further replies.

airdevil

Programmer
Oct 31, 1999
10
US
I am writing a dos-based tetris program in which I need to solve the problem of having the pieces drop while looking for keyboard input form the users. I use the getch() function to get the ASCII values of the arrow keys. My problem is that when I call the getch() command the input stream pauses and waits for keyboard input. I need a function or a different approach that would allow me to look for keyboard input while having the pieces drop at a constant rate. Thanx for any help. Heres a snippet of simplified code.

do
{
command = getch(); // Pauses here
process_command();
//I need soem code to have the piece drop
// while looking for input.
}
while(no_more_moves());

Thanx again,

my email is airdevil23@hotmail.com




Korn
airdevil23@hotmail.com

"procrastination is the key to happiness"
 
Hi,

How about

while(!kbhit())
{
// do stuff
}
inchar = getch();


Pappy
 
thanx a bunch Pappy.

Korn
airdevil23@hotmail.com

"procrastination is the key to happiness"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top