uses crt, graph;
type
TBall = object
public
procedure Show(posX, posY, radius, color, q1, w1, e1, t1, clr : word);
procedure Hide;
public
x, y, r, c : word;
q, w, e, t, m : word;
end;
procedure TBall.Show(posX, posY, radius, color, q1, w1, e1, t1, clr : word);
begin
x := posX;
y := posY;
r := radius;
c := color;
q := q1;
w := w1;
e := e1;
t := t1;
m := clr;
SetColor (m);
Rectangle (q,w,e,t);
SetColor(c);
Circle(x, y, r);
end;
procedure TBall.Hide;
begin
SetColor(black);
Circle(x, y, r);
SetColor(black);
Rectangle (q,w,e,t);
end;
var
gd, gm : integer;
key: char;
dx0, dx1,dx2: integer;
ball, ball1 : TBall;
begin
clrscr;
gd := detect;
InitGraph(gd, gm, '');
ball.Show(150,150,40, White, 100,100,200,200, white);;
readln;
ball.Hide;
readln;
ball.Show(180,180,30, RED, 140,140,220,220, GREEN);;
{ readln;
ball.Hide;}
dx0 := 150;
dx1 := 100;
dx2 := 200;
repeat
key := readkey;
case key of
'w' : begin
ball.hide;
dx0:= dx0+10; dx1:=dx1+10; dx2:=dx2+10;
ball.show (dx0,150, 40, white, dx1,100,dx2,200,white);
readln;
end;
'e' : begin
ball.hide;
ball.Show(182,180,30, RED, 142,140,222,220, GREEN);
readln;
end;
end;
until key <> 'q';
end.
Не могу сообразить как сделать движение вот в этом куске
case key of
'w' : begin
ball.hide;
dx0:= dx0+10; dx1:=dx1+10; dx2:=dx2+10;
ball.show (dx0,150, 40, white, dx1,100,dx2,200,white);
readln;
end;
При нажатии клавиши "w" квадрат с кругом внутри должен перемещаться по оси X