[DELPHI] zmiana koloru po przejściu problem

Witam

Mam programik, który posiada 2 przyciski “START” i “STOP”. Przycisk start uruchamia procedurę która tworzy kolkę i przesuwa ją po obwodzie całej formatki zgodnie z ruchem wskazówek zegara.

Kulka po każdym przejściu przez lewy górny róg powinna zmieniać kolor i tu jest cały problem. Jak ktoś ma jakiś pomysł to piszcie.

Kod progz poniżej:

unit Unit1;


interface


uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, ExtCtrls, StdCtrls;


type

  TForm1 = class(TForm)

    Timer1: TTimer;

    Button1: TButton;

    Button2: TButton;

    procedure FormCreate(Sender: TObject);

    procedure Timer1Timer(Sender: TObject);

    procedure Button1Click(Sender: TObject);

    procedure Button2Click(Sender: TObject);

  private

    { Private declarations }

  public

    { Public declarations }

  end;


var

  Form1: TForm1;

  X,Y,skok:integer;


implementation


{$R *.dfm}


procedure TForm1.FormCreate(Sender: TObject);

begin

X:=0;

Y:=0;

Skok:=5;

end;


procedure TForm1.Timer1Timer(Sender: TObject);

begin

refresh;

X:=X+skok;


//Y:=Y+skok;

Canvas.Brush.Color:=color;

Canvas.Ellipse(x,y,x+30,y+30);

If X+30>=ClientWidth then

begin

X:=ClientWidth-30;

Y:=Y+skok;

end;

if Y+30>=clientheight then

begin

Y:=ClientHeight-30;

skok:=-skok;

X:=X-skok;

end;

if X<=0 then

begin

Y:=Y+skok;

X:=0;


end;

if Y<=0 then

begin

skok:=5;

Y:=0;

X:=X+1;

end;


end;


procedure TForm1.Button1Click(Sender: TObject);

begin

Timer1.Enabled:=true;


end;


procedure TForm1.Button2Click(Sender: TObject);

begin

Timer1.Enabled:=false;

end;


end.
..

procedure TForm1.Timer1Timer(Sender: TObject);

begin

refresh;

X:=X+skok;

..

if x=0 and y=0 then color:=color+1;

..

Zastosowałem taki warunek

if (X=0 AND Y=0) then Canvas.Brush.Color:= Rgb(random(255),random(255),random(255));

, ale wyskakuje komunikat:

incopatibile types;

A jak w warunku dla przykładu daję tylko Y=1 wtedy działa. Po rozciągnięciu formatki kolory przestają się zmieniać Jakieś pomysły??

Dodane 24.01.2009 (So) 16:07

Ok już sobie poradziłem

ZAMYKAM TEMAT