Oh , didnt know about that
.
I just read
http://www.delphibasics.co.uk/RTL.asp?Name=Randomize about randomize
But I still dont get at all how it works .
Do I have to always use the ' i ' and the ' loop ' or if I just put 'randomize' before any random function then it will works ?
Like this ?
procedure TForm1.PlayClick(Sender: TObject);
begin
randomize; roll := 0;
cd := 0;
rt1 := 2 + random(5);
rt2 := 2 + random(5);
r1 := rt1;
r2 := rt2;
Label3.Caption := IntToStr(r1);
Label4.Caption := IntToStr(r2);
Timer1.Enabled := True;
end;
will it work in the Timer too ?procedure TForm1.Timer1Timer(Sender: TObject);
begin
randomize; roll := roll + 0.0157;
if roll < rt1
then a := 1 + random(6)
else a := a;
if roll < rt2
then b := 1 + random(6)
else b := b;
Label1.Caption := IntToStr(a);
Label2.Caption := IntToStr(b);
cd := cd + 0.0157;
if cd > 1 then
begin
cd := 0;
if r1 > 0 then
r1 := r1 - 1;
if r2 > 0 then
r2 := r2 - 1;
end;
Label4.Caption := IntToStr(r1);
Label4.Caption := IntToStr(r2);
if (r1 = 0) and (r2 = 0) then
Timer1.Enabled := False;
end;