cdar

diff unit_Easteregg.pas @ 0:ef71164288c1

begin of using hg for cdar
author "Meillo r e t u r n s <meillo@marmaro.de>"
date Sun, 03 Dec 2006 21:54:43 +0100
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/unit_Easteregg.pas	Sun Dec 03 21:54:43 2006 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +unit unit_Easteregg;
     1.5 +
     1.6 +interface//####################################################################################
     1.7 +
     1.8 +uses
     1.9 +  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    1.10 +  Dialogs, jpeg, ExtCtrls;
    1.11 +
    1.12 +type
    1.13 +  Tform_easteregg = class(TForm)
    1.14 +    img_Marmaro: TImage;
    1.15 +    Timer1: TTimer;
    1.16 +    procedure img_MarmaroClick(Sender: TObject);
    1.17 +    procedure Timer1Timer(Sender: TObject);
    1.18 +    procedure FormCreate(Sender: TObject);
    1.19 +  private
    1.20 +    vx : integer;
    1.21 +    vy : integer;
    1.22 +    x1 : integer;
    1.23 +    y1 : integer;
    1.24 +    x2 : integer;
    1.25 +    y2 : integer;
    1.26 +  public
    1.27 +    { Public declarations }
    1.28 +  end;
    1.29 +
    1.30 +var
    1.31 +  form_easteregg: Tform_easteregg;
    1.32 +
    1.33 +implementation//###############################################################################
    1.34 +
    1.35 +{$R *.dfm}//###################################################################################
    1.36 +
    1.37 +//------------------------------------------------------------------------------ form create
    1.38 +procedure Tform_easteregg.FormCreate(Sender: TObject);
    1.39 +begin
    1.40 +  vx := 0;
    1.41 +  vy := 0;
    1.42 +  x1 := form_Easteregg.Left + (form_Easteregg.Width div 2);
    1.43 +  y1 := form_Easteregg.top + (form_Easteregg.height div 2);
    1.44 +  x2 := screen.Width div 2;
    1.45 +  y2 := screen.Height div 2;
    1.46 +end;//--------------------------------------------------------------------------
    1.47 +
    1.48 +//#############################################################################################
    1.49 +
    1.50 +//------------------------------------------------------------------------------ kill
    1.51 +procedure Tform_easteregg.img_MarmaroClick(Sender: TObject);
    1.52 +begin
    1.53 +  application.Terminate;
    1.54 +end;//--------------------------------------------------------------------------
    1.55 +
    1.56 +//------------------------------------------------------------------------------ move form
    1.57 +procedure Tform_easteregg.Timer1Timer(Sender: TObject);
    1.58 +begin
    1.59 +  // keep window in foreground
    1.60 +  SetWindowPos(handle, HWND_TopMost, left, top, width, height, SWP_ShowWindow);
    1.61 +
    1.62 +  randomize; // for better random
    1.63 +
    1.64 +  x1 := form_Easteregg.Left + (form_Easteregg.Width div 2);
    1.65 +  y1 := form_Easteregg.top + (form_Easteregg.height div 2);
    1.66 +
    1.67 +  if x1 < x2 then
    1.68 +    begin
    1.69 +        vx := vx + (random(10)-4);
    1.70 +    end
    1.71 +  else
    1.72 +    begin
    1.73 +        vx := vx + (random(10)-6);
    1.74 +    end;
    1.75 +
    1.76 +  if y1 < y2 then
    1.77 +    begin
    1.78 +        vy := vy + (random(10)-4);
    1.79 +    end
    1.80 +  else
    1.81 +    begin
    1.82 +        vy := vy + (random(10)-6);
    1.83 +    end;
    1.84 +
    1.85 +  if (vx > 0) then form_easteregg.Left := form_easteregg.Left + (random(2)+1)
    1.86 +  else form_easteregg.Left := form_easteregg.Left - (random(2)+1);
    1.87 +
    1.88 +  if (vy > 0) then form_easteregg.top := form_easteregg.top + (random(2)+1)
    1.89 +  else form_easteregg.top := form_easteregg.top - (random(2)+1);
    1.90 +
    1.91 +  if form_easteregg.Left < 0 then form_Easteregg.left := 0;
    1.92 +  if form_easteregg.Left > screen.Width - form_easteregg.Width then
    1.93 +      form_Easteregg.Left := screen.Width - form_Easteregg.Width;
    1.94 +  if form_easteregg.top < 0 then form_Easteregg.top := 0;
    1.95 +  if form_easteregg.top > screen.Height - form_easteregg.height then
    1.96 +      form_Easteregg.top := screen.Height - form_Easteregg.height;
    1.97 +end;//--------------------------------------------------------------------------
    1.98 +
    1.99 +
   1.100 +end.//########################################################################################