procedure Draw (x,y:integer;mode:boolean);
var sprite:array [1..3] of string [3];
i:integer;
begin
sprite[1]:='/|\';
sprite[2]:='-=-';
sprite[3]:='\|/';
if mode then textcolor (White)
else textcolor (Black);
for i:=y to y+2 do begin
gotoxy (x,i);
write (sprite[i-y+1]);
end;
gotoxy (x+1,y+1);
end;

procedure status (n:integer; s:string);
begin
textcolor (Black); textbackground (White);
gotoxy (1,n); write (' ':79);
gotoxy (2,n); write (s);
textcolor (White); textbackground (Black);
end;

var x,y:integer;
begin
clrscr;
status(1,'Управление движением-2');
status(25,'Стрелки-управление;ESC-выход');
x:=10; y:=10; LastDir:=goleft;
repeat {бесконечный цикл работы программы}
repeat {цикл до нажатия клавиши}
Draw (x,y,true); Delay (myDelay);
Draw (x,y,false);
case LastDir of
goLeft:
if x>1 then Dec(x)
else begin
x:=1; LastDir:=gostop;
end;
GoRight:
if x<77 then inc(x)
else begin
x:=77; LastDir:=gostop;
end;
goUp:
if y>2 then Dec(y)
else begin
y:=2; LastDir:=gostop;
end;
goDown:
if y<22 then inc(y)
else begin
y:=22; LastDir:=gostop;
end;
end;
until keyPressed; {обработка нажатия клавиши}
ch:=Upcase(readkey);
case ch of
#0: begin
ch:=readkey;
case ch of
LEFT: LastDir:=goLeft;
RIGHT: LastDir:=GoRight;
UP: LastDir:=goUp;
DOWN: LastDir:=goDown;
end;
end;
ESC: halt;
end;
until false;
end.

Оценка - 1.0 (10)

2010-07-17 • Просмотров [ 2000 ]