Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Computer Graphics Exercises [9/9]

Exercise 8 output image

Change the program so that the right column of discs is drawn in the opposite order, from the bottom to the top. The screen is 720 pixels high.

Then, change the second for loop so that the corresponding discs are connected by lines.

Hint 1

It is easier to make changes in the first for loop. When it works correctly, make changes in the second for loop.

Hint 2

Since this task requires a reversal of direction, a subtraction operation needs to be used.

Hint 3

Which coordinate needs changing, x or y?

Solution

for #i=10..720 +=50
	{
	disc(100, i, 10);
	disc(800, 720-i, 10);
    sleepMs(100);
	}
	
for #i=10..720 +=50
	{
	line(100, i, 800, 720-i);
    sleepMs(100);
	}

Click on the 'Articles' button at the top to select another article. We also suggest taking a peak into our main 'Gallery' of programs, and taking a look into 'Overview' of our main programming tutorial for beginners. Have fun!

Loading...