1 REM X,Y = coordinates of the ball

2 REM XN = the new X coordinate

3 REM YN = the new Y coordinate

4 REM XD = the X direction of motion

5 REM YD = the Y direction of motion (for each space in the X direction)

6 REM

10 GR : COLOR= 3

20 VLIN O,39 AT 19: VLIN 0,39 AT 21

30 X = 0:Y = 0

40 XD = 1:YD = 1

50 COLOR= 5: PLOT X,Y

60 XN = X +XD

70 IF XN = 0 THEN XD = 1

80 IF XN = 39 THEN XD = - 1

90 YN = Y + YD

100 IF YN < 0 THEN YD = INT (2 * RND (1) + 1):YN = Y + YD: GOTO 100

110 IF YN > 39 THEN YD = - INT (2 * RND (1) + 1):YN = Y + Y + YD: GOTO 110

120 IF SCRN( XN,YN) = 3 THEN XD = - 1 * XD

130 COLOR= 0: PLOT X,Y

140 X = XN:Y = YN

150 GOTO 50