Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
3
Indexable
Never
Uses GraphABC;

Procedure Smile (X, Y, Size : Integer);
begin
  Circle(X + Size div 2, Y + Size div 2, Size div 2);
  Circle(X + Size div 4, Y + Size div 8 * 3, Size div 10);
  Circle(X + Size * 3 div 4, Y + Size div 8 * 3, Size div 10);
  Arc(X + Size div 2, Y + Size div 2, Size div 4, 200, 340);
end;

Const Sz = 20;

Var WW, WH, X, Y, D, DirectX, DirectY: Integer;
    F : Text;
    
Procedure KeyDown(Key: Integer);
begin
  Case Key Of
  VK_Add:
    D := D + 1;
  VK_Subtract:
    if D > 1 Then
     D := D - 1;
  VK_Escape:
    begin
      Rewrite(F);
      Writeln(F, X,' ', Y);
      Close(F);
      CloseWindow;
    End;
  end;
end;     

Begin
  WW := WindowWidth;
  WH := WindowHeight;
  
  ClearWindow(clBlack);
  
  Assign(F, '8.2.txt');
  Reset(F);
  Readln(F, X, Y);
  Close(F);
  
  D := 10;
  DirectX := 1;
  DirectY := 1;
  
  OnKeyDown := KeyDown;
  
  SetSmoothing(False);
  SetBrushColor(clBlack);
  Repeat
    SetPenColor(clWhite);
    Smile(X, Y, Sz);
    Sleep(30);
    
    SetPenColor(clBlack);
    Smile(X, Y, Sz);
    
    If X <= 0 Then
      DirectX := 1;
    if X >= WW - Sz Then
      DirectX := -1;
   If Y <= 0 Then
      DirectY := 1;
    if Y >= WH - Sz Then
      DirectY := -1;

    X := X + DirectX * D;
    Y := Y + DirectY * D;
  Until False;
end.