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

Username:   Password: 
 RegisterRegister   
 applying delay to a specific part of a loop
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
neverstopbelevin




PostPosted: Thu Nov 18, 2010 7:28 pm   Post subject: applying delay to a specific part of a loop

in my code, im trying to get a maple leaf to appear in a random location and the user must click it to win.

the problem is that if i delay the time it takes for a maple leaf to show up, i must delay the movement of the mouse, however I do not want to delay the mouse movement, only the amount of time it takes for a maple leaf to show up.

code:

loop
    cls
    a := Rand.Int (0, maxx)
    b := Rand.Int (0, maxy)
    c1 := a + 50
    d := b + 50
    drawfillmapleleaf (a, b, c1, d, red)
    mousewhere (mx, my, mb)
    drawline (mx - maxx, my, mx + maxx, my, red)
    drawline (mx, my - maxy, mx, my + maxy, black)
    if mb = 1 and
            whatdotcolour (mx, my) = red
            then
        put "You Win"
        exit when whatdotcolour (mx, my) = red
    end if
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
TerranceN




PostPosted: Thu Nov 18, 2010 7:37 pm   Post subject: RE:applying delay to a specific part of a loop

Create a counter outside your loop and increment it every time your loop goes around. Use an if statement so that once that counter gets above a certain value, it moves the maple leaf and resets the counter back to 0.
neverstopbelevin




PostPosted: Thu Nov 18, 2010 8:08 pm   Post subject: RE:applying delay to a specific part of a loop

okay, thats solved
neverstopbelevin




PostPosted: Thu Nov 18, 2010 8:25 pm   Post subject: RE:applying delay to a specific part of a loop

thhanks
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  [ 4 Posts ]
Jump to:   


Style:  
Search: