Продолжаем знакомиться с графическим режимом. 16 апреля 2020 г. восьмым классам было дано задание - строительство многоэтажного дома в GameLogo. Это был некий итог темы создания орнамента. Предлагаю вам подключится к выполнению этого задания, правда вместо GameLogo делаем в Lazarus.
Уровни сложности задания:
1. Дом из оконных плит без заливки рисуется сверху вниз
2. Дом из оконных плит без заливки рисуется снизу вверх
3. Дом из оконных плит с заливкой (плита и окно залита разным цветом) рисуется снизу вверх (смотри GIF-образец)
4. Дом из балконных плит с заливкой (плита, балкон и окно залита разным цветом) рисуется снизу вверх
5. Дом из оконных и балконных плит (чередуются по вашему правилу) с заливкой (плита, балкон и окно залита разным цветом) рисуется снизу вверх
6. Дом из оконных и балконных плит (чередуются по вашему правилу) с заливкой (плита, балкон и окно залита разным цветом) рисуется снизу вверх со случайно включенным или выключенным цветом.
Дополнительное задание: крыша (дизайн на ваше усмотрение)
Рекомендую для плит использовать процедуры пользователя.
Как организовать систему вложенных циклов, можно посмотреть здесь -
Надеюсь перевести программу с языка Лого на Паскаль у вас проблем не возникнет.
Текст программы вставляем в комментарий к этому сообщению, в теме указываем Фамилию и Имя.
Удачи!
uses Graph;
var Gd, Gm: Smallint;
s, c: word;
i, j, k: byte;
begin
Gd:= detect;
InitGraph(Gd, Gm, '');
SetFillStyle(1, 1);
FloodFill(1, 1, 1);
SetColor(0);
for i:= 1 to GetMaxY div 100 do begin
c:= GetMaxY - ((i - 1)* 100);
for j:= 1 to GetMaxX div 100 do begin
s:= ((GetMaxX) - ((GetMaxX div 100)*100)) div 2 + ((j - 1) * 100);
SetFillStyle(1, 7);
Rectangle(s, c - 100, s + 100, c);
FloodFill(s + 1, c - 1, 0);
k:= random(2);
if k = 1 then
SetFillStyle(1, 14)
else
SetFillStyle(1, 8);
Rectangle(s + 10, c - 10, s + 90, c - 90);
FloodFill(s + 11, c - 11, 0);
Line(s + 70, c - 10, s + 70, c - 90);
Line(s + 70, c - 70, s + 90, c - 70);
if (j + i) mod 3 = 0 then begin
SetFillStyle(1, 3);
Bar(s + 1, c - 49, s + 99, c - 1);
end;
end;
end;
readln;
CloseGraph;
end.
Uses Graph;
Var Gd, Gm : SmaLLInt;
a,b,i,j,k:integer;
Begin
Gd:=Detect;
InitGraph(Gd,Gm,'');
SetFillStyle(1,1);
Bar(0,GetMaxY,GetMaxX,0);
SetColor(0);
for i:=1 to GetMaxY div 150 do begin
b:=GetMaxY-((i-1)*150);
for j:=1 to GetMaxX div 150 do begin
a:=(GetMaxX-((GetMaxX div 150)*150)) div 2+((j-1)*150);
Rectangle(a,b-150,a+150,b);
SetFillStyle(1,7);
FloodFill(a+1,b-1,0);
Rectangle(a+30,b-120,a+120,b-30);
k:=random(4);
if (k=1) or (k=3) then SetFillStyle(1,14)
else
SetFillStyle(1,8);
floodFill(a+90,b-31,0);
Line(a+90,b-120,a+90,b-30);
Line(a+90,b-90,a+120,b-90);
if (j mod 3=0) then begin
if (k=3) then SetFillStyle(1,9)
else SetFillStyle(1,6);
Bar(a,b-70,a+150,b);
end;
end;
end;
Readln;
CloseGraph;
End.
Uses Graph;
Var j,i,x,y,k,f,flag:integer;
Gd,Gm:SmallInt;
begin
Gd:=Detect;
InitGraph(Gd,Gm, '');
x:=250;
y:=250;
k:=x;
SetFillStyle(1,2);
Bar(0,0,GetMaxX,GetMaxY);
For j:=1 to 5 do begin
For i:=1 to 10 do begin
SetColor(0);
Rectangle(x,y,x+50,y+50);
SetFillStyle(1,7);
Bar(x+1,y+1,(x+50)-1,(y+50)-1);
SetColor(0);
Rectangle(x+7,y+7,x+43,y+43);
Flag:=random(2);
If Flag=1 then
SetFillStyle(1,14)
else SetFillStyle(1,8);
Bar(x+8,y+8,(x+43)-1,(y+43)-1);
SetColor(0);
Line(x+35,y+7,x+35,y+43);
Line(x+35,y+13,x+43,y+13);
f:=random(2);
If f=1 then begin
SetFillStyle(1,6);
Bar(x+1,y+25,(x+50)-1,(y+50)-1);
end;
x:=x+50;
end;
y:=y-50;
x:=k;
end;
Readln;
CloseGraph;
end.
Uses Graph;
Var Gd, Gm : SmaLLInt;
a,b,i,j,k,n:integer;
Begin
Gd:=Detect;
InitGraph(Gd,Gm,'');
SetFillStyle(1,1);
Bar(0,GetMaxY,GetMaxX,0);
for i:=1 to GetMaxY div 150 do begin
b:=GetMaxY-((i-1)*150);
for j:=1 to GetMaxX div 150 do begin
a:=(GetMaxX-((GetMaxX div 150)*150)) div 2+((j-1)*150);
SetColor(0);
Rectangle(a,b-150,a+150,b);
SetFillStyle(1,7);
FloodFill(a+1,b-1,0);
Rectangle(a+30,b-120,a+120,b-30);
k:=random(4);
if (k=1) or (k=3) then SetFillStyle(1,14)
else
SetFillStyle(1,8);
FloodFill(a+90,b-31,0);
Line(a+90,b-120,a+90,b-30);
Line(a+90,b-90,a+120,b-90);
SetColor(1);
if (j mod 3=0) then begin
if (k=3) then SetFillStyle(1,9)
else SetFillStyle(1,6);
Rectangle(a,b-70,a+150,b);
FloodFill(a+1,b-65,1);
end;
end;
end;
Readln;
CloseGraph;
End.
uses graph;
var Gd, Gm: smallint;
a, b: integer;
c, d, e: longint;
begin
Gd:= detect;
initgraph(Gd, Gm, '');
setfillstyle(1, 15);
floodfill(1, 1, 1);
setColor(0);
for c:= 1 to GetMaxY div 100 do begin
b:= GetMaxY - ((c - 1)* 100);
for d:= 1 to GetMaxX div 100 do begin
a:= ((GetMaxX) - ((GetMaxX div 100)*100)) + ((d - 1) * 100);
setfillstyle(1, 6);
rectangle(a, b - 100, a + 100, b);
floodfill(a + 1, b - 1, 0);
e:= random(1);
if e = 1 then
setfillstyle(1, 4)
else
setfillstyle(1, 9);
rectangle(a + 10, b - 10, a + 90, b - 90);
floodfill(a + 11, b - 11, 0);
line(a + 70, b - 10, a + 70, b - 90);
line(a + 70, b - 70, a + 90, b - 70);
end;
end;
readln;
closegraph;
end.
uses Graph;
var Gd, Gm: Smallint;
s, c,i,j,g: integer;
k:boolean;
begin
Gd:= detect;
InitGraph(Gd, Gm, '');
SetFillStyle(1, 1);
Bar(1, 1,getmaxx,getmaxy);
SetColor(0);
for i:= 1 to GetMaxY div 100 do begin
c:= GetMaxY - ((i - 1)* 100);
for j:= 1 to GetMaxX div 100 do begin
s:= ((GetMaxX) - ((GetMaxX div 100)*100)) div 2 + ((j - 1) * 100);
Setfillstyle(1,0);
Bar(s-1, c - 101, s + 99, c-1);
SetFillStyle(1, 7);
Bar(s, c - 100, s + 100, c);
g:= random(2);
if g = 1 then
k:=true
else
k:=false;
If k=true then
SetFillStyle(1, 14)
else
SetFillStyle(1, 8);
Rectangle(s + 10, c - 10, s + 90, c - 90);
FloodFill(s + 11, c - 11, 0);
Line(s + 70, c - 10, s + 70, c - 90);
Line(s + 70, c - 70, s + 90, c - 70);
if (j + i) mod 4 = 0 then begin
SetFillStyle(1, 4);
Bar(s + 1, c - 49, s + 99, c - 1);
end;
end;
end;
readln;
CloseGraph;
end.