Управление точкой на экране

code: #pascal
uses graph,crt;
var gd,gm,x,y,x1,y1:integer;
    c:char;
label 0,1,2,3,4;
begin
initgraph(gd,gm,'c:\bp\bgi');
y:= 50;
x:= 50;
outtext('Press up, down, left ,right aroow keys for moving the point');
outtextxy(10,10,'Press Esc to Exit');
0:
c:=readkey;
if c=chr(27) then halt;
if ord(c)=72 then goto 1;
if ord(c)=80 then goto 2;
if ord(c)=75 then goto 3;
if ord(c)=77 then goto 4;
GOTO 0;
1:
y := y - 1;
IF y < 1 THEN y:= 2;
putpixel(x1, y1, 0);
putpixel(x, y, 15);
x1 := x; y1 := y;
goto 0;
2:
putpixel(x, y, 0);
y := y + 1;
IF y > 479 THEN y := 478;
putpixel (x1, y1, 0);
putpixel (x, y, 15);
x1 := x; y1 := y;
goto 0;
3:
x := x - 1;
IF x < 1 THEN x := 2;
putpixel(x1, y1, 0);
putpixel (x, y, 15);
x1 := x; y1 := y;
goto 0;
4:
x := x + 1;
IF x > 639 THEN x := 638;
putpixel (x1, y1, 0);
putpixel (x, y, 15);
x1:= x; y1 := y;
goto 0;
end.
Поделиться:

Похожие статьи: