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

Username:   Password: 
 RegisterRegister   
 Need help with a loop while doing something else
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
LindenRulz




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




PostPosted: 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?
LindenRulz




PostPosted: 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.
Clayton




PostPosted: 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.
LindenRulz




PostPosted: 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
Clayton




PostPosted: 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.
LindenRulz




PostPosted: 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
CodeMonkey2000




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: