' Draw 100 circles, each in a new color ' (complete program) ' SCREEN 12 ' LET HUE = 4 LET COUNT = 1 ' DO WHILE COUNT <= 100 ' LET HUE = HUE + 1 ' IF HUE >= 16 THEN LET HUE = 1 END IF ' COLOR HUE CIRCLE (320, 240),50 SLEEP 1 ' LET COUNT = COUNT + 1 LOOP ' END
Now the program works. Each time HUE gets larger it is checked:
IF HUE >= 16 THEN
If it is too big, HUE is changed to 1:
HUE = 1
Now HUE has to build back up again.
Notice how the program has been put together out of different pieces:
' Draw 100 circles, ' each in a new color ' (complete program) ' SCREEN 12 ' LET HUE = 4 LET COUNT = 1 ' DO WHILE COUNT <= 100 ' LET HUE = HUE + 1 ' IF HUE >= 16 THEN LET HUE = 1 END IF ' COLOR HUE CIRCLE (320, 240),50 SLEEP 1 ' LET COUNT = COUNT + 1 LOOP ' END
There are the counting loop pieces,
there are the graphics pieces, and there are the
pieces that keep HUE
in range.
How could you modify the CIRCLE
statement in this program so that
each time a circle is drawn it is larger than the previous one?
(There are several answers to this question.)