procedure TWall.hitBy (aBall : TBall);
begin
{ bounce the ball off the wall }
aBall.direction := convertFactor - aBall.direction;
end;
procedure THole.hitBy (aBall : TBall);
begin
{ drain enery from ball }
aBall.energy := 0.0;
{ move ball }
if aBall = CueBall then
aBall.setCenter(50, 100)
else begin
saveRack := saveRack + 1;
aBall.setCenter (10 + saveRack * 15, 250);
end;
end;
procedure TBall.hitBy (aBall : TBall);
var
da : real;
begin
{ cut the energy of the hitting ball in half }
aBall.energy := aBall.energy / 2.0;
{ and add it to our own }
energy := energy + aBall.energy;
{ set our new direction }
direction := hitAngle(self.x - aBall.x, self.y - aBall.y);
{ and set the hitting balls direction }
da := aBall.direction - direction;
aBall.direction := aBall.direction + da;
{ continue our update }
update;
end;