looping randint
Author |
Message |
be natural*
|
Posted: Sat Jun 07, 2003 2:50 pm Post subject: looping randint |
|
|
in my program, i tried to shoot the bubbles and each time i shoot a bubble, the colour of it changes. So i put randint in the loop to randomize the colour of the bubble, but what happens is that the colours are changing so fast until i press the shift key and then the colour doesn't change while it's being shoot. how can i make the randomly-chosen colour stay as it is before the shooting?
I attached my code below... code: |
View.Set("graphics:400;600")
var xCoor : array 1 .. 3 of int := init (190, 200, 210)
var yCoor : array 1 .. 3 of int := init (5, 75, 5)
var iColor: int
var chars : array char of boolean
Draw.FillPolygon (xCoor, yCoor, 3, brightblue)
Draw.Polygon (xCoor, yCoor, 3, black)
loop
randint (iColor, 1, 5)
drawfilloval (200, 90, 15, 15, iColor)
Input.KeyDown (chars)
if chars (KEY_SHIFT) then
for i : 90 .. 400
drawfilloval (200, i, 15, 15, iColor)
delay (1)
drawfilloval (200, i, 15, 15, white)
end for
drawfilloval (200,400,15,15,iColor)
end if
end loop |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Catalyst
![](http://catalyze.mine.nu/jack_of_spades+100.jpg)
|
Posted: Sat Jun 07, 2003 3:03 pm Post subject: (No subject) |
|
|
Since this is a very simple fix...
all you need to do is randomize the color
after it is shot
code: | View.Set("graphics:400;600")
var xCoor : array 1 .. 3 of int := init (190, 200, 210)
var yCoor : array 1 .. 3 of int := init (5, 75, 5)
var iColor: int :=1
var chars : array char of boolean
Draw.FillPolygon (xCoor, yCoor, 3, brightblue)
Draw.Polygon (xCoor, yCoor, 3, black)
loop
drawfilloval (200, 90, 15, 15, iColor)
Input.KeyDown (chars)
if chars (KEY_SHIFT) then
for i : 90 .. 400
drawfilloval (200, i, 15, 15, iColor)
delay (1)
drawfilloval (200, i, 15, 15, white)
end for
drawfilloval (200,400,15,15,iColor)
randint (iColor, 1, 5)
end if
end loop |
|
|
|
|
|
![](images/spacer.gif) |
|
|