Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

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 centers of disc pairs.

If you cannot solve this exercise, then first examine the hints carefully one by one. Make a good effort. If you still cannot solve the exercise, take a look at the solution.

Hint 1

Since the lines connect disc centers, the line procedure call has to use the same coordinates as the 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 sleepMs statement, insert: line(i, 100, i, 700);

Loading...