Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

while Loop and Keyboard [5/11]

This program draws a disc at the horizontal position i.

The result is a simple animation.

After running and studying the program, change the third argument (the literal 100) of the disc function call to some other value and observe how it affects the output. Try values 20 and 200.

Exercise 1

Modify the program so that the disc increases in size while moving.

Solution

disc(i, 200, i/4, /red);

After that, change the second argument (i.e. literal 200) to some other value and observe how it affects the output. Try values 600 and 300.

Exercise 2

Modify the program so that the disc moves vertically, in a direction from the top to the bottom.

Solution

disc(200, i, 100, /red);

Loading...