#include #include #include #include #include #include #include #include #include int drawship(); int drawland(); int main () { clrscr (); int gdriver = DETECT, gmode, errorcode; initgraph (&gdriver, &gmode, "c:\\tclite\\bgi"); errorcode = graphresult (); if (errorcode != grOk) { printf ("Graphics error: %s\n", grapherrormsg (errorcode)); printf ("Press Anykey to halt: "); getch (); exit (1); } /* "graphics main prorgam lines" go here */ randomize; //drawship(); drawland(); getch (); closegraph (); return 0; } int drawship() { setcolor(WHITE); //drawpoly ( //arc(midx, midy, stangle, endangle, radius); //arc (250,250, 0, 180, //ellipse(midx, midy, stangle, endangle, xradius, yradius); //ellipse (350, 300, 0, 360, 15, 7); //line (350,300,360,310); //circle ( /* line(250,250,257,250); line(257,250,257,257); line(257,257,250,257); line(250,257,250,250); line(250,250,254,244); line(254,244,257,250); line(252,257,248,261); line(248,261,247,264); line(245,264,249,264); line(255,257,260,261); line(260,261,261,264); line(259,264,263,264); */ return 0; } int drawland() { randomize; int x_str, x_end, y_str, y_end, a, b, x_point; y_str = getmaxy() / 2; x_str = getmaxx(); while (!kbhit()) { //a = random (100); a = rand()%100; x_end = x_str - a; if (y_end > getmaxy()-50) { b = rand()%100; y_end = y_str - b; } else if (y_end < getmaxy()/2) { b = rand()%100; y_end = y_str + b; } else { b = rand()%100; y_end = y_str + b; } //x_point = random(100); line (x_str, y_str, x_end, y_end); //printf("%d %d %d %d\n", x_str,y_str,x_end,y_end); //delay(500); x_str = x_end; y_str = y_end; //delay (50); if (x_end < 1) { clrscr(); x_str = getmaxx(); } } return 0; }