program g;
uses crt;


var xyz : array[2..79,2..23] of shortint;



procedure border;
var x:integer;

begin

textcolor (8);
gotoxy (1,1);
write ('É');
for x := 0 to 77 do write ('Í');
write ('»');

gotoxy (1,24);
write ('È');
for x := 0 to 77 do write ('Í');
write ('¼');

for x := 2 to 23 do begin
gotoxy (80,x);
write ('º');
gotoxy (1,x);
write ('º');
end;

end;



procedure main;
var shape,turn,x,y,g,h:shortint;
overlap : boolean;
input : char;
begin

turn := 1;
x := 40;
y := 3;
overlap := false;



{randomize;
shape := random(7);  }

shape := 1;

repeat
repeat

case shape of
1 : begin

if x > 75 then x := 75;
if x < 2 then x := 2;

if (turn = 1) or (turn = 3) then begin
for g := 0 to 3 do if xyz[x+g,y] <> 0 then overlap := true;
if y >= 24 then overlap := true;
if overlap = true then y := y - 1;

for g := 0 to 3 do xyz[x+g,y] := 3;

end;

end;

2 : begin
end;
3 : begin
end;
4 : begin
end;
5 : begin
end;
6 : begin
end;
7 : begin
end;
end;

for g := 2 to 79 do for h := 2 to 23 do begin
textcolor (xyz[g,h]);
gotoxy (g,h);
write ('g');
end;

delay (100);

if overlap = false then for g := 0 to 3 do xyz[x+g,y] := 0;

y := y + 1;

until keypressed;

input := readkey;

case input of
'a' : x := x - 1;
's' : x := x + 1;
end;


until input = 'q';


end;



begin
clrscr;
border;
main;

end.
