#include #include #define DELAY 25 #define OFFSET 10 #define WIDTH 80 #define HEIGHT 30 void ask_user(int, int, int*, int*, int*, int*, int* ); void draw_line( int ); void draw_point(int, int, int, int, int, int, int); void time_delay(int, int*, int); int main(int argc, char **argv) { int i, delay, width, height, kount=0; int x0=0, y0=0, dirx=1, diry=1, max_time=1000; delay = (argv[1]?atoi(argv[1]):DELAY); width = (argv[1] && argv[2]?atoi(argv[2]):WIDTH); height = (argv[1] && argv[2] && argv[3]?atoi(argv[3]):HEIGHT); ask_user(width, height, &x0, &y0, &dirx, &diry, &max_time); while(1) { system("clear"); printf("\ntime=%d\n\n\n", kount); draw_line(width); draw_point(kount, width, height, x0, y0, dirx, diry); draw_line(width); fflush(stdout); time_delay(delay, &kount, max_time); } return 0; } void ask_user(int w, int h, int* x, int* y, int* dx, int *dy, int* m_t) { int c; printf("Do you want to provide initial coordinates, direction, and simulation duration?\n"); printf("(Yy/Nn) "); c = getchar(); if((c=='Y') || (c=='y')){ printf("Width = %d. Give me x0: ", w); scanf("%d",x); printf("Height = %d. Give me y0: ", h); scanf("%d",y); printf("Give me the vertical/horizontal ratio [v/h]: "); scanf("%d/%d", dy, dx); printf("Give me the number of frames: "); scanf("%d", m_t); } return; } void draw_line( int width ) { int i; for(i=0; i max_t) exit(stat); return; }