Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 looping randint
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
be natural*




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: