|
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ExtCtrls; | |
TForm1 = class(TForm) | |
Timer1: TTimer; | |
procedure FormCreate(Sender: TObject); | |
procedure FormClose(Sender: TObject; var Action: TCloseAction); | |
procedure Timer1Timer(Sender: TObject); | |
procedure FormMouseDown(Sender: TObject; Button: TMouseButton; | |
Shift: TShiftState; X, Y: Integer); | |
{ Private declarations } | |
{ Public declarations } | |
Form1: TForm1; | |
x, y, vx, vy: integer; | |
UFO: Tbitmap; | |
mx,my:integer; | |
procedure TForm1.FormCreate(Sender: TObject); | |
UFo.LoadFromFile('ufo.bmp'); | |
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); | |
procedure TForm1.Timer1Timer(Sender: TObject); | |
d:= sqr(x+32-mx)+sqr(y+16-my); | |
vx := vx + round( (x+32-mx)*100/d ); | |
vy := vy + round( (y+16-my)*100/d ); | |
Form1.Canvas.Brush.Color := clBlack; | |
Form1.Canvas.FillRect(Rect(x,y,x+64,y+32)); | |
if x+64 >= Form1.ClientWidth then vx := -10; | |
if y+32 >= Form1.ClientHeight then vy := -3; | |
Form1.Canvas.Draw(x,y,ufo); | |
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton; | |
Shift: TShiftState; X, Y: Integer); | |