1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
Timer1: TTimer;
Shape1: TShape;
procedure Timer1Timer(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form2: TForm2;
i,j : integer;
implementation
{$R *.dfm}
procedure TForm2.FormActivate(Sender: TObject);
begin
i := 1;
j := 1;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
form2.Caption := 'la balle qui rebondie';
end;
procedure TForm2.Timer1Timer(Sender: TObject);
begin
Shape1.Left := Shape1.left+ i;
Shape1.Top := Shape1.top +j ;
if Shape1.Left + Shape1.Width >= form2.ClientWidth then
begin
i:=-i;
j:=j;
Shape1.Brush.Color:= clred;
// ball.Brush.Style:= bscross
end;
if Shape1.Top < 0 then
begin
i:=i;
j:=-j;
Shape1.brush.color := clblue;
// ball.Brush.Style := bsvertical;
end;
if Shape1.left < 0 then
begin
i:=-i;
j:=j;
Shape1.brush.color := clgreen;
// ball.Brush.Style := bshorizontal;
end;
if Shape1.Top + Shape1.Height > form2.ClientHeight then
begin
j := -j;
i := i;
Shape1.Brush.Style := bssolid;
Shape1.Brush.Color := clyellow;
end;
end;
end. |
Partager