diff --git a/lazarus/bombs/project1.ico b/lazarus/bombs/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/bombs/project1.ico differ diff --git a/lazarus/bombs/project1.lpi b/lazarus/bombs/project1.lpi new file mode 100644 index 0000000..c490021 --- /dev/null +++ b/lazarus/bombs/project1.lpi @@ -0,0 +1,80 @@ + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/lazarus/bombs/project1.lpr b/lazarus/bombs/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/bombs/project1.lpr @@ -0,0 +1,21 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/lazarus/bombs/project1.res b/lazarus/bombs/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/bombs/project1.res differ diff --git a/lazarus/bombs/unit1.lfm b/lazarus/bombs/unit1.lfm new file mode 100644 index 0000000..06bc782 --- /dev/null +++ b/lazarus/bombs/unit1.lfm @@ -0,0 +1,42 @@ +object Form1: TForm1 + Left = 202 + Height = 550 + Top = 210 + Width = 812 + Caption = 'Form1' + ClientHeight = 550 + ClientWidth = 812 + OnCreate = FormCreate + LCLVersion = '1.6.2.0' + object Image1: TImage + Left = 0 + Height = 550 + Top = 0 + Width = 812 + Align = alClient + OnMouseDown = Image1MouseDown + OnMouseMove = Image1MouseMove + end + object Shape1: TShape + Left = 192 + Height = 16 + Top = 112 + Width = 16 + Shape = stEllipse + Visible = False + end + object Label1: TLabel + Left = 8 + Height = 42 + Top = 8 + Width = 247 + Caption = 'Paint landscape by left mouse button,'#10'and drom bombs by right button.' + ParentColor = False + end + object Timer1: TTimer + Interval = 10 + OnTimer = Timer1Timer + left = 240 + top = 16 + end +end diff --git a/lazarus/bombs/unit1.pas b/lazarus/bombs/unit1.pas new file mode 100644 index 0000000..daecb21 --- /dev/null +++ b/lazarus/bombs/unit1.pas @@ -0,0 +1,89 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, + StdCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Image1: TImage; + Label1: TLabel; + Shape1: TShape; + Timer1: TTimer; + procedure FormCreate(Sender: TObject); + procedure Image1MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer + ); + procedure Timer1Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + speed: single; + +implementation + +{$R *.lfm} + +procedure TForm1.FormCreate(Sender: TObject); +begin + Image1.Canvas.Brush.Color := clWhite; + Image1.Canvas.FillRect(Image1.ClientRect); +end; + +procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + if Button = mbRight then begin + Shape1.Left := round(x - Shape1.Width/2); + Shape1.Top := round(y - Shape1.Height/2); + Shape1.Visible := true; + speed := 0; + end; +end; + +procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + if ssLeft in Shift then begin + Image1.Canvas.Pen.Width := 50; + Image1.Canvas.Pen.Style := psSolid; + Image1.Canvas.LineTo(x, y); + end else begin + Image1.Canvas.MoveTo(x, y); + end; +end; + +procedure TForm1.Timer1Timer(Sender: TObject); +var + x, y: integer; +begin + if Shape1.Visible then begin + Shape1.Top := Round(Shape1.Top + speed); + speed := speed + 1; + if Shape1.Top > ClientHeight then Shape1.Visible := false; + + x := round(Shape1.Left + Shape1.Width/2); + y := round(Shape1.Top + Shape1.Height/2); + if Image1.Canvas.Pixels[x, y] = clBlack then begin + Shape1.Visible := false; + Image1.Canvas.Pen.Style := psClear; + Image1.Canvas.Ellipse(round(x-speed), round(y-speed), round(x+speed), round(y+speed)); + end; + end; +end; + +end. +