以上都没有考虑反射多次的情况,
给出伪代码:
TYPE TLINE=RECORD
POINTSTART:TPOINT;
POINTEND:TPOINT;
END;
FUNCTION GETREFLECTLINE(LINE:TLINE):TLINE;{求得该线的反射线}
BEGIN
{这段代码应该简单}
END;
PROCEDURE DRAWLINE(LINE{初始线}:TLINE;DEEP{反射几次}:INTEGER);
BEGIN
FOR I:=1 TO DEEP DO
BEGIN
LINE:=GETREFLECTLINE(LINE);
DRAW(LINE);
END
END;
{在台球杆旋转时重复执行,就呈现游戏中的那种效果了}
EVENT POLEDIRECTIONROTATE
DRAW(LINE,N)
END