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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
uses crt,graph,dos;
type T_etoile = record
x,y:integer;
end;
const max=26;
var a,b:integer;
G_Etoile, M_Etoile, P_Etoile,TP_Etoile:array[1..100] of T_etoile;
I,J:Integer;
x,y,color:integer;
heure,minu,sec,cent,plus,versus,encor:word;
{ Procedure pour dessiner les petites,moyenes,et grandes etoiles }
Procedure Petit_Etoile(x,y,color:LongInt);
begin
for i:=0 to 2 do
begin
putpixel(x,y+i,color);
putpixel(x+i-1,y+1,color)
end
end;
Procedure Moyen_Etoile(x,y,color:LongInt);
begin
for i:=0 to 4 do
begin
PutPixel(x,y+i,color);
PutPixel(x+i-2,y+2,color)
end
end;
Procedure Grand_Etoile(x,y,color:LongInt);
Begin
for i:=0 to 8 do
begin
PutPixel(x,y+i-1,color);
PutPixel(x+i-4,y+3,color)
end;
PutPixel(x-1,y+2,color);
PutPixel(x+1,y+2,color);
PutPixel(x-1,y+4,color);
PutPixel(x+1,y+4,color)
end;
{ Programme principal }
Begin
a:=detect;
Initgraph(a,b,'c:\tp\bgi');
setbkcolor(0);
randomize;
{ Initialiser les differentes positions du champ d'etoiles }
for j:=1 to max do
begin
G_Etoile[j].x:=random(630)+5;
G_Etoile[j].y:=random(460)+5;
M_Etoile[j].x:=random(630)+5;
M_Etoile[j].y:=random(460)+5;
P_Etoile[j].x:=random(630)+5;
P_Etoile[j].y:=random(460)+5;
TP_Etoile[j].x:=random(630)+5;
TP_Etoile[j].y:=random(460)+5;
end;
{ Afficher le champ d'etoile }
for j:=1 to max do
begin
Grand_etoile( G_Etoile[j].x, G_Etoile[j].y,white);
Moyen_Etoile( M_Etoile[j].x, M_Etoile[j].y,white);
Petit_Etoile( P_Etoile[j].x, P_Etoile[j].y,white);
PutPixel(TP_Etoile[j].x, TP_Etoile[j].y,white);
end;
{ Tout ce qui suit permet le deplacement du champ d'etoile }
repeat
gettime(heure,minu,sec,cent);
if versus<> sec then
begin
for j:=1 to max do
begin
{ Effacer l'etoile concern}
PutPixel( TP_Etoile[j].x, TP_Etoile[j].y,0);
Inc(TP_Etoile[j].x,2);
{ afficher l'etoile concern}
PutPixel( TP_Etoile[j].x, TP_Etoile[j].y,white);
if TP_Etoile[j].x>648 then
begin
TP_Etoile[j].x:=1;
TP_Etoile[j].y:=random(460)+5;
end;
end;
end;
if plus<> cent then
begin
for j:=1 to max do
begin
{ Effacer l'etoile concern}
Grand_etoile( G_Etoile[j].x, G_Etoile[j].y,0);
Inc(G_Etoile[j].x);
{afficher l'etoile concern}
Grand_etoile( G_Etoile[j].x, G_Etoile[j].y,white);
if G_Etoile[j].x=650 then
begin
G_Etoile[j].x:=1;
G_Etoile[j].y:=random(460)+5;
end;
end;
end;
if versus<>plus then
begin
for j:=1 to max do
begin
{ Effacer l'etoile concern}
Moyen_etoile( M_Etoile[j].x, M_Etoile[j].y,0);
Inc(M_Etoile[j].x);
{afficher l'etoile concern}
Moyen_etoile( M_Etoile[j].x, M_Etoile[j].y,white);
if M_Etoile[j].x=650 then
begin
M_Etoile[j].x:=1;
M_Etoile[j].y:=random(460)+5;
end;
end;
end;
if encor<> plus then
begin
for j:=1 to max do
begin
{ Effacer l'etoile concern}
Petit_Etoile( P_Etoile[j].x, P_Etoile[j].y,0);
Inc(P_Etoile[j].x);
{afficher l'etoile concern}
Petit_Etoile( P_Etoile[j].x, P_Etoile[j].y,white);
if P_Etoile[j].x=650 then
begin
P_Etoile[j].x:=1;
P_Etoile[j].y:=random(460)+5;
end;
end;
end;
versus:=sec;
plus:=cent;
until keypressed;
Closegraph;
END. |
Partager