Blame lazarus/bombs/unit1.pas

c22d5d
unit Unit1;
c22d5d
c22d5d
{$mode objfpc}{$H+}
c22d5d
c22d5d
interface
c22d5d
c22d5d
uses
c22d5d
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
c22d5d
  StdCtrls;
c22d5d
c22d5d
type
c22d5d
c22d5d
  { TForm1 }
c22d5d
c22d5d
  TForm1 = class(TForm)
c22d5d
    Image1: TImage;
c22d5d
    Label1: TLabel;
c22d5d
    Shape1: TShape;
c22d5d
    Timer1: TTimer;
c22d5d
    procedure FormCreate(Sender: TObject);
c22d5d
    procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
c22d5d
      Shift: TShiftState; X, Y: Integer);
c22d5d
    procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer
c22d5d
      );
c22d5d
    procedure Timer1Timer(Sender: TObject);
c22d5d
  private
c22d5d
    { private declarations }
c22d5d
  public
c22d5d
    { public declarations }
c22d5d
  end;
c22d5d
c22d5d
var
c22d5d
  Form1: TForm1;
c22d5d
  speed: single;
c22d5d
c22d5d
implementation
c22d5d
c22d5d
{$R *.lfm}
c22d5d
c22d5d
procedure TForm1.FormCreate(Sender: TObject);
c22d5d
begin
c22d5d
  Image1.Canvas.Brush.Color := clWhite;
c22d5d
  Image1.Canvas.FillRect(Image1.ClientRect);
c22d5d
end;
c22d5d
c22d5d
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
c22d5d
  Shift: TShiftState; X, Y: Integer);
c22d5d
begin
c22d5d
  if Button = mbRight then begin
c22d5d
    Shape1.Left := round(x - Shape1.Width/2);
c22d5d
    Shape1.Top := round(y - Shape1.Height/2);
c22d5d
    Shape1.Visible := true;
c22d5d
    speed := 0;
c22d5d
  end;
c22d5d
end;
c22d5d
c22d5d
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
c22d5d
  Y: Integer);
c22d5d
begin
c22d5d
  if ssLeft in Shift then begin
c22d5d
    Image1.Canvas.Pen.Width := 50;
c22d5d
    Image1.Canvas.Pen.Style := psSolid;
c22d5d
    Image1.Canvas.LineTo(x, y);
c22d5d
  end else begin
c22d5d
    Image1.Canvas.MoveTo(x, y);
c22d5d
  end;
c22d5d
end;
c22d5d
c22d5d
procedure TForm1.Timer1Timer(Sender: TObject);
c22d5d
var
c22d5d
  x, y: integer;
c22d5d
begin
c22d5d
  if Shape1.Visible then begin
c22d5d
    Shape1.Top := Round(Shape1.Top + speed);
c22d5d
    speed := speed + 1;
c22d5d
    if Shape1.Top > ClientHeight then Shape1.Visible := false;
c22d5d
c22d5d
    x := round(Shape1.Left + Shape1.Width/2);
c22d5d
    y := round(Shape1.Top + Shape1.Height/2);
c22d5d
    if Image1.Canvas.Pixels[x, y] = clBlack then begin
c22d5d
      Shape1.Visible := false;
c22d5d
      Image1.Canvas.Pen.Style := psClear;
c22d5d
      Image1.Canvas.Ellipse(round(x-speed), round(y-speed), round(x+speed), round(y+speed));
c22d5d
    end;
c22d5d
  end;
c22d5d
end;
c22d5d
c22d5d
end.
c22d5d