Код
program god;
uses graph,crt,snegmod;
const
sn=630;
var
mass:array[1..sn] of sneg;
d,r,k,ll,i,f:integer;
begin
d:=Detect;
initgraph(d,r,'');
k:=graphresult;
if k<>grok then
writeln(GraphErrorMsg(k))
ELSE
begin
k:=0;
f:=0;
ll:=0;
for i:=1 to sn do mass[i].kk:=0;
repeat
for i:=1 to sn do
begin
if ll=0 then
begin
if (mass[i].kk=0) then
begin
f:=mass[i].start(f);
k:=mass[i].k;
mass[i].kk:=1;
if k=1 then ll:=20;
end else
begin
mass[i].engine;
end;
end else
begin
for d:=1 to sn do
begin
mass[d].engine;
end;
ll:=ll-1;
end;
end;
until keypressed;
end;
closegraph;
end.
uses graph,crt,snegmod;
const
sn=630;
var
mass:array[1..sn] of sneg;
d,r,k,ll,i,f:integer;
begin
d:=Detect;
initgraph(d,r,'');
k:=graphresult;
if k<>grok then
writeln(GraphErrorMsg(k))
ELSE
begin
k:=0;
f:=0;
ll:=0;
for i:=1 to sn do mass[i].kk:=0;
repeat
for i:=1 to sn do
begin
if ll=0 then
begin
if (mass[i].kk=0) then
begin
f:=mass[i].start(f);
k:=mass[i].k;
mass[i].kk:=1;
if k=1 then ll:=20;
end else
begin
mass[i].engine;
end;
end else
begin
for d:=1 to sn do
begin
mass[d].engine;
end;
ll:=ll-1;
end;
end;
until keypressed;
end;
closegraph;
end.
Код
unit snegmod;
interface
uses graph,crt;
type
sneg=object
k,kk,x1,y1,ll,f:integer;
constructor init;
function start(y0:integer):integer;
procedure engine;
end;
implementation
constructor sneg.init;
begin
line(x1+4,y1,x1+1,y1);
line(x1-4,y1,x1-1,y1);
line(x1,y1+4,x1,y1+1);
line(x1,y1-4,x1,y1-1);
line(x1+1,y1+1,x1+3,y1+3);
line(x1+1,y1-1,x1+3,y1-3);
line(x1-1,y1-1,x1-3,y1-3);
line(x1-1,y1+1,x1-3,y1+3);
end;
function sneg.start(y0:integer):integer;
var smesh:integer;
begin
k:=0;
smesh:=random(4);
y1:=5;
x1:=y0+smesh+4;
if (y0+smesh+9)>getmaxx then begin k:=1; start:=0; end else
begin
start:=y0+20+random(10);
end;
sneg.init;
kk:=1;
end;
procedure sneg.engine;
begin
ll:=random(5);
if kk=1 then begin
if y1<(getmaxy) then begin
setwritemode(xorput);
sneg.init;
setwritemode(copyput);
case ll of
0:begin y1:=y1+1; x1:=x1-2;end;
1:begin y1:=y1+1; x1:=x1-1;end;
2:begin y1:=y1+2; x1:=x1;end;
3:begin y1:=y1+1; x1:=x1+1;end;
4:begin y1:=y1+1; x1:=x1+2;end;
end;
sneg.init;
end else kk:=0;
end;
end;
end.