D
DaVinci
I am writing a pong game.but met some problem.
the ball function to control the scrolling ball,
void ball(int starty,int startx)
{
int di ,i;
int dj,j;
di = 1;
dj = 1;
i = starty;
j = startx;
int ch;
while(1)
{
mvaddstr(i,j,"O");
refresh();
usleep(100000);
i = i + di;
j = j + dj;
if(i >= LINES -1 || i < 0)
{
di = -di;
}
if(j >= COLS -1 || j < 0)
{
dj = -dj;
}
}
}
the question is when I want to invoke the ball()function in main()
function,
I can't go out from the while loop. If I didn't write the while loop
statement
I didn't how to let the ball srcolling all the time.
I had trid to use IPC to make them work,let ball() be invoked by child
process
but not work.
any help is apreciated.
the ball function to control the scrolling ball,
void ball(int starty,int startx)
{
int di ,i;
int dj,j;
di = 1;
dj = 1;
i = starty;
j = startx;
int ch;
while(1)
{
mvaddstr(i,j,"O");
refresh();
usleep(100000);
i = i + di;
j = j + dj;
if(i >= LINES -1 || i < 0)
{
di = -di;
}
if(j >= COLS -1 || j < 0)
{
dj = -dj;
}
}
}
the question is when I want to invoke the ball()function in main()
function,
I can't go out from the while loop. If I didn't write the while loop
statement
I didn't how to let the ball srcolling all the time.
I had trid to use IPC to make them work,let ball() be invoked by child
process
but not work.
any help is apreciated.