Learn to Program with ZedLX

Free Online Programming Course for Beginners

Simple Graphics [13/15]

This program draws two lines of discs simultaneously. The discs are 50 pixels apart.
[Run the program]

Exercise:

Iteration Line Ends 1 Exercise output image

Draw lines connecting the centers of disc pairs.

If you need help, then examine the hints carefully one by one. If you're still having trouble, take a look at the solution.

Hint 1

Since the lines connect disc centers, use the same coordinates for the line procedure call as for the corresponding disc procedure calls.

Hint 2

The disc procedure has the form:
disc(x, y, radius, color)

The line procedure has the form:
line(x1, y1, x2, y2)

Solution

Just above the call to sleepMs, insert: line(i, 100, i, 700);

Loading...