diff --git a/lazarus/hide-n-seek/project1.ico b/lazarus/hide-n-seek/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/hide-n-seek/project1.ico differ diff --git a/lazarus/hide-n-seek/project1.lpi b/lazarus/hide-n-seek/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/hide-n-seek/project1.lpi @@ -0,0 +1,79 @@ + + + + + + + + + <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"/> + <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/hide-n-seek/project1.lpr b/lazarus/hide-n-seek/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/hide-n-seek/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/hide-n-seek/project1.res b/lazarus/hide-n-seek/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/hide-n-seek/project1.res differ diff --git a/lazarus/hide-n-seek/unit1.lfm b/lazarus/hide-n-seek/unit1.lfm new file mode 100644 index 0000000..b38e801 --- /dev/null +++ b/lazarus/hide-n-seek/unit1.lfm @@ -0,0 +1,47 @@ +object Form1: TForm1 + Left = 373 + Height = 476 + Top = 306 + Width = 588 + Caption = 'Form1' + ClientHeight = 476 + ClientWidth = 588 + OnMouseMove = FormMouseMove + LCLVersion = '1.6.2.0' + object Shape1: TShape + Left = 58 + Height = 61 + Top = 75 + Width = 86 + OnMouseMove = Shape1MouseMove + Shape = stRoundRect + end + object Panel1: TPanel + Left = 344 + Height = 61 + Top = 131 + Width = 216 + Caption = 'Another Safe Place' + TabOrder = 0 + end + object Panel2: TPanel + Left = 48 + Height = 154 + Top = 296 + Width = 249 + Caption = 'Sweet Home' + TabOrder = 1 + end + object Timer1: TTimer + Interval = 10 + OnTimer = Timer1Timer + left = 26 + top = 12 + end + object Timer2: TTimer + Interval = 500 + OnTimer = Timer2Timer + left = 65 + top = 12 + end +end diff --git a/lazarus/hide-n-seek/unit1.pas b/lazarus/hide-n-seek/unit1.pas new file mode 100644 index 0000000..32c6033 --- /dev/null +++ b/lazarus/hide-n-seek/unit1.pas @@ -0,0 +1,73 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Panel1: TPanel; + Panel2: TPanel; + Shape1: TShape; + Timer1: TTimer; + Timer2: TTimer; + procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); + procedure Shape1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer + ); + procedure Timer1Timer(Sender: TObject); + procedure Timer2Timer(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + mouseX, mouseY: integer; + +implementation + +{$R *.lfm} + +procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + mouseX := X; + mouseY := Y; +end; + +procedure TForm1.Timer1Timer(Sender: TObject); +begin + if Shape1.Left + Shape1.Width div 2 < mouseX then Shape1.Left := Shape1.Left + 5; + if Shape1.Left + Shape1.Width div 2 > mouseX then Shape1.Left := Shape1.Left - 5; + if Shape1.Top + Shape1.Height div 2 < mouseY then Shape1.Top := Shape1.Top + 5; + if Shape1.Top + Shape1.Height div 2 > mouseY then Shape1.Top := Shape1.Top - 5; +end; + +procedure TForm1.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +begin + Beep; + Shape1.Brush.Color := clRed; + Cursor := crNone; + Timer2.Enabled := true; + Timer1.Enabled := false; +end; + +procedure TForm1.Timer2Timer(Sender: TObject); +begin + Cursor := crDefault; + Shape1.Brush.Color := clWhite; + Timer1.Enabled := true; + Timer2.Enabled := false; +end; + +end. +