#include #include #define AMPLITUDE 10 #define WAVELENGTH 40 #define SPEED 0.1 int main(void) { // Initialize ncurses and set up the screen initscr(); noecho(); curs_set(FALSE); // Get the dimensions of the terminal window int row, col; getmaxyx(stdscr, row, col); // Set up the sine wave variables double t = 0; double y = 0; // Loop forever, updating and redrawing the sine wave while (1) { // Clear the screen clear(); // Calculate the y-value of the sine wave at each point along the x-axis for (int x = 0; x < col; x++) { y = AMPLITUDE * sin((2 * M_PI * x) / WAVELENGTH - t); mvprintw(row / 2 + y, x, "*"); } // Update the time variable and redraw the screen t += SPEED; refresh(); // Sleep for a short time to slow down the animation usleep(10000); } // Clean up ncursed endwin(); return 0; }