Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Computer Graphics Exercises [4/9]

The given program draws discs positioned on a vertical line at x = 480. Disc centers are 50 pixels apart.

Some exercises must be difficult. If all of them could just be easily solved by everyone, then the exercises would be boring, and they would lack educational value. A lot can be learned from a difficult exercise, escpecially when the solution is peeked at only after a few minutes of sincere effort.

Exercise:

Exercise 3 output image

Change the program so that discs are drawn on a diagonal line. The distance from the center of any disc to the top screen edge equals the distance to the left screen edge, which means that the x and y coordinates of disc centers must be equal ( x = y ).

Hint 1

The task requires changing the position of the discs on the left-right axis. Therefore, the x-coordinate of the discs needs to be modified.

Hint 2

The first argument of the disc function specifies the x-coordinate. Also try re-reading the exercise text.

The solution is on the next slide.

Loading...