#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <stdarg.h>
#include <dos.h>
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;
drawland();
getch ();
closegraph ();
return 0;
}
int drawship()
{
setcolor(WHITE);
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;
}
line (x_str, y_str, x_end, y_end);
x_str = x_end;
y_str = y_end;
if (x_end < 1)
{
clrscr();
x_str = getmaxx();
}
}
return 0;
}
Download Lander.cpp