Computer Science Canada

Drawing Circrles from left to right, 40 total, random colors

Author:  moneyhoney [ Tue Mar 05, 2013 2:52 pm ]
Post subject:  Drawing Circrles from left to right, 40 total, random colors

Exercise: 5. Draw 40 small circles starting at the middle left of the screen extending to the middle right of the screen. Make each circle a random color.

left question at school, in case you guys know how. I'll write up a new one, editing this thread soon.

Author:  Raknarg [ Tue Mar 05, 2013 4:58 pm ]
Post subject:  RE:Drawing Circrles from left to right, 40 total, random colors

Are you asking us to program it for you?

Author:  moneyhoney [ Tue Mar 05, 2013 7:03 pm ]
Post subject:  Re: RE:Drawing Circrles from left to right, 40 total, random colors

Raknarg @ Tue Mar 05, 2013 4:58 pm wrote:
Are you asking us to program it for you?


No

var circleCount : int
var circleColour : int
var x : int
var y : int

y := maxy div 2
x := 15
circleCount := 0
loop
randint (circleColour, 1, 255)
Draw.FillOval (x, y, 15, 15, circleColour)

circleCount := circleCount + 1
x := x + 15
end loop

I need to know how to make it 40 circles.

Author:  evildaddy911 [ Tue Mar 05, 2013 7:37 pm ]
Post subject:  Re: Drawing Circrles from left to right, 40 total, random colors

the infinite loop will make an infinite amount of circles. do you know how to repeat a fixed number of times?
hint: try a different type of loop

Author:  Raknarg [ Wed Mar 06, 2013 7:53 pm ]
Post subject:  RE:Drawing Circrles from left to right, 40 total, random colors

or in case they dont know already... Basically every language has a structure called a for loop, which loops for only a specific amount of iterations.

In this case, it's structured like this:

for i : 1 .. n

end for

i being what you want to call the loop, and n being the number of times for it to iterate.

Author:  KingGrumpz [ Thu Mar 07, 2013 9:49 pm ]
Post subject:  RE:Drawing Circrles from left to right, 40 total, random colors

if you want to keep the code you have use an exit when statement
(Ex. exit when Letter = "a")

Author:  Raknarg [ Sat Mar 09, 2013 6:17 pm ]
Post subject:  RE:Drawing Circrles from left to right, 40 total, random colors

Or, you know, teach him a much better concept


: