- for (j=0;;) {
- x=(int)(c*ranf())+2;
- y=(int)(r*ranf())+2;
-
- cursor(x,y); addch('.');
-
- cursor(xpos[j],ypos[j]); addch('o');
-
- if (j==0) j=4; else --j;
- cursor(xpos[j],ypos[j]); addch('O');
-
- if (j==0) j=4; else --j;
- cursor(xpos[j],ypos[j]-1);
- addch('-');
- cursor(xpos[j]-1,ypos[j]);
- addstr("|.|");
- cursor(xpos[j],ypos[j]+1);
- addch('-');
-
- if (j==0) j=4; else --j;
- cursor(xpos[j],ypos[j]-2);
- addch('-');
- cursor(xpos[j]-1,ypos[j]-1);
- addstr("/ \\");
- cursor(xpos[j]-2,ypos[j]);
- addstr("| O |");
- cursor(xpos[j]-1,ypos[j]+1);
- addstr("\\ /");
- cursor(xpos[j],ypos[j]+2);
- addch('-');
-
- if (j==0) j=4; else --j;
- cursor(xpos[j],ypos[j]-2);
- addch(' ');
- cursor(xpos[j]-1,ypos[j]-1);
- addstr(" ");
- cursor(xpos[j]-2,ypos[j]);
- addstr(" ");
- cursor(xpos[j]-1,ypos[j]+1);
- addstr(" ");
- cursor(xpos[j],ypos[j]+2);
- addch(' ');
- xpos[j]=x; ypos[j]=y;
- refresh();
- napms(50);
+
+ for (j = 0;;) {
+ x = (int) (c * ranf()) + 2;
+ y = (int) (r * ranf()) + 2;
+
+ mvaddch(y, x, '.');
+
+ mvaddch(ypos[j], xpos[j], 'o');
+
+ j = next_j(j);
+ mvaddch(ypos[j], xpos[j], 'O');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 1, xpos[j], '-');
+ mvaddstr(ypos[j], xpos[j] - 1, "|.|");
+ mvaddch(ypos[j] + 1, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], '-');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, "/ \\");
+ mvaddstr(ypos[j], xpos[j] - 2, "| O |");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, "\\ /");
+ mvaddch(ypos[j] + 2, xpos[j], '-');
+
+ j = next_j(j);
+ mvaddch(ypos[j] - 2, xpos[j], ' ');
+ mvaddstr(ypos[j] - 1, xpos[j] - 1, " ");
+ mvaddstr(ypos[j], xpos[j] - 2, " ");
+ mvaddstr(ypos[j] + 1, xpos[j] - 1, " ");
+ mvaddch(ypos[j] + 2, xpos[j], ' ');
+
+ xpos[j] = x;
+ ypos[j] = y;
+
+ switch (getch()) {
+ case ('q'):
+ case ('Q'):
+ curs_set(1);
+ endwin();
+ ExitProgram(EXIT_SUCCESS);
+ case 's':
+ nodelay(stdscr, FALSE);
+ break;
+ case ' ':
+ nodelay(stdscr, TRUE);
+ break;
+#ifdef KEY_RESIZE
+ case (KEY_RESIZE):
+ r = (float) (LINES - 4);
+ c = (float) (COLS - 4);
+ break;
+#endif
+ }
+ napms(50);