Introduction to OOP: Chapter 6: Case Study: A Billiards Game
[next]
[previous]
[audio]
[real]
[text]
Reaction to Mouse Down Events
procedure mouseButtonDown (x, y : integer);
var
bptr : Ball;
begin
(* give the cue ball some energy *)
CueBall.energy := 20.0;
(* and a direction *)
CueBall.setDirection(hitAngle (cueBall.x - x, cueBall.y - y));
(* then update as long as any ball moves *)
ballMoved := true;
while ballMoved do begin
ballMoved := false;
bptr := listOfBalls;
while bptr <> nil do begin
bptr.update;
bptr := bptr.link;
end;
end;
end;
Intro OOP, Chapter 6, Slide 9