Author |
Message |
Michael516

|
Posted: Wed Mar 12, 2008 6:37 pm Post subject: can you have more than one loop going at once |
|
|
is it possible to have more than one loop going at once? if so, how? |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Saad

|
Posted: Wed Mar 12, 2008 6:51 pm Post subject: RE:can you have more than one loop going at once |
|
|
Just like a regular loop
Turing: |
loop
%% Your first loop
loop
%% Inner loop
end loop
end loop
|
|
|
|
|
|
 |
lordroba

|
Posted: Wed Mar 12, 2008 7:09 pm Post subject: Re: can you have more than one loop going at once |
|
|
it is also possible to do it using a process. Say you want to do something while playing music continuously in the background.
code: |
process DoMusic
loop
Music.PlayFile ("music.midi")
end loop
end DoMusic
process secondloop
loop
put "this is the second loop"
end loop
end secondloop
fork DoMusic
fork secondloop
|
|
|
|
|
|
 |
Saad

|
Posted: Wed Mar 12, 2008 7:13 pm Post subject: RE:can you have more than one loop going at once |
|
|
Oh, I'm sorry, I misread your question.
But you want to try coding it in such a way that you update everything in one loop. Take for example a bullet moving. You want to update it per frame of the main loop vs in each separate
Your general structure should go like this
Turing: |
loop
%% Update all things that need moving
end loop
|
Rather then
Turing: |
loop
%% Main loop
loop
%% Update a certain thing in this loop
end loop
end loop
|
Processes should be avoided however for music you can use them.
Hope it helps |
|
|
|
|
 |
Michael516

|
Posted: Wed Mar 12, 2008 8:20 pm Post subject: Re: can you have more than one loop going at once |
|
|
thanks, that stuff really helped. |
|
|
|
|
 |
DaveAngus

|
Posted: Tue Mar 18, 2008 10:49 am Post subject: RE:can you have more than one loop going at once |
|
|
loop %this will be your outside loop
loop %This is your inner loop
end loop %ends inner loop
end loop %ends outer loop |
|
|
|
|
 |
A.J

|
Posted: Tue Mar 18, 2008 1:17 pm Post subject: Re: can you have more than one loop going at once |
|
|
DaveAngus...that's EXACTLY what saad said....! he wanted 2 loops running at the same time, not one loop inside another....
processes are the way to go! |
|
|
|
|
 |
Sean

|
Posted: Tue Mar 18, 2008 2:34 pm Post subject: Re: can you have more than one loop going at once |
|
|
Davas has been doing this for several posts now, all he is attempting to do is increase his post count.
And yes, Processes are the way to go, Looping like above goes in a step by step, when one is done the other starts, but with the processes you can have numerous ones running at the exact same time. |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
Zampano

|
Posted: Tue Mar 18, 2008 3:22 pm Post subject: Re: can you have more than one loop going at once |
|
|
We're ones to talk. |
|
|
|
|
 |
CodeMonkey2000
|
Posted: Tue Mar 18, 2008 3:26 pm Post subject: RE:can you have more than one loop going at once |
|
|
Processes are the way to go only for music(and threading but I doubt anyone will using turing for that). For anything else do what saad said. Have everything processed through a main loop each iteration. |
|
|
|
|
 |
Dan

|
Posted: Tue Mar 18, 2008 3:42 pm Post subject: RE:can you have more than one loop going at once |
|
|
Just to clarify the reason why alot of peoleop discureage the use of processes in Turing is that Turing lacks good controls over processes to synroizne them, kill them or set there pirority level amoung other things.
Also process are an andavced topic for the high school level and using them with out fully understanding them can lead to random looking resuslts. There is no way to know when witch process will run, how offten or for how long befor giving controll to another process when not using any kind of synronzation btween them. Also processes can run slightly differently on computers with muptial cpus then with one (aucatly at the same time vs taking turns).
So using processes with out understanding what they are can lead to bad coding partices, random results and very hard to debug code.
Edit: Depending on how Turing implmentes processes under the hood, there could also be dead locking issues if not used correctly. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
 |
DaveAngus

|
Posted: Wed Mar 19, 2008 7:57 am Post subject: Re: can you have more than one loop going at once |
|
|
Vilament @ Tue Mar 18, 2008 2:34 pm wrote: Davas has been doing this for several posts now, all he is attempting to do is increase his post count.
And yes, Processes are the way to go, Looping like above goes in a step by step, when one is done the other starts, but with the processes you can have numerous ones running at the exact same time.
Actually I could care less how many posts I have.
ACtually im bored on my spares and im just trying to help you.
Get your facts straight. |
|
|
|
|
 |
|