1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include "library.h"
void one_window(int x, int y, int width, int height)
{
fill_rectangle(x,y,width,height);
}
void row_windows(int x, int y, int width, int height, int n)
{
one_window(x,y,width,height);
if(n>1)
{
row_windows(x+(1.5*width),y,width,height,n-1);
}
}
void block_windows(int x, int y, int width, int height, int n, int floors)
{
row_windows(x,y,width,height,n);
if(floors>1)
{
block_windows(x,y+(1.5*height),width,height,n,floors-1);
}
}
void office_building(int x, int y, int width, int height, int n, int floors)
{
double R = (random_in_range(0,30))/100.0;
double G = (random_in_range(0,30))/100.0;
double B = (random_in_range(0,30))/100.0;
set_pen_color(R,G,B);
fill_rectangle(x,y,width,height);
double Gw = (random_in_range(10,25))/100.0;
double Bw = (random_in_range(10,25))/100.0;
set_pen_color(0,Gw,Bw);
block_windows(x+(n),y+(floors),((width/n)-n),((height/floors)-floors),n,floors);
}
void main()
{
int width = random_in_range(100,300);
int height = random_in_range(100,300);
int n = random_in_range(4,6);
int floors = random_in_range(5,20);
make_window(600,600);
office_building(100,200,width,height,n,floors);
}
|