Computer Science Canada

Need help with a loop while doing something else

Author:  LindenRulz [ Fri Feb 16, 2007 5:26 pm ]
Post subject:  Need help with a loop while doing something else

I have a loop created in a procedure and I want to do something while the loop is running. How can I do this?? Mad

Author:  CodeMonkey2000 [ Fri Feb 16, 2007 7:37 pm ]
Post subject:  RE:Need help with a loop while doing something else

What does the loop do? Play music?

Author:  LindenRulz [ Fri Feb 16, 2007 7:56 pm ]
Post subject:  Re: Need help with a loop while doing something else

I am trying to make a game with a traffic light and I loop drawing over the different colour lights with a brighter colour. I want this to happen while using Mouse.Where to move an object.

Author:  Clayton [ Fri Feb 16, 2007 8:39 pm ]
Post subject:  Re: Need help with a loop while doing something else

just have both running in the same loop. The computer runs fast enough that concurrency seems to be happening, so you will be good.

Author:  LindenRulz [ Tue Feb 20, 2007 4:32 pm ]
Post subject:  Re: Need help with a loop while doing something else

I have a few seconds of delay as well so it will only move my object once every few seconds

Author:  Clayton [ Tue Feb 20, 2007 5:19 pm ]
Post subject:  Re: Need help with a loop while doing something else

it would help to see a bit of code so we can provide suggestions to you.

Author:  LindenRulz [ Wed Feb 21, 2007 7:23 pm ]
Post subject:  Re: Need help with a loop while doing something else

Here is a bit of the code:

procedure trafficlight
loop
drawfillbox (10, 10, 100, 160, yellow)
drawfilloval (55, 135, 20, 20, black)
drawfilloval (55, 85, 20, 20, black)
drawfilloval (55, 35, 20, 20, brightgreen)
delay (7000)
drawfilloval (55, 135, 20, 20, black)
drawfilloval (55, 85, 20, 20, 43)
drawfilloval (55, 35, 20, 20, black)
delay (2000)
drawfilloval (55, 135, 20, 20, brightred)
drawfilloval (55, 85, 20, 20, black)
drawfilloval (55, 35, 20, 20, black)
delay (5000)
end loop
end trafficlight
var x, y, button : int
Mouse.Where (x, y, button)
drawfillbox (x - 15, y + 15, x + 15, y - 15, blue)
trafficlight

Author:  CodeMonkey2000 [ Wed Feb 21, 2007 7:42 pm ]
Post subject:  RE:Need help with a loop while doing something else

You should use Time.Elapsed to figure out when your should change lights. That way you can incorperate that into your main loop.


: