Bouncing ball simulation

(*by Nasser Abbasi January 14,2008*)
x=RandomReal[{-0.9,0.9}];
y=RandomReal[{-0.9,0.9}];
r=0.1;

g=Disk[{x,y},r];

Dynamic[Refresh[Graphics[g,ImageMargins->0,
Frame->True,
ImagePadding->1,
PlotRangeClipping->False,
PlotRange->1],
UpdateInterval->$TimeUnit,TrackedSymbols->{g}],
SynchronousUpdating->True
]

simulationTime=1000;
dx=0.01;dy=0.01;

For[k=1,k≤simulationTime,k++,
{
g=Disk[{x+=dx,y+=dy},r];
FinishDynamic[];(*to eliminate flicker*)
If[Abs[x]≥0.9,dx=-dx];
If[Abs[y]≥0.9,dy=-dy];
Pause[$TimeUnit*2]
}
]