cdar

view unit_Easteregg.pas @ 2:104f349dcfcc

Added tag cdar-2.3 for changeset 87b91371db05b8cabe2dc3e2d2dc3ba830ab463b
author "Meillo r e t u r n s <meillo@marmaro.de>"
date Sun, 03 Dec 2006 21:56:41 +0100
parents
children
line source
1 unit unit_Easteregg;
3 interface//####################################################################################
5 uses
6 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7 Dialogs, jpeg, ExtCtrls;
9 type
10 Tform_easteregg = class(TForm)
11 img_Marmaro: TImage;
12 Timer1: TTimer;
13 procedure img_MarmaroClick(Sender: TObject);
14 procedure Timer1Timer(Sender: TObject);
15 procedure FormCreate(Sender: TObject);
16 private
17 vx : integer;
18 vy : integer;
19 x1 : integer;
20 y1 : integer;
21 x2 : integer;
22 y2 : integer;
23 public
24 { Public declarations }
25 end;
27 var
28 form_easteregg: Tform_easteregg;
30 implementation//###############################################################################
32 {$R *.dfm}//###################################################################################
34 //------------------------------------------------------------------------------ form create
35 procedure Tform_easteregg.FormCreate(Sender: TObject);
36 begin
37 vx := 0;
38 vy := 0;
39 x1 := form_Easteregg.Left + (form_Easteregg.Width div 2);
40 y1 := form_Easteregg.top + (form_Easteregg.height div 2);
41 x2 := screen.Width div 2;
42 y2 := screen.Height div 2;
43 end;//--------------------------------------------------------------------------
45 //#############################################################################################
47 //------------------------------------------------------------------------------ kill
48 procedure Tform_easteregg.img_MarmaroClick(Sender: TObject);
49 begin
50 application.Terminate;
51 end;//--------------------------------------------------------------------------
53 //------------------------------------------------------------------------------ move form
54 procedure Tform_easteregg.Timer1Timer(Sender: TObject);
55 begin
56 // keep window in foreground
57 SetWindowPos(handle, HWND_TopMost, left, top, width, height, SWP_ShowWindow);
59 randomize; // for better random
61 x1 := form_Easteregg.Left + (form_Easteregg.Width div 2);
62 y1 := form_Easteregg.top + (form_Easteregg.height div 2);
64 if x1 < x2 then
65 begin
66 vx := vx + (random(10)-4);
67 end
68 else
69 begin
70 vx := vx + (random(10)-6);
71 end;
73 if y1 < y2 then
74 begin
75 vy := vy + (random(10)-4);
76 end
77 else
78 begin
79 vy := vy + (random(10)-6);
80 end;
82 if (vx > 0) then form_easteregg.Left := form_easteregg.Left + (random(2)+1)
83 else form_easteregg.Left := form_easteregg.Left - (random(2)+1);
85 if (vy > 0) then form_easteregg.top := form_easteregg.top + (random(2)+1)
86 else form_easteregg.top := form_easteregg.top - (random(2)+1);
88 if form_easteregg.Left < 0 then form_Easteregg.left := 0;
89 if form_easteregg.Left > screen.Width - form_easteregg.Width then
90 form_Easteregg.Left := screen.Width - form_Easteregg.Width;
91 if form_easteregg.top < 0 then form_Easteregg.top := 0;
92 if form_easteregg.top > screen.Height - form_easteregg.height then
93 form_Easteregg.top := screen.Height - form_Easteregg.height;
94 end;//--------------------------------------------------------------------------
97 end.//########################################################################################