On Tue, Dec 22, 2009 at 1:51 PM, Asad Abbas <[email protected]> wrote: > Sir, > > i am trying to make a simple pingpong game using Turbo C++ Graphics... > > Everything Thing is just going fine... > But I cant manage to move the ball all the time.. and move the bat only when > the user press the up or down keys.. > > my ball only moves when user either press up or down key.. > otherwise it is kept still... > > i dont know which function should i use.. > > currently > iam using function... > > movebat(getch()); // movebat function move the bat up or down.. on pressing > either 'a' or 'z' > > the problem is that the loop stops on this line untill the user presses the > key.. and as a result ball stops moving.. and ball only moves when the user > press a key...
You need either a separate thread to handle the ball, or a non-blocking function for user input. <http://www.simonhuggins.com/courses/cbasics/course_notes/snake.htm> would suggest code along the lines of: if (kbhit()){ movebat(getch()); } -- PJH http://shabbleland.myminicity.com/ http://www.chavgangs.com/register.php?referer=9375 http://www.kongregate.com/?referrer=Shabble
