this slowpoke moves

Draw Smilies

public
    procedure PaintFace(x,y: integer);
    procedure EraseFace(x,y: integer); 
    
var
  Form1: TForm1;
  fx,fy: integer;
  n: integer;
  p: integer;
  
//

procedure TForm1.PaintFace(x,y: integer);
begin
    Canvas.Pen.Color := clBlack;
    Canvas.Brush.Color := clYellow;
    Canvas.Ellipse(x,y,x+30,Y+30);
    Canvas.Ellipse(x+9,y+10,x+11,y+13);
    Canvas.Ellipse(x+19,y+10,x+21,y+13);
    Canvas.Arc(x+4,y+4,x+26,y+26,x,y+20,x+30,y+20);
end;

procedure TForm1.EraseFace(x,y: integer);
begin
   Canvas.Pen.Color := clBtnFace;
   Canvas.Brush.Color := clBtnFace;
   Canvas.Ellipse(x,y,x+30,y+30);
end;

procedure TForm1.TimerTimer(Sender: TObject);
begin
    EraseFace(fx,fy);
    fx:= Random(ClientWidth-30);
    fy:= Random(ClientHeight-30);
    PaintFace(fx,fy);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    fx:=100;
    fy:=100;
    Randomize;  
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  inc(n);  
  if (x > fx) and (x < fx+30) and
     (y > fy) and (y < fy+30)
  then begin
       inc(p);
       end;
  if n = 10 then
    begin
        Timer.Enabled := False; 
        ShowMessage('All met 10. Pant : ' +
                 IntToStr(p)+'.');
        EraseFace(fx,fy);
        Label1.Visible := True;
        Button1.Visible := True;
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
    Label1.Visible := False;  
    Button1.Visible := False; 
    Timer.Enabled := True;    
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate